Fork me on GitHub

The Maven Support Plugin

This was one of the first plugins that we (well Chris really) wrote. It addresses the following deficiencies within the gradle ecosystem.

  • Well defined POM files for all types of artifacts with classifiers and types
    • Name, description, organization, licenses, developers, year inception, packaging, dependencies (and exclusions), and test dependencies.
  • Javadocs and source jars, with variants support
  • Local maven publish of AARs, APKs, and everything else with variants

Later on, we added support for

  • Publishing with PGP signatures to maven central
  • Javadocs with doc-info and with graphviz uml diagram support
  • War, Zip, distribution and more support (with pom's)
  • Skip publish setting

How do I apply it

In your root build.gradle

allprojects  {
    project.group = ( project.hasProperty('pom.groupId')
            ? project.property('pom.groupId') : "" )
    project.version =
            ( project.hasProperty('pom.version') ? project.property('pom.version') : "1.0" )
    apply from: 'https://raw.githubusercontent.com/gradle-fury/gradle-fury/master/gradle/maven-support.gradle'
}

Sorry for the boiler plate, copy and paste code. Maybe one day we'll find a way to clean it up.

What else does it need (dependencies)?

gradle.properties, fill out all the pom details if publishing (both to maven local via the install task and to nexus via the publishArtifacts task.

optional

  • gpg
  • encryption plugin so you can store your password with some degree of assurance

What tasks and behavioral changes does the maven support plugin offer?

Tasks

install

Publishes to maven local for all artifacts with variants/flavors and distZip artifacts

publishArtifacts

Publishes to a remove nexus repo

Profiles

-Pprofile=javadoc

Generates javadocs for all projects, android and java, with optionally uml graphics and with support for doc-html folders.

-Pprofile=sources

Generates source jars for all projects, android and java.

Modules with application or distribution plugins

There's few special cases that we handle in order to generate valid pom files to be able to publish to both local maven and a remove maven repo. Long story short, if you used to run distZip, it's probably no longer necessary. Just run gradlew install