I have a custom incremental build task that signs all jar dependencies for my Java project. It looks like this:
task signJarDependencies(type: IncrementalSignJarTask) {
inputFiles = configurations.deployment #<-- key line to notice
outputDir = webstartLibDir
inputProperty = 'original'
}
class IncrementalSignJarTask extends DefaultTask {
@InputFiles
def FileCollection inputFiles
@OutputDirectory
def File outputDir
@Input
def inputProperty
@TaskAction
void execute(IncrementalTaskInputs inputs) {
logger.info inputs.incremental ? "CHANGED inputs considered out of date" : "ALL inputs considered out of date"
List filesChanged = []
inputs.outOfDate { change ->
filesChanged << change.file
}
GParsPool.withPool {
filesChanged.eachParallel { f ->
project.ibSignJar(f,outputDir)
}
}
inputs.removed { change ->
logger.info "removed: ${change.file.name}"
def targetFile = new File(outputDir, change.file.name)
targetFile.delete()
}
}
}
I would like jars that are no longer in the dependency list to be considered “removed” by the incremental task and deleted. I know if I use @InputDirectory this will happen, but that won’t work well since I’m getting the list of jars from the configuration instead of a directory… and of course the jars will be coming from different directories anyway since they are defined by the dependency system and cached somewhere on the local computer.
Is there a clean idiomatic Gradle way to do this?
Thanks!