|
| 1 | +plugins { |
| 2 | + id("lithic.kotlin") |
| 3 | + id("com.gradleup.shadow") version "8.3.8" |
| 4 | +} |
| 5 | + |
| 6 | +buildscript { |
| 7 | + dependencies { |
| 8 | + classpath("com.guardsquare:proguard-gradle:7.4.2") |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +dependencies { |
| 13 | + testImplementation(project(":lithic-java")) |
| 14 | + testImplementation(kotlin("test")) |
| 15 | + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") |
| 16 | + testImplementation("org.assertj:assertj-core:3.25.3") |
| 17 | + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") |
| 18 | + testImplementation("org.junit.platform:junit-platform-console:1.10.1") |
| 19 | +} |
| 20 | + |
| 21 | +tasks.shadowJar { |
| 22 | + from(sourceSets.test.get().output) |
| 23 | + configurations = listOf(project.configurations.testRuntimeClasspath.get()) |
| 24 | +} |
| 25 | + |
| 26 | +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" |
| 27 | +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { |
| 28 | + group = "verification" |
| 29 | + dependsOn(tasks.shadowJar) |
| 30 | + notCompatibleWithConfigurationCache("ProGuard") |
| 31 | + |
| 32 | + injars(tasks.shadowJar) |
| 33 | + outjars(proguardJarPath) |
| 34 | + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") |
| 35 | + |
| 36 | + verbose() |
| 37 | + dontwarn() |
| 38 | + |
| 39 | + val javaHome = System.getProperty("java.home") |
| 40 | + if (System.getProperty("java.version").startsWith("1.")) { |
| 41 | + // Before Java 9, the runtime classes were packaged in a single jar file. |
| 42 | + libraryjars("$javaHome/lib/rt.jar") |
| 43 | + } else { |
| 44 | + // As of Java 9, the runtime classes are packaged in modular jmod files. |
| 45 | + libraryjars( |
| 46 | + // Filters must be specified first, as a map. |
| 47 | + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), |
| 48 | + "$javaHome/jmods/java.base.jmod" |
| 49 | + ) |
| 50 | + } |
| 51 | + |
| 52 | + configuration("./test.pro") |
| 53 | + configuration("../lithic-java-core/src/main/resources/META-INF/proguard/lithic-java-core.pro") |
| 54 | +} |
| 55 | + |
| 56 | +val testProGuard by tasks.registering(JavaExec::class) { |
| 57 | + group = "verification" |
| 58 | + dependsOn(proguardJar) |
| 59 | + notCompatibleWithConfigurationCache("ProGuard") |
| 60 | + |
| 61 | + mainClass.set("org.junit.platform.console.ConsoleLauncher") |
| 62 | + classpath = files(proguardJarPath) |
| 63 | + args = listOf( |
| 64 | + "--classpath", proguardJarPath, |
| 65 | + "--scan-classpath", |
| 66 | + "--details", "verbose", |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +tasks.test { |
| 71 | + dependsOn(testProGuard) |
| 72 | + // We defer to the tests run via the ProGuard JAR. |
| 73 | + enabled = false |
| 74 | +} |
0 commit comments