forked from QuiltMC/quilt-standard-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
214 lines (182 loc) · 5.98 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
import qsl.internal.Versions
plugins {
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version("1.1.3")
id("qsl.common")
}
def ENV = System.getenv()
group = "org.quiltmc"
version = Versions.QSL_VERSION
// Takes "1.0.0-beta.1" and changes it to "1.0.0-beta.2", unless we are releasing.
// TODO: there is no way to semantically identify if a release is a snapshot or not right now
if (version.contains("beta") && !ENV.MAVEN_URL) {
int beta = Integer.parseInt(version.substring(version.indexOf("beta.") + 5))
version = version.replace(version.substring(version.indexOf("beta.")), "beta." + (beta + 1))
}
version = version + "+" + Versions.MINECRAFT_VERSION.version() + (System.getenv("SNAPSHOTS_URL") ? "-SNAPSHOT" : "")
println("QSL: " + version)
sourceSets {
testmod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
// The root project simply just publishes all artifacts.
// For that reason, do not generate a remapped jar.
prepareRemapJar {
enabled = false
}
remapJar {
enabled = false
}
jar {
enabled = false
}
task fatJavadoc(type: Javadoc) {
group "documentation"
options {
source = String.valueOf(Versions.JAVA_VERSION)
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
links(
"https://guava.dev/releases/21.0/api/docs/",
"https://asm.ow2.io/javadoc/",
"https://docs.oracle.com/en/java/javase/16/docs/api/",
"https://jenkins.liteloader.com/job/Mixin/javadoc/",
"https://logging.apache.org/log4j/2.x/log4j-api/apidocs/",
"https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-mappings/${Versions.MINECRAFT_VERSION.version()}+build.${Versions.MAPPINGS_BUILD}/quilt-mappings-${Versions.MINECRAFT_VERSION.version()}+build.${Versions.MAPPINGS_BUILD}-javadoc.jar/"
)
// Disable the overzealous doclint tool in Java 8
addStringOption("Xdoclint:none", "-quiet")
tags(
"author:a",
'reason:m:"Reason:"'
)
}
failOnError false
exclude {
it.file.absolutePath.contains("mixin") || it.file.absolutePath.contains("impl")
}
afterEvaluate {
subprojects.each { subproject ->
subproject.tasks.withType(Javadoc).each { javadocTask ->
source += javadocTask.source
classpath += javadocTask.classpath
// TODO: find a proper fix for this
// What does this do? Well, turns out transitive access wideners aren't applied properly,
// which fails the fat javadoc task! Since Quilt Block Entity adds a transitive access widener to a private interface.
// So what do we do? We simply removed the Vanilla JAR and hope that the correct transformed JAR shows up first.
// The proper fix is to get the root project to generate a new MC JAR that contains all the transitive transformations of the modules
// applied and pass that to the fat javadoc task instead.
.filter { !it.name.startsWith("minecraft-merged-named") }
}
}
}
destinationDir = file("${buildDir}/docs/fat-javadoc")
}
task fatJavadocJar(type: Jar) {
group "build"
classifier "fat-javadoc"
dependsOn fatJavadoc
from fatJavadoc.destinationDir
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact fatJavadocJar
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
rootProject.subprojects.stream().filter {
it.path.count(':') == 1
}.forEach {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
}
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
// Because we rely on the results of our libraries, we use afterEvaluate to setup the sourcesets and testmod tasks.
afterEvaluate {
// Add sourceSet dependencies on all libraries
// Make this project include the compileClasspath and runtimeClasspath of the libraries.
subprojects.stream().filter { it.path.count(":") == 1 }.each {
project.sourceSets.main.compileClasspath += it.sourceSets.main.compileClasspath
project.sourceSets.main.runtimeClasspath += it.sourceSets.main.runtimeClasspath
project.sourceSets.testmod.compileClasspath += it.sourceSets.testmod.compileClasspath
project.sourceSets.testmod.runtimeClasspath += it.sourceSets.testmod.runtimeClasspath
}
}
loom {
runs {
testmodClient {
client()
configName = "Testmod Client"
source(project.sourceSets.testmod)
programArg("--uuid=1")
}
testmodServer {
server()
configName = "Testmod Server"
source(project.sourceSets.testmod)
}
// Auto test server, a server is ran for a few seconds and testmods run to verify things such as mixin
// application function properly.
// This task is typically ran by the CI server.
autoTestServer {
server()
configName = "Auto test server"
source(project.sourceSets.testmod)
property("quilt.auto_test")
programArg("--nogui")
}
}
}
afterEvaluate {
def generateQmjForIdea = tasks.create("generateQmjForIdea")
project.subprojects.each {
it.subprojects.each {
generateQmjForIdea.dependsOn it.tasks.getByName("generateQmj")
}
}
idea {
project {
settings {
taskTriggers {
afterSync generateQmjForIdea
}
}
}
}
testmodRemapJar { tsk ->
nestedJars.setFrom(Collections.emptySet())
rootProject.subprojects.stream().filter {
it.path.count(':') == 1
}.forEach {
tsk.nestedJars.from it.tasks.getByName("testmodRemapJar")
}
}
}
task checkVersion {
doFirst {
try {
def xml = new URL("https://maven.quiltmc.org/repository/release/org/quiltmc/qsl/maven-metadata.xml").text
def metadata = new groovy.xml.XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text()
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
} catch (FileNotFoundException ignored) {
// No existing version of library found
}
}
}
project.getTasksByName("checkLibVersion", true).each {
checkVersion.dependsOn it
}
publish.dependsOn checkVersion