I have the following in my build.gradle
:
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
pom.packaging = "aar"
pom.groupId = project.CORE_GROUP
pom.version = project.CORE_VERSION_NAME
repository(url: "scp://" + project.CORE_MAVEN_URL) {
authentication(userName: project.uploadUsername, privateKey: project.uploadKeyFile)
}
}
}
}
}
And I want it to be dependent on the following task:
task checkProperties << {
if (!project.hasProperty('uploadUsername')) {
throw new RuntimeException("Couldn't find uploadUsername property. Did you forget to specify it in ~/.gradle/gradle.properties?")
} else if (!project.hasProperty('uploadKeyFile')) {
throw new RuntimeException("Couldn't find uploadKeyFile property. Did you forget to specify it in ~/.gradle/gradle.properties?")
}
}
How can I achieve this? If I write the following:
afterEvaluate { project ->
uploadArchives(dependsOn: checkProperties) {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
pom.packaging = "aar"
pom.groupId = project.CORE_GROUP
pom.version = project.CORE_VERSION_NAME
repository(url: "scp://" + project.CORE_MAVEN_URL) {
authentication(userName: project.uploadUsername, privateKey: project.uploadKeyFile)
}
}
}
}
}
Then I get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/scottjohnson/Source/core-android/core/build.gradle' line: 61
* What went wrong:
A problem occurred configuring project ':core'.
> org.gradle.api.internal.MissingMethodException: Could not find method mavenDeployer() for arguments [build_42edqo477lbj5geoh0e3gdkj7q$_run_closure6_closure9_closure10_closure11@30b8afce] on repository container.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.68 secs
BTW, the reason I want to do this is that right now, if I just put the code that checks the properties into the uploadArchives
task, then even if I run ./gradlew clean build
, it checks the properties (which I don't want to happen on my build server, since it doesn't have permission to actually upload the archives). Thus, a method that would check the properties only when the uploadArchives
task is executed would also be acceptable.