-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
101 lines (85 loc) · 3.25 KB
/
build.gradle.kts
File metadata and controls
101 lines (85 loc) · 3.25 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
plugins {
id("openlayer.kotlin")
id("com.gradleup.shadow") version "8.3.8"
}
buildscript {
repositories {
google()
}
dependencies {
classpath("com.guardsquare:proguard-gradle:7.4.2")
classpath("com.android.tools:r8:8.3.37")
}
}
dependencies {
testImplementation(project(":openlayer-java"))
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0")
}
tasks.shadowJar {
from(sourceSets.test.get().output)
configurations = listOf(project.configurations.testRuntimeClasspath.get())
}
val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar"
val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) {
group = "verification"
dependsOn(tasks.shadowJar)
notCompatibleWithConfigurationCache("ProGuard")
injars(tasks.shadowJar)
outjars(proguardJarPath)
printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt")
val javaHome = System.getProperty("java.home")
if (System.getProperty("java.version").startsWith("1.")) {
// Before Java 9, the runtime classes were packaged in a single jar file.
libraryjars("$javaHome/lib/rt.jar")
} else {
// As of Java 9, the runtime classes are packaged in modular jmod files.
libraryjars(
// Filters must be specified first, as a map.
mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"),
"$javaHome/jmods/java.base.jmod"
)
}
configuration("./test.pro")
configuration("../openlayer-java-core/src/main/resources/META-INF/proguard/openlayer-java-core.pro")
}
val testProGuard by tasks.registering(JavaExec::class) {
group = "verification"
dependsOn(proguardJar)
notCompatibleWithConfigurationCache("ProGuard")
mainClass.set("com.openlayer.api.proguard.ProGuardCompatibilityTest")
classpath = files(proguardJarPath)
}
val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar"
val r8Jar by tasks.registering(JavaExec::class) {
group = "verification"
dependsOn(tasks.shadowJar)
notCompatibleWithConfigurationCache("R8")
mainClass.set("com.android.tools.r8.R8")
classpath = buildscript.configurations["classpath"]
args = listOf(
"--release",
"--classfile",
"--output", r8JarPath,
"--lib", System.getProperty("java.home"),
"--pg-conf", "./test.pro",
"--pg-conf", "../openlayer-java-core/src/main/resources/META-INF/proguard/openlayer-java-core.pro",
"--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt",
tasks.shadowJar.get().archiveFile.get().asFile.absolutePath,
)
}
val testR8 by tasks.registering(JavaExec::class) {
group = "verification"
dependsOn(r8Jar)
notCompatibleWithConfigurationCache("R8")
mainClass.set("com.openlayer.api.proguard.ProGuardCompatibilityTest")
classpath = files(r8JarPath)
}
tasks.test {
dependsOn(testProGuard)
dependsOn(testR8)
// We defer to the tests run via the ProGuard JAR.
enabled = false
}