api / org.gradle.api.artifacts.maven / MavenDeployer

MavenDeployer

interface MavenDeployer : MavenResolver

A resolver that can only be used for uploading artifacts to a Maven repository. If you use this resolver for getting dependencies from a Maven repository, an exception is thrown. This resolver support all aspects of Maven deployment, including snapshot deployment and metadata.xml manipulation.

You have to specify at least one repository. Otherwise, if there is only one artifact, usually there is not more to do. If there is more than one artifact you have to decide what to do about this, as a Maven POM can only deal with one artifact. There are two strategies. If you want to deploy only one artifact you have to specify a filter to select this artifact. If you want to deploy more than one artifact, you have to specify filters which select each artifact. Associated with each filter is a separate configurable POM.

You can create an instance of this type via the org.gradle.api.tasks.Upload#getRepositories() container

Functions

addProtocolProviderJars

abstract fun addProtocolProviderJars(jars: MutableCollection<File>): Unit

Out of the box only uploading to the filesysten and via http is supported. If other protocolls should be used, the appropriate Maven wagon jars have to be passed via this method.

getRepository

abstract fun getRepository(): Any

Returns the repository to be used for uploading artifacts.

getSnapshotRepository

abstract fun getSnapshotRepository(): Any

Returns the repository to be used for uploading snapshot artifacts.

isUniqueVersion

abstract fun isUniqueVersion(): Boolean

Returns whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time. Defaults to true.

setRepository

abstract fun setRepository(repository: Any): Unit

Sets the repository to be used for uploading artifacts. If #getSnapshotRepository() is not set, this repository is also used for uploading snapshot artifacts.

setSnapshotRepository

abstract fun setSnapshotRepository(snapshotRepository: Any): Unit

Sets the repository to be used for uploading snapshot artifacts. If this is not set, the #getRepository() is used for uploading snapshot artifacts.

setUniqueVersion

abstract fun setUniqueVersion(uniqueVersion: Boolean): Unit

Sets whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time. Defaults to true.

Inherited Functions

beforeDeployment

abstract fun beforeDeployment(action: Action<in MavenDeployment>): Unit

Adds an action to be executed immediately before a deployment to this resolver. The action is executed after all artifacts have been build, including generation of the POM. The action can modify the set of artifacts to be deployed.

abstract fun beforeDeployment(action: Closure<Any>): Unit

Adds a closure to be executed immediately before a deployment to this resolver. The closure is passed a as a parameter. The closure is executed after all artifacts have been build, including generation of the POM. The closure can modify the set of artifacts to be deployed.

getSettings

abstract fun getSettings(): Any

Returns a Maven settings object. This can be used for example to figure out where the local repository is located. This property is populated on demand.

Inheritors

GroovyMavenDeployer

interface GroovyMavenDeployer : MavenDeployer

Adds Groovy configuration convenience methods on top of the MavenDeployer. This class provides also a builder for repository and snapshot-repository:

 mavenUploader.repository(url: 'file://repoDir') { authentication(userName: 'myName') releases(updatePolicy: 'never') snapshots(updatePolicy: 'always') } 
This call set the repository object and also returns an instance of this object. If you use 'snapshotRepository' instead of repository, the snapshot repository is build.