Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between gradle install and gradle publishToMavenLocal?

Tags:

gradle

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?

like image 617
Doron Gold Avatar asked Nov 15 '15 12:11

Doron Gold


People also ask

What does Gradle publishToMavenLocal do?

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 install command?

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.

Do I need to install Gradle?

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.


1 Answers

As far as I know, these two accomplish the same thing.

That said, I recommend using the maven-publish plugin because:

  • It's newer and has a nicer publishing DSL, see the Maven Publish Plugin page for more details
  • It doesn't explicitly depend on the java plugin, which is useful if you ever build non-Java projects

You can always write: task install(dependsOn: 'publishToMavenLocal') if you like the task name install.

like image 70
Eric Wendelin Avatar answered Oct 17 '22 13:10

Eric Wendelin