I have gradle build script for a multi module project.
For better readability I'd like to extract some methods, but when I do the script fails with an exception:
Cannot add task ':signArchives' as a task with that name already exists.
Full reproducable example: Have an otherwise empty directory, with two files in it:
settings.gradle
include 'eins', 'zwei'
build.gradle
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
allprojects {
apply plugin: 'signing'
}
subprojects {
signing {
sign configurations.archives
}
}
private Object signIt() {
signing {
sign configurations.archives
}
}
In that directory execute the following:
gradle wrapper
gradlew tasks
You'll get a list of available tasks as a result.
Change the build.gradle file to the following
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
allprojects {
apply plugin: 'signing'
}
subprojects {
signIt()
}
private Object signIt() {
signing {
sign configurations.archives
}
}
execute again:
gradlew tasks
Now you (or at least I) get:
> Cannot add task ':signArchives' as a task with that name already exists.