I have a gradle file that produces a number of jars and I want to add the archives in a loop.
running gradle clean build works fine if I have
signing {
required { isReleaseVersion }
sign configurations.archives
}
artifacts {
archives puzzleJar
archives adventureJar
archives hiqJar
archives mazeJar
archives redpuzzleJar
archives sudokuJar
archives tantrixJar
:
}
but if I change the artifacts declaration to
def jarTasks = ["puzzleJar", "adventureJar", "hiqJar", "mazeJar", "redpuzzleJar", "sudokuJar",..., "tantrixJar"]
artifacts {
jarTasks.each{ taskName ->
def artifactName = 'bb4-' + (taskName - 'Jar') + "-$version"
archives new DefaultPublishArtifact(
artifactName, "jar", "jar", null, new Date(),
new File("$buildDir/libs", "${artifactName}.jar"))
}
}
then ‘gradle clean build’ gives Execution failed for task ‘:signArchives’. > E:\projects\java_projects\bb4-puzzles\build\libs\bb4-puzzle-1.1.2-SNAPSHOT.jar (The system cannot find the file specified)
gradle build does work if the jar files are already there. It looks like the signing plugin implicitly adds the signArchives task. My hunch is that the closure that adds the archives runs after the signing configuration, but I don’t know why - or how to get it to run first.
My full gradle file is https://raw.github.com/barrybecker4/bb4-puzzles/master/build.gradle note that it imports my common gradle build file https://raw.github.com/barrybecker4/bb4-common/master/bb4.gradle
I am using gradle 1.6.