How to release multiple dependent android librarys with consistent versioning?

Given a multi module gradle project consisting of:

  • app
  • library A
  • library B
  • library C

Where

  • app has dependencies on A,B,C
  • B has dependencies on A
  • C has dependencies on A
  • A has no dependencies

How do you configure your dependencies to perform a maven release to a maven repository (i.e. uploadArchives) so that all artifacts (the app and libraries A,B and C) are released with the same version and dependent on the same version of the corresponding libraries?

For example:

To start with, the dependencies look like this

APP

compile project(':A')
compile project(':B')
compile project(':C')

B

compile project(':A')

C

compile project(':A')

This guarantees that when I build the project all libraries and app are compiled using the current codebase.

What I want to do is update one property in gradle.properties, and have all the artifacts released with that version, have dependencies on that version, and still be built using the current codebase (because the current codebase will be that version)

gradle.properties

PROJECT_VERSION=1.2.0

Ultimately I want the released versions to look like this:

APP

compile ('com.my.groupid:A:1.2.0')
compile ('com.my.groupid:B:1.2.0')
compile ('com.my.groupid:C:1.2.0')

B

compile ('com.my.groupid:A:1.2.0')

C

compile ('com.my.groupid:A:1.2.0')

What is the correct approach to achieving this?

Answers


You can use somenthing like this.

APP

compile project(':A')
compile project(':B')
compile project(':C')

B

compile project(':A')

C

compile project(':A')

In top-level build.gradle use:

ext{
    VERSION_NAME = 1.1.2
}

Then in your update script use:

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

                pom.groupId = GROUP
                pom.artifactId = POM_ARTIFACT_ID
                pom.version = rootProject.ext.VERSION_NAME

                //....other parts
            }
        }
    }
}

Define a task like:

task uploadAllArchives {
    description 'Upload all modules to Maven Repository'
    println ''
    println '---------------------------------'
    println 'Version: ' + version
    println 'UPLOAD ALL ARCHIVES'
    println '---------------------------------'
    println ''
    doLast{
        println ''
        println '---------------------------------'
        println 'Version: ' + version
        println 'UPLOAD ALL ARCHIVES FINISHED'
        println '---------------------------------'
        println ''
    }
}
uploadAllArchives.dependsOn(
        ':libraryA:uploadArchives',
        ':libraryB:uploadArchives',
        ':libraryC:uploadArchives')

Need Your Help

strings invalidated after parser finished, iphone

iphone nsxmlparser

I've parsed an xml and stored the parsed data on strings which are property declared, retained and synthesized, the values are getting into these strings during parsing, but are being invalidated a...

Java: Difference between the setPreferredSize() and setSize() methods in components

java swing jframe jpanel

Ok, I read the Java Documentation and I just can't figure out what is the main difference between those two methods. Sometimes I used setSize(), sometimes setPreferredSize(), sometimes one does wha...