Skip to content

Commit

Permalink
build: don't merge jars with ShadowJar (#2401)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jan 31, 2025
1 parent 3d36c93 commit 61759a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 50 deletions.
21 changes: 5 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,12 @@ fun isNonStable(version: String): Boolean {
}

val copyArtifacts by tasks.registering(Copy::class) {
val jarCliPattern = "jadx-cli-(.*)-all.jar".toPattern()
from(tasks.getByPath(":jadx-cli:installShadowDist")) {
exclude("**/*.jar")
filter { line ->
jarCliPattern.matcher(line).replaceAll("jadx-$1-all.jar")
.replace("-jar \"\\\"\$CLASSPATH\\\"\"", "-cp \"\\\"\$CLASSPATH\\\"\" jadx.cli.JadxCLI")
.replace("-jar \"%CLASSPATH%\"", "-cp \"%CLASSPATH%\" jadx.cli.JadxCLI")
}
}
val jarGuiPattern = "jadx-gui-(.*)-all.jar".toPattern()
from(tasks.getByPath(":jadx-gui:installShadowDist")) {
exclude("**/*.jar")
filter { line -> jarGuiPattern.matcher(line).replaceAll("jadx-$1-all.jar") }
from(tasks.getByPath(":jadx-cli:installDist")) {
include("**/bin/*") // copy only scripts
}
from(tasks.getByPath(":jadx-gui:installShadowDist")) {
include("**/*.jar")
rename("jadx-gui-(.*)-all.jar", "jadx-$1-all.jar")
from(tasks.getByPath(":jadx-gui:installDist")) {
include("**/bin/*")
include("**/lib/*.jar")
}
from(layout.projectDirectory) {
include("README.md")
Expand Down
8 changes: 2 additions & 6 deletions jadx-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ plugins {
id("jadx-java")
id("jadx-library")
id("application")

// use shadow only for application scripts, jar will be copied from jadx-gui
id("com.gradleup.shadow") version "8.3.5"
}

dependencies {
Expand Down Expand Up @@ -45,7 +42,6 @@ application {
}
}

tasks.shadowJar {
// shadow jar not needed
configurations = listOf()
tasks.startScripts {
classpath = files("lib/*")
}
41 changes: 13 additions & 28 deletions jadx-gui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id("application")
id("jadx-library")
id("edu.sc.seis.launch4j") version "3.0.6"
id("com.gradleup.shadow") version "8.3.5"
id("org.beryx.runtime") version "1.13.1"
}

Expand Down Expand Up @@ -93,22 +92,8 @@ tasks.jar {
}
}

tasks.shadowJar {
isZip64 = true
mergeServiceFiles()
manifest {
from(tasks.jar.get().manifest)
}
}

// workaround to exclude shadowJar 'all' artifact from publishing to maven
project.components.withType(AdhocComponentWithVariants::class.java).forEach { c ->
c.withVariantsFromConfiguration(project.configurations.shadowRuntimeElements.get()) {
skip()
}
}

tasks.startShadowScripts {
tasks.startScripts {
classpath = files("lib/*")
doLast {
val newContent =
windowsScript.readText()
Expand All @@ -133,7 +118,7 @@ launch4j {
requires64Bit.set(true)
downloadUrl.set("https://www.oracle.com/java/technologies/downloads/#jdk21-windows")
bundledJrePath.set(if (project.hasProperty("bundleJRE")) "%EXEDIR%/jre" else "%JAVA_HOME%")
classpath.set(tasks.getByName("shadowJar").outputs.files.map { "%EXEDIR%/lib/${it.name}" }.toSortedSet())
classpath.set(listOf("%EXEDIR%/lib/*"))
}

runtime {
Expand All @@ -158,11 +143,11 @@ runtime {
val copyDistWin by tasks.registering(Copy::class) {
description = "Copy files for Windows bundle"

val libTask = tasks.getByName("shadowJar")
dependsOn(libTask)
from(libTask.outputs) {
include("*.jar")
into("lib")
val distTask = tasks.getByName("installDist")
dependsOn(distTask)
from(distTask.outputs) {
include("**/lib/*.jar")
includeEmptyDirs = false
}
val exeTask = tasks.getByName("createExe")
dependsOn(exeTask)
Expand All @@ -182,11 +167,11 @@ val copyDistWinWithJre by tasks.registering(Copy::class) {
include("**/*")
into("jre")
}
val libTask = tasks.getByName("shadowJar")
dependsOn(libTask)
from(libTask.outputs) {
include("*.jar")
into("lib")
val distTask = tasks.getByName("installDist")
dependsOn(distTask)
from(distTask.outputs) {
include("**/lib/*.jar")
includeEmptyDirs = false
}
val exeTask = tasks.getByName("createExe")
dependsOn(exeTask)
Expand Down

0 comments on commit 61759a9

Please sign in to comment.