Prashant Sahi
07/09/2024, 3:38 PMtask('zipConfig', type:Zip) {
archiveBaseName = 'objectharvesterservice-restapi'
archiveClassifier = 'tomcat'
from('src/main/assemblies/tomcat/zip')
}
tasks.named('bootWar').configure {
doLast {
copy {
from "build/libs/objectharvesterservice-restapi.war"
into "src/main/assemblies/tomcat/zip/objectharvesterservice-restapi-${version}/webapps"
rename "objectharvesterservice-restapi.war", "objectharvesterservice.war"
}
copy {
from "src/main/assemblies/tomcat/conf"
into "src/main/assemblies/tomcat/zip/objectharvesterservice-restapi-${version}/conf"
}
mkdir "src/main/assemblies/tomcat/zip/objectharvesterservice-restapi-${version}/temp"
tasks['zipConfig'].execute()
}
}Thomas Broyer
07/09/2024, 3:50 PMdoLast on an existing task, and instead configure the zipConfig task to do the equivalent (putting the files directly into the generated ZIP file rather than to an intermediary folder)
• properly declare dependencies between tasks (use the bootWar task's outputs as inputs to the zipConfig task, rather than relying on file paths alone)
• maybe declare the zipConfig as a dependency of the assemble task, rather than as a finalizer of bootWarThomas Broyer
07/09/2024, 3:56 PMtask('zipConfig', type: Zip) {
archiveBaseName = 'objectharvesterservice-restapi'
archiveClassifier = 'tomcat'
from(tasks.named('bootWar')) {
into "objectharvesterservice-restapi-${version}/webapps"
rename "objectharvesterservice-restapi.war", "objectharvesterservice.war" // this could probably be improved
}
from('src/main/assemblies/tomcat/conf') {
into "objectharvesterservice-restapi-${version}/conf"
}
}
tasks.named('assemble') { dependsOn('zipConfig') }Prashant Sahi
07/09/2024, 4:01 PM