Hello,
for a project that is based on Java 11, I included a subproject (‘splitjars’) for processing of third party JARs to fight the ‘split jar’ problem. The subproject has its own build.gradle.kts:
val xercesVersion = "2.11.0"
val ueberjars = configurations.create("ueberjars")
dependencies {
ueberjars("com.github.jnr", "jnr-enxio", "0.1.9")
ueberjars("com.github.jnr", "jnr-unixsocket", "0.21")
ueberjars("xerces", "xercesImpl", xercesVersion)
}
tasks {
val copyJarsForUeberJars = task("copyJarsForUeberJars", Copy::class) {
val ueberBaseFiles = configurations.get("ueberjars").resolvedConfiguration.files
println("ueberBaseFiles: " + ueberBaseFiles)
from(ueberBaseFiles) {
rename("([a-zA-Z_]+)-([\\d\\.]+(.*)).jar", "$1.jar")
}
into("./lib/tmp")
}
val unzipXerces = task("unzipXerces", Copy::class) {
from(zipTree(file("lib/tmp/xercesImpl.jar"))) {
exclude("org/w3c/**/*")
}
into("./lib/tmp/xercesImpl")
dependsOn(copyJarsForUeberJars)
}
val rezipStrippedXerces = task("rezipStrippedXerces", Jar::class) {
baseName = "xerces-stripped"
from(files("./lib/tmp/xercesImpl")) {
}
dependsOn(unzipXerces)
}
}
The idea is to remove some files from xercesImpl.jar that are problematic for Java 11, and to depend on the subproject in the main project and use the (modified) xercesImpl.jar as dependency there:
...
dependencies {
...
api("", "xerces-stripped", "")
...
}
...
tasks.named("compileJava") {
dependsOn(gradle.includedBuild("jingtrang").task(":build"))
dependsOn(":splitjars:rezipStrippedXerces")
}
However, I always get this mysterious error:
* What went wrong:
A problem was found with the configuration of task ':splitjars:rezipStrippedXerces'.
> No value has been specified for property 'archiveFile'.
I would be glad if someone could explain the error message to me or suggest another way to depend on a (modified) jar as dependency.
PS:
The complete project is at https://github.com/aanno/db-toolchain , branch ‘feature/splitjar-subproject’. You need to run ./script/bootstrap.sh after checkout.