-
Notifications
You must be signed in to change notification settings - Fork 89
/
build.gradle
328 lines (268 loc) · 9.32 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
import org.vineflower.build.JasmCompile
import org.vineflower.build.TestDataRuntimesProvider
import java.time.Duration
plugins {
id 'jacoco'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.jetbrains.kotlin.jvm' version '1.6.21'
id("io.github.gradle-nexus.publish-plugin") version '2.0.0-rc-2'
}
apply plugin: 'jacoco'
apply plugin: 'java-test-fixtures'
apply plugin: 'groovy'
apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: 'signing'
allprojects {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
ext.isArm = System.getProperty('os.arch') == 'aarch64'
group = 'org.vineflower'
compileJava {
sourceCompatibility = '11'
targetCompatibility = '11'
}
java.toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.jetbrains:annotations:24.0.0'
testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junit_bom}")
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${project.junit_bom}")
}
test {
useJUnitPlatform()
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
}
group = 'org.vineflower'
archivesBaseName = 'vineflower'
version = '1.10.1'
def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
version = version + (ENV.STATUS == "snapshot" ? "-SNAPSHOT" : "")
sourceSets {
main.java.srcDirs 'src'
test.java.srcDirs 'test'
testFixtures.java.srcDirs 'testFixtures'
testDataGroovy.groovy.srcDirs files("testData/src/groovy/")
testDataKotlin.kotlin.srcDirs files("testData/src/kt/")
testDataScala.scala.srcDirs files("testData/src/scala")
}
repositories { mavenCentral() }
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junit_bom}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${project.junit_bom}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junit_bom}")
testImplementation("org.hamcrest:hamcrest:${project.hamcrest}")
testFixturesImplementation("org.junit.jupiter:junit-jupiter-params:${project.junit_bom}")
testFixturesImplementation("org.hamcrest:hamcrest:${project.hamcrest}")
testDataGroovyImplementation("org.codehaus.groovy:groovy:${project.groovy}")
testDataKotlinImplementation platform("org.jetbrains.kotlin:kotlin-bom")
testDataKotlinImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testDataScalaImplementation("org.scala-lang:scala3-library_3:${project.scala_library}")
testRuntimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
jacocoTestReport.dependsOn(test)
build.dependsOn(jacocoTestReport)
jacocoTestReport {
reports {
xml.required = true
}
}
tasks.withType(JavaCompile) {
options.deprecation = true
}
task testDataClasses {
group = 'build'
}
testClasses.dependsOn(testDataClasses)
void createJavaTestDataSet(int version, String suffix = "", List<String> compilerArgs = []) {
sourceSets.create("testDataJava${version}${suffix}") {
it.java.srcDirs file("testData/src/java${version}${suffix.toLowerCase()}")
}
tasks.getByName("compileTestDataJava${version}${suffix}Java") {
destinationDirectory = file("testData/classes/java${version}${suffix.toLowerCase()}")
if (project.isArm && version > 8 && version < 11) {
// On ARM systems, a more limited set of JVM versions are available
// We'll accept the `--release` flag so development is at least somewhat possible
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(11)
}
options.release = version
} else {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(version)
}
}
options.compilerArgs = compilerArgs
}
testDataClasses.dependsOn("testDataJava${version}${suffix}Classes")
}
def testJavaRuntimes = [:]
[8, 9, 11, 16, 17, 21].forEach { version ->
def runtimeVersion = isArm && version > 8 && version < 11 ? 11 : version
createJavaTestDataSet(version)
testJavaRuntimes[version] = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(runtimeVersion)
}
}
[16, 17, 19, 21].forEach { version -> createJavaTestDataSet(version, "Preview", ["--enable-preview"]) }
[8, 16].forEach { version -> createJavaTestDataSet(version, "NoDebug", ["-g:none"])}
task compileTestDataJasm(type: JasmCompile) {
source = fileTree("testData/src/jasm/")
destinationDirectory = file("testData/classes/jasm/")
options.compilerArgs += ["-g"]
}
task testDataJasmClasses {
group = 'build'
}
testDataJasmClasses.dependsOn(compileTestDataJasm)
testDataClasses.dependsOn(testDataJasmClasses)
compileTestDataGroovyGroovy {
destinationDirectory = file("testData/classes/groovy")
}
testDataClasses.dependsOn(testDataGroovyClasses)
compileTestDataKotlinKotlin {
destinationDirectory = file("testData/classes/kt")
}
testDataClasses.dependsOn(testDataKotlinClasses)
compileTestDataScalaScala {
destinationDirectory = file("testData/classes/scala")
}
testDataClasses.dependsOn(testDataScalaClasses)
test {
maxHeapSize = "512M"
systemProperty "DOT_EXPORT_DIR", System.getProperty("DOT_EXPORT_DIR", null)
systemProperty "DOT_ERROR_EXPORT_DIR", System.getProperty("DOT_ERROR_EXPORT_DIR", null)
systemProperty "VALIDATE_DECOMPILED_CODE", System.getProperty("VALIDATE_DECOMPILED_CODE", "false")
def provider = objects.newInstance(TestDataRuntimesProvider)
testJavaRuntimes.each { k, v ->
provider.launchers.put(k, v)
}
jvmArgumentProviders << provider
}
jar {
archiveClassifier = "slim"
from sourceSets.main.output
manifest {
attributes (
'Main-Class': 'org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler',
'Implementation-Name': "Vineflower",
'Implementation-Version': project.version
)
}
}
// If testFixtures can't be inferred from the build path, it'll need to be manually specified to be able to find
// the test fixtures class. Put it in a unique place to mark it as such.
testFixturesJar {
destinationDirectory = file("$rootDir/build/extralibs")
}
task sourceJar(type:Jar) {
archiveClassifier = "sources"
from sourceSets.main.allSource
}
tasks.withType(Javadoc) {
failOnError false
include 'org/jetbrains/java/decompiler/api/**'
include 'org/jetbrains/java/decompiler/main/extern/**'
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.withType(Jar) {
reproducibleFileOrder = true
preserveFileTimestamps = false
}
def allJar = tasks.register('allJar', Jar) {allJar ->
archiveClassifier.set('')
from sourceSets.main.output
manifest {
attributes (
'Main-Class': 'org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler',
'Implementation-Name': "Vineflower",
'Implementation-Version': project.version
)
}
subprojects.each {
// Check if gradle.properties has 'does_shadow=true', and use the shadowJar configuration if so
Task buildTask = it.tasks.named("true".equals(it.does_shadow) ? 'shadowJar' : 'jar').get()
// Make sure the task is defined as a dependency
dependsOn buildTask
// Relocate the jar into META-INF/plugins
allJar.from(buildTask.outputs) {
into 'META-INF/plugins/'
}
}
}
build.dependsOn(allJar)
publishing {
publications {
mavenJava(MavenPublication) {
pom {
name = 'Vineflower'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'Modern Java & JVM language decompiler aiming to be as accurate as possible, with an emphasis on output quality.'
url = 'https://vineflower.org'
scm {
connection = 'scm:git:https://github.com/Vineflower/vineflower.git'
developerConnection = 'scm:git:ssh:[email protected]:Vineflower/vineflower.git'
url = 'https://github.com/Vineflower/vineflower'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'vineflower'
name = 'Vineflower Development Team'
email = '~jasmine/[email protected]'
}
}
}
// VF-only jar
artifact jar
// Jar with included plugins
artifact allJar
artifact sourcesJar
artifact javadocJar
}
}
}
nexusPublishing {
repositories {
sonatype {
username = ENV.SONATYPE_USER
password = ENV.SONATYPE_PASS
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
// nexus is eepy, give her time to respond
def timeout = Duration.ofMinutes(6)
clientTimeout = timeout
connectTimeout = timeout
}
signing {
if (ENV.SIGNING_KEY) {
def signingKey = ENV.SIGNING_KEY
def signingPassword = ENV.SIGNING_KEY_PASSPHRASE
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}