java - How can I make uploadArchives dependent on another task? -
java - How can I make uploadArchives dependent on another task? -
i have next in 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 want dependent on next task:
task checkproperties << { if (!project.hasproperty('uploadusername')) { throw new runtimeexception("couldn't find uploadusername property. did forget specify in ~/.gradle/gradle.properties?") } else if (!project.hasproperty('uploadkeyfile')) { throw new runtimeexception("couldn't find uploadkeyfile property. did forget specify in ~/.gradle/gradle.properties?") } }
how can accomplish this? if write 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 next error:
failure: build failed exception. * where: build file '/users/scottjohnson/source/core-android/core/build.gradle' line: 61 * went wrong: problem occurred configuring project ':core'. > org.gradle.api.internal.missingmethodexception: not find method mavendeployer() arguments [build_42edqo477lbj5geoh0e3gdkj7q$_run_closure6_closure9_closure10_closure11@30b8afce] on repository container. * try: run --stacktrace alternative stack trace. run --info or --debug alternative more log output. build failed total time: 7.68 secs
btw, reason want right now, if set code checks properties uploadarchives
task, if run ./gradlew clean build
, checks properties (which don't want happen on build server, since doesn't have permission upload archives). thus, method check properties when uploadarchives
task executed acceptable.
i able figure out based in part on @opal's comment:
def checkproperties() { if (!project.hasproperty('uploadusername')) { throw new runtimeexception("couldn't find uploadusername property. did forget specify in ~/.gradle/gradle.properties?") } else if (!project.hasproperty('uploadkeyfile')) { throw new runtimeexception("couldn't find uploadkeyfile property. did forget specify in ~/.gradle/gradle.properties?") } } 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) { } } } } // need check create sure properties available before execute // uploadarchives. gradle.taskgraph.beforetask { task atask -> if (atask == uploadarchives) { checkproperties() atask.repositories.mavendeployer.repository(url: "scp://" + project.core_maven_url) { authentication(username: project.uploadusername, privatekey: project.uploadkeyfile) } } }
java android maven deployment gradle
Comments
Post a Comment