Fanish
12/24/2025, 7:42 AMPhilip W
12/24/2025, 7:59 AMFanish
12/24/2025, 9:00 AMtasks.register('copyProductDependencies', Copy) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from configurations.compileClasspath
into "$buildDir/$izpackStaging/libb"
exclude 'org/codehaus/izpack/**'
rename { String fileName ->
fileName.replaceFirst(/-(\d+\.)*\d+(-SNAPSHOT)?(?=\.(jar|zip)$)/, '$3')
}
but it is not able to handle all type of jars as there are many type of conversion.
I am surprised maven is able to do in on line but in gradle I need to lot of work. is there any alternative way in gradle.Philip W
12/24/2025, 9:16 AMAdam
12/24/2025, 1:04 PM${artifactId}-${version}-${classifier}.${extension}.Adam
12/24/2025, 1:13 PMVampire
12/24/2025, 2:45 PMI am surprised maven is able to do in on line but in gradle I need to lot of work. is there any alternative way in gradle.Maybe because it is usually a very bad idea and Gradle tries to help you not shooting your own foot? Artifacts without version in the name are always problematic later on, as you don't know their version, ... 🤷♂️ I would probably not try to regex-manipulate stuff, but just do it the way I need it upfront, something like
interface FileSystemOperationsProvider {
@get:Inject
val fileSystemOperations: FileSystemOperations
}
val foo by tasks.registering {
val compileClasspath = configurations.compileClasspath
inputs.files(compileClasspath).withPathSensitivity(PathSensitivity.NAME_ONLY).withPropertyName("compileClasspath")
val destinationDir = layout.buildDirectory.dir("versionless-libs")
outputs.dir(destinationDir)
val fs = objects.newInstance<FileSystemOperationsProvider>().fileSystemOperations
val artifacts = compileClasspath.map { it.incoming.artifacts }
doLast {
fs.sync {
artifacts.get().forEach { artifact ->
from(artifact.file) {
rename {
when (val id = artifact.id.componentIdentifier) {
is ModuleComponentIdentifier -> "${id.module}.jar"
is ProjectComponentIdentifier -> "${id.projectName}.jar"
else -> it
}
}
}
}
into(destinationDir)
}
}
}Scott Palmer
01/08/2026, 9:16 PM