The assemble task includes the following tasks, as far as I know:
:compileJava
:processResources
:classes
:jar
:assemble
My jar task depends on a copy library task in which I copy all my libraries from my implementation configuration into a libs folder. To get a working executable jar currently I assemble my project, execute the copy libs task and then the jar task again (which iterates over the libs and adds their name to the classpath) as this works fine.
:compileJava
:processResources
:classes
:jar
:assemble
:copyLibs
:jar
But when I put the copy libs task before the jar task via dependsOn
then when I execute my project the jar doesn’t find all libs, even though it seems like they have been copied successfully.
:compileJava
:processResources
:classes
:copyLibs
:jar
:assemble
EDIT: The copyLibs and jar task of my build.gradle
project.configurations.implementation.setCanBeResolved(true)
task copyLibs(type: Copy) {
from configurations.implementation
into "$buildDir/libs"
}
build.dependsOn copyLibs
jar {
manifest {
attributes 'Main-Class': 'dc.v077a.server.ServerMain',
'Class-Path': fileTree("$buildDir/libs").filter {
it.isFile() && !it.name.startsWith("dc-v077a-server") }.files.name.join(' ')
}
}