22

I'm building a large multi-module Android library, and need to publish the library to an internal company Artifactory.

Should I use the old maven plugin, or the new maven-publish plugin?

Note: The above two official plugins don't fully support Android, so there are two community ports.

Also interesting - the Android Tools team deprecated the experimental gradle plugin that was based around the SoftwareComponent model - which is what the maven-publish plugin uses. Is maven-publish deprecated too then?

ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107

1 Answers1

6

I would recommend you to use the new maven publish plugin. Gradle deprecated the old maven plugin with Gradle 1.3. According to this Gradle blog post only parts of the SoftwareComponent model will be marked as deprecated and the rest is going to be ported:

... You may therefore be wondering what is happening to the Software Model. We’re in the process of porting the configuration DSL of the native support to the current model. So the declarative nature and strong modelling language will be the same. The rule engine that was part of the Software Model will be deprecated. Everything under the model block will be ported as extensions to the current model ...

If you want an example for the maven-publish, Realm-Java uses it: https://github.com/realm/realm-java/blob/master/realm/realm-library/build.gradle

Philipp Hofmann
  • 3,388
  • 26
  • 32
  • Thanks for the explanations. Is this deprecated for technical reasons only or are there things that I can do with maven-publish that's not doable with maven ? – mbonnin Aug 16 '18 at 07:33
  • If you check the documentation here: https://docs.gradle.org/current/userguide/maven_plugin.html, it states, that maven-publish introduces some new concepts and features. For example a new feature is Publishing to Maven Local. – Philipp Hofmann Aug 16 '18 at 09:12
  • 1
    If by Maven Local, you mean ~/.m2, this is doable with the regular `maven` plugin. Just run `./gradlew install' – mbonnin Aug 17 '18 at 08:16
  • I'm not really sure what the real benefit of maven-publish is, but the gradle documentation states it is more powerful, has new features and is now the preferred way of publishing artefacts with maven. I would trust the documentation and use the new maven-publish. – Philipp Hofmann Aug 17 '18 at 08:27
  • 1
    That's the thing, I like to have specific claims. More than just the general "more powerful" thing. – mbonnin Aug 17 '18 at 08:33