MavenPublication

API Documentation:MavenPublication

Note: This class is incubating and may change in a future version of Gradle.

A MavenPublication is the representation/configuration of how Gradle should publish something in Maven format. The "maven-publish" plugin creates one MavenPublication named "maven" in the project's publishing.publications container. This publication is configured to publish all of the project's visible configurations (i.e. Project.getConfigurations()).

The Maven POM identifying attributes are mapped as follows:

  • groupId - project.group
  • artifactId - project.name
  • version - project.version

The ability to add multiple publications and finely configure publications will be added in future Gradle versions.

Customising the publication prior to publishing

It is possible to modify the generated POM prior to publication. This is done using the MavenPom.withXml() method of the POM returned via the MavenPublication.getPom() method, or directly by an action (or closure) passed into MavenPublication.pom().

Properties

PropertyDescription
pom
Incubating

The POM that will be published.

Property details

MavenPom pom (read-only)

Note: This property is incubating and may change in a future version of Gradle.

The POM that will be published.

Script blocks

No script blocks

Methods

MethodDescription
pom(configure)
Incubating

Configures the POM that will be published. The supplied action will be executed against the MavenPublication.getPom() result. This method also accepts a closure argument, by type coercion.

Method details

void pom(Action<? super MavenPom> configure)

Note: This method is incubating and may change in a future version of Gradle.

Configures the POM that will be published. The supplied action will be executed against the MavenPublication.getPom() result. This method also accepts a closure argument, by type coercion.