Class MvnPublisher
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
A Generator for Maven deployments in response to requests for
MvnPublication or MvnInstallation. It supports publishing
releases using the
Publish Portal API
and publishing snapshots (and local installations) using the
"traditional" Maven approach (uploading the files individually,
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 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.
Except for local installs, the publisher requires at least one
MvnPublishingDestination to publish to. If none is set, the
publisher adds an instance of PortalPublisherDestination for releases
and an instance of MvnDeployDestination with id "central"
for snapshots.
-
Constructor Summary
ConstructorsConstructorDescriptionMvnPublisher(Project project) Initializes a new Maven publication generator. -
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.destination(String id, URI uri, MvnVersionType... types) Create and add aMvnPublishingDestinationfrom the given arguments.destinations(MvnPublishingDestination... destinations) Adds the given publishing destinations.protected <T extends Resource>
Collection<T> doProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Keep generated sub artifacts (checksums, signatures).Use the provided information to sign the artifacts.Methods inherited from class AbstractGenerator
cleanup, name, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
context, name, of, resources
-
Constructor Details
-
MvnPublisher
Initializes a new Maven publication generator.- Parameters:
project- the project
-
-
Method Details
-
destinations
Adds the given publishing destinations.- Parameters:
destinations- the destinations- Returns:
- the Maven publisher
-
destination
Create and add aMvnPublishingDestinationfrom the given arguments.- Parameters:
id- the id. May be used to lookup credentials, seeMvnPublishingDestinationuri- the locationtypes- the supported version types- Returns:
- the Maven publisher
-
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
-
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 byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
requested- the request for resources- Returns:
- the stream
-