Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Libraries: maven vs maven-publish gradle project

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.

  • unofficial maven plugin
  • unofficial maven-publish plugin

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?

like image 306
ZakTaccardi Avatar asked Jan 26 '18 20:01

ZakTaccardi


People also ask

Does Android use Maven or Gradle?

Google chose Gradle as the official build tool for Android; not because build scripts are code, but because Gradle is modeled in a way that is extensible in the most fundamental ways. Gradle's model also allows it to be used for native development with C/C++ and can be expanded to cover any ecosystem.

What does Maven publish do?

The Maven Publish Plugin provides the ability to publish build artifacts to an Apache Maven repository. A module published to a Maven repository can be consumed by Maven, Gradle (see Declaring Dependencies) and other tools that understand the Maven repository format.

What is publishing in build Gradle?

Gradle automatically generates publishing tasks for all possible combinations of publication and repository, allowing you to publish any artifact to any repository.


1 Answers

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

like image 51
Philipp Hofmann Avatar answered Oct 20 '22 10:10

Philipp Hofmann