4

I am working on an Android SDK made of multiple library modules and a test app module:

mySDK
|-test-app
|-lib-core
|-lib-ui
|-...

I would like to publish it on a Maven repository, with all library modules embedded (but not the test-app).

I know how to publish a single library module using Maven Publish Plugin but can't figure out how to make a Maven publication containing multiple library modules.

How would you do that ?

sdabet
  • 18,360
  • 11
  • 89
  • 158

2 Answers2

2

Just upload each module as a standalone module.
It is not mandatory to upload all the modules at the same time, the dependencies are just described in the pom file.

It can be useful putting a base script in a single gradle file with some common settings and properties (you can read them from a gradle.properties file), something like:

rootFolder/maven_push.gradle:

apply plugin: 'maven'
//....

      pom.artifactId = POM_ARTIFACT_ID

      pom.project {
           name POM_NAME
           packaging POM_PACKAGING
           description POM_DESCRIPTION
           url POM_URL
           //...
      }

      //...

and then in each module/build.gradle file add:

apply from: '../maven_push.gradle'
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

Each module is a library by itself, so configure each one of them (besides the app) to be packaged as AAR files and deployed to the desired repo. If you are going to use the Maven publish plugin, just apply the steps to each module(to the module's build.gradle files). A good practice is to centralize the groupId and version values, perhaps in the gradle.properties file, or in the main gradle file. Same procedure applies to other plugins, like the android-gradle-maven plugin.

Fco P.
  • 2,486
  • 17
  • 20