In gradle, the install
task is introduced by the maven
plugin.
The publishToMavenLocal
task is introduced by the maven-publish
plugin.
The documentation of both tasks says they install/publish the module/artifacts to the local maven cache (.m2
directory).
If I need to publish a local project to my local maven cache, so that another local project can depend on it, which of the two tasks should I use?
The publishToMavenLocal is a built-in task of the maven-publish plugin of Gradle, and it will not publish anything into the remote Artifactory (JCenter / Maven) at all. Make sure mavenLocal() is in the first position of the list. Make sure you are using the correct version of your library.
What is Gradle? Gradle is a build automation tool known for its ability to create software. It is known to build automation on many programming languages like Scala, Java, Android, C/C++, and Groovy. The tool supports groovy based Domain Specific Language over XML.
Android Studio comes with a working installation of Gradle, so you don't need to install Gradle separately in that case. In order to create a new build or add a Wrapper to an existing build, you will need to install Gradle according to these instructions.
As far as I know, these two accomplish the same thing.
That said, I recommend using the maven-publish
plugin because:
java
plugin, which is useful if you ever build non-Java projectsYou can always write: task install(dependsOn: 'publishToMavenLocal')
if you like the task name install
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With