Class MvnPublisher
- All Implemented Interfaces:
Generator, ResourceProvider
A Generator for maven deployments in response to requests for
MvnPublication It supports publishing releases using the
Publish Portal API
and publishing snapshots using the "traditional" maven approach
(uploading the files, including the appropriate maven-metadata.xml
files).
The publisher requests the PomFile from the project and uses
the groupId, artfactId and version as specified in this file.
It also requests the LibraryJarFile, the SourcesJarFile and
the JavadocJarFile. The latter two are optional for snapshot
releases.
Publishing requires credentials for the maven repository and a PGP/GPG secret key for signing the artifacts. They can be set by the respective methods. However, it is assumed that the credentials are usually made available as properties in the build context.
-
Field Summary
Fields inherited from class AbstractProvider
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the directory where additional artifacts are created.artifactDirectory(Path directory) Sets the directory where additional artifacts are created.artifactDirectory(Supplier<Path> directory) Sets the directory where additional artifacts are created.credentials(String user, String pass) Sets the Maven repository credentials.doProvide(ResourceRequest<T> requested) Invoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.Keep generated sub artifacts (checksums, signatures).Publish the release automatically.Use the provided information to sign the artifacts.Returns the snapshot repository.snapshotRepository(URI uri) Sets the Maven snapshot repository URI.Returns the upload URI.Sets the upload URI.Methods inherited from class AbstractGenerator
cleanup, name, name, newResource, project, toStringMethods inherited from class AbstractProvider
provideMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
provide
-
Constructor Details
-
MvnPublisher
Creates a new Maven publication generator.- Parameters:
project- the project
-
-
Method Details
-
uploadUri
Sets the upload URI.- Parameters:
uri- the repository URI- Returns:
- the maven publication generator
-
uploadUri
-
snapshotRepository
Sets the Maven snapshot repository URI.- Parameters:
uri- the snapshot repository URI- Returns:
- the maven publication generator
-
snapshotRepository
Returns the snapshot repository. Defaults tohttps://central.sonatype.com/repository/maven-snapshots/.- Returns:
- the uri
-
credentials
Sets the Maven repository credentials. If not specified, the publisher looks for propertiesmvnrepo.userandmvnrepo.passwordin the properties provided by theBuildContext.- Parameters:
user- the usernamepass- the password- Returns:
- the maven publication generator
-
signWith
Use the provided information to sign the artifacts. If no information is specified, the publisher will use the
BuildContextto look up the propertiessigning.secretKeyRingFile,signing.secretKeyandsigning.password.The publisher retrieves the secret key from the key ring using the key ID. While this method makes signing in CI/CD pipelines more complex, it is considered best practice.
- Parameters:
secretKeyRing- the secret key ringkeyId- the key idpassword- the password- Returns:
- the mvn publisher
-
keepSubArtifacts
Keep generated sub artifacts (checksums, signatures).- Returns:
- the mvn publication generator
-
publishAutomatically
Publish the release automatically.- Returns:
- the mvn publisher
-
artifactDirectory
Returns the directory where additional artifacts are created. Defaults to sub directorypublications/mavenin the project's build directory (seeProject.buildDirectory()).- Returns:
- the directory
-
artifactDirectory
Sets the directory where additional artifacts are created. ThePathis resolved against the project's build directory (seeProject.buildDirectory()). Ifdestinationisnull, the additional artifacts are created in the directory where the base artifact is found.- Parameters:
directory- the new directory- Returns:
- the maven publication generator
-
artifactDirectory
Sets the directory where additional artifacts are created. If theSupplierreturnsnull, the additional artifacts are created in the directory where the base artifact is found.- Parameters:
directory- the new directory- Returns:
- the maven publication generator
-
doProvide
Description copied from class:AbstractProviderInvoked byAbstractProvider.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the requested- Returns:
- the stream
-