generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
199 lines (157 loc) · 5.03 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
id 'com.matthewprenger.cursegradle' version '1.4.+'
id "com.modrinth.minotaur" version "2.+"
id 'io.github.juuxel.loom-quiltflower' version '1.7.+'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
group = project.maven_group
repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url "https://maven.quiltmc.org/repository/release" }
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
//For compatibility purposes only
modCompileOnly group: 'org.quiltmc', name: 'quilt-loader', version: project.quilt_loader
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Non Fabric dependencies
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
compileOnly("com.google.code.findbugs:annotations:3.0.1")
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
/**
* Rename every resource file to lowercase. With that, we can allow Crowdin to translate.
*/
tasks.withType(Copy) {
eachFile {
rename {
String filename-> filename.toLowerCase()
}
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
//---------------- Publishing ----------------
ext.ENV = System.getenv()
ext.cfType = ENV.RELEASE_TYPE ? ENV.RELEASE_TYPE : "alpha"
ext.isRelease = cfType == "release"
ext.changes = ENV.CHANGELOG ? ENV.CHANGELOG.replaceAll("\\\\n", "\n") : ""
ext.mod_version = project.mod_version
if(!isRelease){
ext.mod_version = "${project.mod_version}-SNAPSHOT-${ ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : 'git rev-parse --verify --short HEAD'.execute().text.trim()}"
}
version = ext.mod_version
ext.keysExists = ENV.CURSEFORGE_TOKEN != null || project.getGradle().getStartParameter().isDryRun()
if(keysExists) {
println("Keys loaded, loading publish scripts")
project.ext.keys = new Properties()
if (project.getGradle().getStartParameter().isDryRun()) {
println("Dry run, loading publish scripts")
//These are fake, don't waste your time with it.
project.ext.keys.curseforge_key = "00000000-0000-0000-0000-000000000000"
project.ext.keys.modrinth_token = "gho_pJ9dGXVKpfzZp4PUHSxYEq9hjk0h288Gwj4S"
project.ext.keys.kosmx_maven = "V2h5IGRpZCB5b3UgZGVjb2RlIGl0PyAg"
} else {
project.ext.keys.curseforge_key = ENV.CURSEFORGE_TOKEN
project.ext.keys.modrinth_token = ENV.MODRINTH_TOKEN
project.ext.keys.kosmx_maven = ENV.KOSMX_TOKEN //KosmX's maven (maven.kosmx.dev)
}
modrinth {
versionType = project.cfType
token = project.keys.modrinth_token
projectId = "gxpkKtVH"
versionNumber = "${project.mod_version}"
versionName = "${project.mod_version}"
gameVersions = ['1.19', '1.19.1', '1.19.2']
changelog = changes
loaders = ["fabric", "quilt"]
uploadFile = remapJar
}
curseforge {
apiKey = project.keys.curseforge_key
project {
id = '565968'
changelogType = "markdown"
changelog = changes
releaseType = project.cfType
addGameVersion "1.19"
addGameVersion "1.19.1"
addGameVersion "1.19.2"
addGameVersion "Fabric"
relations {
requiredDependency 'fabric-api'
requiredDependency 'modmenu'
embeddedLibrary 'cloth-config'
}
options {
forgeGradleIntegration = false // FABRIC MOD
javaVersionAutoDetect = false // defaults to true
}
mainArtifact(remapJar)
afterEvaluate {
uploadTask.dependsOn(remapJar)
}
}
}
task publishMod {
dependsOn(build)
finalizedBy(publish)
finalizedBy(tasks.curseforge)
finalizedBy("modrinth")
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
if (project.keysExists) {
maven {
url = 'https://maven.kosmx.dev/'
credentials {
username = 'blanketGH'
password = project.keys.kosmx_maven
}
}
} else {
mavenLocal()
}
}
}