Search code examples
androidandroid-gradle-pluginandroid-maven-plugin

Maven publication of multi-modules android library


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 ?


Solution

  • 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'