Package org.apache.maven.plugin.gpg
Class SignAndDeployFileMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.gpg.AbstractGpgMojo
-
- org.apache.maven.plugin.gpg.SignAndDeployFileMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="sign-and-deploy-file", requiresProject=false, threadSafe=true) public class SignAndDeployFileMojo extends AbstractGpgMojo
Signs artifacts and installs the artifact in the remote repository.- Since:
- 1.0-beta-4
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.artifact.factory.ArtifactFactory
artifactFactory
Component used to create an artifactprivate java.lang.String
artifactId
ArtifactId of the artifact to be deployed.private java.io.File
ascDirectory
The directory where to store signature files.private java.lang.String
classifier
Add classifier to the artifactprivate java.lang.String
classifiers
A comma separated list of classifiers for each of the extra side artifacts to deploy.private org.apache.maven.artifact.deployer.ArtifactDeployer
deployer
private java.lang.String
description
Description passed to a generated POM file (in case of generatePom=true).private java.io.File
file
File to be deployed.private java.lang.String
files
A comma separated list of files for each of the extra side artifacts to deploy.private boolean
generatePom
Upload a POM for this artifact.private java.lang.String
groupId
GroupId of the artifact to be deployed.private java.io.File
javadoc
The bundled API docs for the artifact.private org.apache.maven.artifact.repository.ArtifactRepository
localRepository
private org.apache.maven.project.validation.ModelValidator
modelValidator
The component used to validate the user-supplied artifact coordinates.private boolean
offline
Flag whether Maven is currently in online/offline mode.private java.lang.String
packaging
Type of the artifact to be deployed.private java.io.File
pomFile
Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.private org.apache.maven.project.MavenProject
project
The default Maven project created when building the pluginprivate org.apache.maven.project.MavenProjectHelper
projectHelper
Used for attaching the source and javadoc jars to the project.private org.apache.maven.artifact.repository.ArtifactRepositoryFactory
repositoryFactory
Component used to create a repositoryprivate java.lang.String
repositoryId
Server Id to map on the <id> under <server> section ofsettings.xml
.private java.lang.String
repositoryLayout
The type of remote repository layout to deploy to.private java.util.Map
repositoryLayouts
Map that contains the layouts.private int
retryFailedDeploymentCount
Parameter used to control how many times a failed deployment will be retried before giving up and failing.private java.io.File
sources
The bundled sources for the artifact.private java.lang.String
types
A comma separated list of types for each of the extra side artifacts to deploy.private boolean
uniqueVersion
Whether to deploy snapshots with a unique version or not.protected boolean
updateReleaseInfo
Parameter used to update the metadata to make the artifact as release.private java.lang.String
url
URL where the artifact will be deployed.private java.lang.String
version
Version of the artifact to be deployed.
-
Constructor Summary
Constructors Constructor Description SignAndDeployFileMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
deploy(java.io.File source, org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository deploymentRepository, org.apache.maven.artifact.repository.ArtifactRepository localRepository)
Deploy an artifact from a particular file.void
execute()
private org.apache.maven.model.Model
generateModel()
Generates a minimal model from the user-supplied artifact information.private java.io.File
generatePomFile()
Generates a minimal POM from the user-supplied artifact information.private java.io.File
getLocalRepoFile(org.apache.maven.artifact.Artifact artifact)
Gets the path of the specified artifact within the local repository.private void
initProperties()
private void
processModel(org.apache.maven.model.Model model)
Process the supplied pomFile to get groupId, artifactId, version, and packagingprivate org.apache.maven.model.Model
readModel(java.io.File pomFile)
Extract the model from the specified POM file.private void
validateArtifactInformation()
Validates the user-supplied artifact information.-
Methods inherited from class org.apache.maven.plugin.gpg.AbstractGpgMojo
newSigner
-
-
-
-
Field Detail
-
ascDirectory
@Parameter(property="gpg.ascDirectory") private java.io.File ascDirectory
The directory where to store signature files.
-
offline
@Parameter(defaultValue="${settings.offline}", readonly=true) private boolean offline
Flag whether Maven is currently in online/offline mode.
-
groupId
@Parameter(property="groupId") private java.lang.String groupId
GroupId of the artifact to be deployed. Retrieved from POM file if specified.
-
artifactId
@Parameter(property="artifactId") private java.lang.String artifactId
ArtifactId of the artifact to be deployed. Retrieved from POM file if specified.
-
version
@Parameter(property="version") private java.lang.String version
Version of the artifact to be deployed. Retrieved from POM file if specified.
-
packaging
@Parameter(property="packaging") private java.lang.String packaging
Type of the artifact to be deployed. Retrieved from POM file if specified. Defaults to file extension if not specified via command line or POM.
-
classifier
@Parameter(property="classifier") private java.lang.String classifier
Add classifier to the artifact
-
description
@Parameter(property="generatePom.description") private java.lang.String description
Description passed to a generated POM file (in case of generatePom=true).
-
file
@Parameter(property="file", required=true) private java.io.File file
File to be deployed.
-
pomFile
@Parameter(property="pomFile") private java.io.File pomFile
Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter.
-
generatePom
@Parameter(property="generatePom", defaultValue="true") private boolean generatePom
Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument.
-
uniqueVersion
@Parameter(property="uniqueVersion", defaultValue="true") private boolean uniqueVersion
Whether to deploy snapshots with a unique version or not.
-
url
@Parameter(property="url", required=true) private java.lang.String url
URL where the artifact will be deployed.
ie ( file:///C:/m2-repo or scp://host.com/path/to/repo )
-
repositoryId
@Parameter(property="repositoryId", defaultValue="remote-repository", required=true) private java.lang.String repositoryId
Server Id to map on the <id> under <server> section ofsettings.xml
. In most cases, this parameter will be required for authentication.
-
repositoryLayout
@Parameter(property="repositoryLayout", defaultValue="default") private java.lang.String repositoryLayout
The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout.
-
deployer
@Component private org.apache.maven.artifact.deployer.ArtifactDeployer deployer
-
localRepository
@Parameter(defaultValue="${localRepository}", required=true, readonly=true) private org.apache.maven.artifact.repository.ArtifactRepository localRepository
-
repositoryLayouts
@Component(role=org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout.class) private java.util.Map repositoryLayouts
Map that contains the layouts.
-
artifactFactory
@Component private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
Component used to create an artifact
-
repositoryFactory
@Component private org.apache.maven.artifact.repository.ArtifactRepositoryFactory repositoryFactory
Component used to create a repository
-
modelValidator
@Component private org.apache.maven.project.validation.ModelValidator modelValidator
The component used to validate the user-supplied artifact coordinates.
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
The default Maven project created when building the plugin- Since:
- 1.3
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
Used for attaching the source and javadoc jars to the project.- Since:
- 1.3
-
javadoc
@Parameter(property="javadoc") private java.io.File javadoc
The bundled API docs for the artifact.- Since:
- 1.3
-
sources
@Parameter(property="sources") private java.io.File sources
The bundled sources for the artifact.- Since:
- 1.3
-
retryFailedDeploymentCount
@Parameter(property="retryFailedDeploymentCount", defaultValue="1") private int retryFailedDeploymentCount
Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.- Since:
- 1.3
-
updateReleaseInfo
@Parameter(property="updateReleaseInfo", defaultValue="false") protected boolean updateReleaseInfo
Parameter used to update the metadata to make the artifact as release.- Since:
- 1.3
-
types
@Parameter(property="types") private java.lang.String types
A comma separated list of types for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries infiles
orclassifiers
, then an error will be raised.
-
classifiers
@Parameter(property="classifiers") private java.lang.String classifiers
-
files
@Parameter(property="files") private java.lang.String files
A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in the number of entries intypes
orclassifiers
, then an error will be raised.
-
-
Method Detail
-
initProperties
private void initProperties() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
getLocalRepoFile
private java.io.File getLocalRepoFile(org.apache.maven.artifact.Artifact artifact)
Gets the path of the specified artifact within the local repository. Note that the returned path need not exist (yet).- Parameters:
artifact
- The artifact whose local repo path should be determined, must not benull
.- Returns:
- The absolute path to the artifact when installed, never
null
.
-
processModel
private void processModel(org.apache.maven.model.Model model)
Process the supplied pomFile to get groupId, artifactId, version, and packaging- Parameters:
model
- The POM to extract missing artifact coordinates from, must not benull
.
-
readModel
private org.apache.maven.model.Model readModel(java.io.File pomFile) throws org.apache.maven.plugin.MojoExecutionException
Extract the model from the specified POM file.- Parameters:
pomFile
- The path of the POM file to parse, must not benull
.- Returns:
- The model from the POM file, never
null
. - Throws:
org.apache.maven.plugin.MojoExecutionException
- If the file doesn't exist of cannot be read.
-
generatePomFile
private java.io.File generatePomFile() throws org.apache.maven.plugin.MojoExecutionException
Generates a minimal POM from the user-supplied artifact information.- Returns:
- The path to the generated POM file, never
null
. - Throws:
org.apache.maven.plugin.MojoExecutionException
- If the generation failed.
-
validateArtifactInformation
private void validateArtifactInformation() throws org.apache.maven.plugin.MojoFailureException
Validates the user-supplied artifact information.- Throws:
org.apache.maven.plugin.MojoFailureException
- If any artifact coordinate is invalid.
-
generateModel
private org.apache.maven.model.Model generateModel()
Generates a minimal model from the user-supplied artifact information.- Returns:
- The generated model, never
null
.
-
deploy
protected void deploy(java.io.File source, org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository deploymentRepository, org.apache.maven.artifact.repository.ArtifactRepository localRepository) throws org.apache.maven.artifact.deployer.ArtifactDeploymentException
Deploy an artifact from a particular file.- Parameters:
source
- the file to deployartifact
- the artifact definitiondeploymentRepository
- the repository to deploy tolocalRepository
- the local repository to install into- Throws:
org.apache.maven.artifact.deployer.ArtifactDeploymentException
- if an error occurred deploying the artifact
-
-