-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
executable file
·264 lines (227 loc) · 7.72 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT' apply false
id 'org.cadixdev.licenser' version '0.6.1'
id "org.ajoberstar.grgit" version "3.1.1"
id 'com.matthewprenger.cursegradle' version "1.4.0"
}
import net.fabricmc.loom.task.RunClientTask
def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? "9999" : System.getenv("GITHUB_RUN_NUMBER"))
version = rootProject.base_version + "." + runNumber
logger.lifecycle("Building cloth-api: " + version)
archivesBaseName = "cloth-api"
def getBranch() {
if (System.getenv().GIT_BRANCH) {
def branch = System.getenv().GIT_BRANCH
return branch.substring(branch.lastIndexOf("/") + 1)
}
if (grgit == null) {
return "unknown"
}
def branch = grgit.branch.current().name
return branch.substring(branch.lastIndexOf("/") + 1)
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'dev.architectury.loom'
apply plugin: 'org.cadixdev.licenser'
sourceCompatibility = targetCompatibility = 1.8
group = "me.shedaniel.cloth.api"
ext {
shouldGenerateData = false
}
sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
resources {
srcDir 'src/generated/resources'
}
}
datagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
repositories {
maven { url "https://maven.shedaniel.me/" }
}
dependencies {
minecraft "com.mojang:minecraft:$project.minecraft_version"
mappings "me.shedaniel:legacy-yarn:${project.yarn_version}:v2"
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
modImplementation "me.shedaniel.cloth:basic-math:${project.cloth_basic_math}"
}
configurations {
dev
}
jar {
classifier = "dev"
}
afterEvaluate {
remapJar {
input = file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}.jar"
}
artifacts {
dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
license {
header rootProject.file('HEADER')
include '**/*.java'
}
if (shouldGenerateData) {
task generateData(type: RunClientTask, dependsOn: downloadAssets) {
classpath = configurations.runtimeClasspath
classpath sourceSets.main.output
classpath sourceSets.datagen.output
}
build.dependsOn generateData
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocs(type: Javadoc) {
source = sourceSets.main.allJava
}
task javadocsJar(type: Jar, dependsOn: javadocs) {
archiveClassifier.set("javadocs")
javadocs.failOnError false
from javadocs.destinationDir
}
}
subprojects {
version = rootProject.version
dependencies {
testmodImplementation sourceSets.main.output
datagenImplementation sourceSets.main.output
}
task remapMavenJar(type: Copy, dependsOn: remapJar) {
afterEvaluate {
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
into("${project.buildDir}/libs/")
rename { String fn -> "$archivesBaseName-${version}-maven.jar" }
}
}
publishing {
publications {
create("${archivesBaseName}_mavenJava", MavenPublication) {
afterEvaluate {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocsJar
}
}
}
repositories {
if (System.getenv("MAVEN_PASS") != null) {
maven {
url = "https://deploy.shedaniel.me/"
credentials {
username = "shedaniel"
password = System.getenv("MAVEN_PASS")
}
}
}
}
}
}
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
afterEvaluate {
input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
archiveName = "${archivesBaseName}-${version}-maven.jar"
addNestedDependencies = false
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocsJar
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
repositories {
if (System.getenv("MAVEN_PASS") != null) {
maven {
url = "https://deploy.shedaniel.me/"
credentials {
username = "shedaniel"
password = System.getenv("MAVEN_PASS")
}
}
}
}
}
task licenseFormatAll
subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
sourceSets {
testmod
datagen
}
dependencies {
subprojects.each {
implementation project(path: ":${it.name}", configuration: "dev")
include project("${it.name}:")
testmodImplementation project("${it.name}:").sourceSets.testmod.output
}
include "me.shedaniel.cloth:basic-math:${project.cloth_basic_math}"
}
curseforge {
apiKey = project.hasProperty('apiKey') ? project.property('apiKey') : System.getenv('CF_API_KEY')
if (apiKey != null)
project {
id = '317121'
changelog = 'A changelog can be found at https://github.com/shedaniel/cloth-api/commits'
releaseType = 'release'
addGameVersion '1.16-Snapshot'
addGameVersion '1.16.2'
addGameVersion 'Java 8'
addGameVersion 'Fabric'
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
displayName = "[Fabric $project.minecraft_version] v$project.version"
}
afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}
options {
forgeGradleIntegration = false
javaVersionAutoDetect = false
}
}