Gradle Maven Publish Plugin: Difference between revisions
Line 10: | Line 10: | ||
=Overview= | =Overview= | ||
The concepts behind publishing with "maven-publish", and the publishing mechanics, are described in the [[#Concepts_and_Plugin_Mechanics|Concepts and Plugin Mechanics]] below. | The concepts behind publishing with "maven-publish", and the publishing mechanics, are described in the [[#Concepts_and_Plugin_Mechanics|Concepts and Plugin Mechanics]] below. A step by step procedure is available under the [[#Procedure|Procedure]] section. | ||
=Concepts and Plugin Mechanics= | =Concepts and Plugin Mechanics= |
Revision as of 21:28, 15 May 2018
External
Internal
Overview
The concepts behind publishing with "maven-publish", and the publishing mechanics, are described in the Concepts and Plugin Mechanics below. A step by step procedure is available under the Procedure section.
Concepts and Plugin Mechanics
Procedure
"maven-publish" is an newer alternative to publishing with Maven Plugin, which uses the a task of type "Upload" task. It generates Maven metadata and pushes the artifacts and the metadata to a Maven repository.
apply plugin: 'maven-publish'
"publishing" Extension
The plugin creates a "publishing" extension of type PublishingExtension. This extension provides a container of named publications and a container of named repositories.
publishing {
publications {
myPublicationName(MavenPublication) {
// Configure the publication here
}
}
}
repositories {
maven {
url "${url}"
authentication {
basic(BasicAuthentication)
}
}
}
Publications are published to repositories via tasks and the configuration of the publication object determines exactly what is published.
The plugin does not have effect if no MavenPublication is added to the publications container. A publication determines which artifacts are actually published as well as the details included in the associated POM file. A publication can be configured by adding components, customizing artifacts, and by modifying the generated POM file directly.
Publishing to a Maven Repository
Apply the Plugin
apply plugin: 'maven-publish'
Define the Publications
Define the Repository
Execute
gradle publish