Maven Publication
A MavenPublication
is the representation/configuration of how Gradle should publish something in Maven format. You directly add a named Maven publication the project's publishing.publications
container by providing MavenPublication as the type.
publishing {
publications {
myPublicationName(MavenPublication) {
// Configure the publication here
}
}
}
groupId
-project.group
artifactId
-project.name
version
-project.version
For certain common use cases, it's often sufficient to specify the component to publish, and nothing more (from. The published component is used to determine which artifacts to publish, and which dependencies should be listed in the generated POM file.
To add additional artifacts to the set published, use the artifact and artifact methods. You can also completely replace the set of published artifacts using setArtifacts. Together, these methods give you full control over what artifacts will be published.
To customize the metadata published in the generated POM, set properties, e.g. getDescription, on the POM returned via the getPom method or directly by an action (or closure) passed into pom. As a last resort, it is possible to modify the generated POM using the withXml method.
// Example of publishing a Java module with a source artifact and a customized POM
plugins {
id 'java'
id 'maven-publish'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
}
publishing {
publications {
myPublication(MavenPublication) {
from components.java
artifact sourceJar
pom {
name = "Demo"
description = "A demonstration of Maven POM customization"
url = "http://www.example.com/project"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "johnd"
name = "John Doe"
email = "john.doe@example.com"
}
}
scm {
connection = "scm:svn:http://subversion.example.com/svn/project/trunk/"
developerConnection = "scm:svn:https://subversion.example.com/svn/project/trunk/"
url = "http://subversion.example.com/svn/project/trunk/"
}
}
}
}
}
Since
1.4