-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
229 lines (194 loc) · 6.72 KB
/
Copy pathbuild.gradle
File metadata and controls
229 lines (194 loc) · 6.72 KB
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
plugins {
id 'java-library'
id 'maven-publish'
id 'com.gradleup.shadow' version '9.+'
}
group = 'com.cleanroommc'
version = '2.0.0'
base.archivesName = 'java-utils'
java {
toolchain {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
languageVersion = JavaLanguageVersion.of(8)
}
withSourcesJar()
}
sourceSets {
api
checker
main {
compileClasspath += api.output
runtimeClasspath += api.output
compileClasspath += checker.output
runtimeClasspath += checker.output
}
test {
compileClasspath += api.output
runtimeClasspath += api.output
compileClasspath += checker.output
runtimeClasspath += checker.output
}
}
repositories {
maven {
name 'CleanroomMC'
url 'https://maven.cleanroommc.com'
}
mavenCentral()
}
configurations {
shade
implementation.extendsFrom shade
}
dependencies {
api 'org.slf4j:slf4j-api:2.0.17'
api 'com.cleanroommc:platform-utils:2.0.0'
api 'org.jspecify:jspecify:1.0.0'
apiImplementation 'org.jspecify:jspecify:1.0.0'
shade 'com.google.code.gson:gson:2.10.1'
shade 'org.apache.commons:commons-compress:1.26.0'
runtimeOnly 'org.slf4j:slf4j-simple:2.0.17'
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// commons-compress needs commons-codec to *write* tar archives in the extraction tests
testImplementation 'commons-codec:commons-codec:1.16.1'
}
test {
useJUnitPlatform()
}
tasks.named('compileCheckerJava', JavaCompile).configure {
sourceCompatibility = JavaVersion.VERSION_1_2
targetCompatibility = JavaVersion.VERSION_1_1
options.compilerArgs << '-Xlint:-options'
}
jar {
from sourceSets.api.output.classesDirs
from sourceSets.checker.output.classesDirs
}
shadowJar {
archiveClassifier = 'all'
from sourceSets.api.output.classesDirs
from sourceSets.checker.output.classesDirs
relocate 'com.google.gson', 'com.cleanroommc.javautils.shadow.gson'
relocate 'org.apache.commons.compress', 'com.cleanroommc.javautils.shadow.compress'
mergeServiceFiles()
}
tasks.register('apiJar', Jar).configure {
group 'build'
archiveClassifier = 'api'
from sourceSets.api.output.classesDirs
}
tasks.register('apiSourceJar', Jar).configure {
group 'build'
archiveClassifier = 'api-source'
from sourceSets.api.allSource
}
tasks.register('checkerJar', Jar).configure {
group 'build'
archiveClassifier = 'checker'
from sourceSets.checker.output
manifest {
attributes('Main-Class': 'com.cleanroommc.javautils.checker.JavaChecker')
}
}
tasks.register('nolocatorJar', Jar).configure {
group 'build'
archiveClassifier = 'nolocator'
from (sourceSets.main.output.classesDirs) {
exclude 'com/cleanroommc/javautils/locators/**'
}
from sourceSets.api.output.classesDirs
from sourceSets.checker.output.classesDirs
}
tasks.register('nolocatorSourceJar', Jar).configure {
group 'build'
archiveClassifier = 'nolocator-source'
from (sourceSets.main.allSource) {
exclude 'com/cleanroommc/javautils/locators/**'
}
from sourceSets.api.allSource
from sourceSets.checker.allSource
}
tasks.register('noprovisionerJar', Jar).configure {
group 'build'
archiveClassifier = 'noprovisioner'
from (sourceSets.main.output.classesDirs) {
exclude 'com/cleanroommc/javautils/provisioners/**'
}
from sourceSets.api.output.classesDirs
from sourceSets.checker.output.classesDirs
}
tasks.register('noprovisionerSourceJar', Jar).configure {
group 'build'
archiveClassifier = 'noprovisioner-source'
from (sourceSets.main.allSource) {
exclude 'com/cleanroommc/javautils/provisioners/**'
}
from sourceSets.api.allSource
from sourceSets.checker.allSource
}
// External library coordinates, declared once and reused across variant POMs
def libDeps = [
slf4jApi: ['org.slf4j', 'slf4j-api', '2.0.17', 'compile'],
platform: ['com.cleanroommc', 'platform-utils', '2.0.0', 'compile'],
jspecify: ['org.jspecify', 'jspecify', '1.0.0', 'compile'],
gson: ['com.google.code.gson', 'gson', '2.10.1', 'runtime'],
compress: ['org.apache.commons', 'commons-compress', '1.26.0', 'runtime'],
slf4jSimple: ['org.slf4j', 'slf4j-simple', '2.0.17', 'runtime']
]
// Builds a withXml action that appends the given dependencies to a generated POM
def pomDependencies = { deps -> { xml ->
def depsNode = xml.asNode().appendNode('dependencies')
deps.each { d ->
def dep = depsNode.appendNode('dependency')
dep.appendNode('groupId', d[0])
dep.appendNode('artifactId', d[1])
dep.appendNode('version', d[2])
dep.appendNode('scope', d[3])
}
}}
publishing {
repositories {
maven {
name 'CleanroomMaven'
url 'https://repo.cleanroommc.com/releases'
credentials(PasswordCredentials)
}
}
publications {
mavenJava(MavenPublication) {
artifactId 'java-utils'
from components.java
}
mavenAll(MavenPublication) {
artifactId 'java-utils-all'
artifact(tasks.shadowJar) { classifier = null }
artifact(tasks.sourcesJar) { classifier = 'sources' }
pom.withXml(pomDependencies([libDeps.slf4jApi, libDeps.platform, libDeps.jspecify, libDeps.slf4jSimple]))
}
mavenApi(MavenPublication) {
artifactId 'java-utils-api'
artifact(tasks.apiJar) { classifier = null }
artifact(tasks.apiSourceJar) { classifier = 'sources' }
pom.withXml(pomDependencies([libDeps.jspecify]))
}
mavenChecker(MavenPublication) {
artifactId 'java-utils-checker'
artifact(tasks.checkerJar) { classifier = null }
}
mavenNolocator(MavenPublication) {
artifactId 'java-utils-nolocator'
artifact(tasks.nolocatorJar) { classifier = null }
artifact(tasks.nolocatorSourceJar) { classifier = 'sources' }
pom.withXml(pomDependencies([libDeps.slf4jApi, libDeps.platform, libDeps.jspecify, libDeps.gson, libDeps.compress, libDeps.slf4jSimple]))
}
mavenNoprovisioner(MavenPublication) {
artifactId 'java-utils-noprovisioner'
artifact(tasks.noprovisionerJar) { classifier = null }
artifact(tasks.noprovisionerSourceJar) { classifier = 'sources' }
pom.withXml(pomDependencies([libDeps.slf4jApi, libDeps.platform, libDeps.jspecify, libDeps.slf4jSimple]))
}
}
}