1

I would like to publish my android library to maven repo ( for now only local repository) so i use maven-publish plugin and use terminal gradle publishToMavenLocal command to do that.

Is there any possibility to add that command to build.gradle so the publishing task will trigger always on build?

And the second question, is there any possibility to add dependency to pom file automatically from aar , because gradle dont do that by default, for now I'm using solution found here Gradle not including dependencies in published pom.xml.

Cheers Wojtek

1 Answer 1

3

Is there any possibility to add that command to build.gradle so the publishing task will trigger always on build?

Yes, it is possible. If you know the name of the build task, which have to trigger a publishing, you can use the finalizedBy property of the task, you can read about it here, like:

someBuildTask.finalizedBy publishToMavenLocal

In this case, task publishToMavenLocal will be always triggered after the someBuildTask. But you have to know, it will be triggered, even if build task fails, so it may need some additional configuration to skip it's execution if build task was failed.

But, IMO, it's preffered to make it other way, I mean, make a publishing dependent from build tasks and call not a build, but publishing task instead. In that case, you will be able to call a build with and without artifacts publishing.

1
  • FYI for anyone looking to use this, it is not the same as running the install task. The POM created will not have any dependencies in it.
    – Don Rhummy
    Dec 29, 2017 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.