Package org.apache.maven.plugin.install
Class InstallFileMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugin.install.AbstractInstallMojo
org.apache.maven.plugin.install.InstallFileMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="install-file",
requiresProject=false,
aggregator=true,
threadSafe=true)
public class InstallFileMojo
extends AbstractInstallMojo
Installs a file in the local repository.
- Version:
- $Id: InstallFileMojo.java 1617120 2014-08-10 15:15:48Z khmarbaise $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringArtifactId of the artifact to be installed.protected StringClassifier type of the artifact to be installed.private FileThe file to be installed in the local repository.private BooleanGenerate a minimal POM for the artifact if none is supplied via the parameterpomFile.protected StringGroupId of the artifact to be installed.private FileThe bundled API docs for the artifact.private FileThe path for a specific local repository directory.private org.apache.maven.project.validation.ModelValidatorThe component used to validate the user-supplied artifact coordinates.protected StringPackaging type of the artifact to be installed.private FileLocation of an existing POM file to be installed alongside the main artifact, given by thefileparameter.private StringThe type of remote repository layout to install to.Map that contains the repository layouts.private FileThe bundled sources for the artifact.protected StringVersion of the artifact to be installed.Fields inherited from class org.apache.maven.plugin.install.AbstractInstallMojo
artifactFactory, createChecksum, digester, installer, localRepository, updateReleaseInfoFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()private org.apache.maven.model.ModelGenerates a minimal model from the user-supplied artifact information.private FileGenerates a (temporary) POM file from the plugin configuration.private voidprocessModel(org.apache.maven.model.Model model) Populates missing mojo parameters from the specified POM.private org.apache.maven.model.ModelParses a POM.private org.apache.maven.model.ModelreadModel(InputStream pomFile) Parses a POM.voidsetLocalRepositoryPath(File theLocalRepositoryPath) private voidValidates the user-supplied artifact information.Methods inherited from class org.apache.maven.plugin.install.AbstractInstallMojo
addMetaDataFilesForArtifact, getLocalRepoFile, getLocalRepoFile, installChecksums, installChecksumsMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
groupId
GroupId of the artifact to be installed. Retrieved from POM file if one is specified or extracted frompom.xmlin jar if available. -
artifactId
ArtifactId of the artifact to be installed. Retrieved from POM file if one is specified or extracted frompom.xmlin jar if available. -
version
Version of the artifact to be installed. Retrieved from POM file if one is specified or extracted frompom.xmlin jar if available. -
packaging
Packaging type of the artifact to be installed. Retrieved from POM file if one is specified or extracted frompom.xmlin jar if available. -
classifier
Classifier type of the artifact to be installed. For example, "sources" or "javadoc". Defaults to none which means this is the project's main artifact.- Since:
- 2.2
-
file
The file to be installed in the local repository. -
javadoc
The bundled API docs for the artifact.- Since:
- 2.3
-
sources
The bundled sources for the artifact.- Since:
- 2.3
-
pomFile
Location of an existing POM file to be installed alongside the main artifact, given by thefileparameter.- Since:
- 2.1
-
generatePom
Generate a minimal POM for the artifact if none is supplied via the parameterpomFile. Defaults totrueif there is no existing POM in the local repository yet.- Since:
- 2.1
-
repositoryLayout
@Parameter(property="repositoryLayout", defaultValue="default", required=true) private String repositoryLayoutThe type of remote repository layout to install to. Trylegacyfor a Maven 1.x-style repository layout.- Since:
- 2.2
-
repositoryLayouts
@Component(role=org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout.class) private Map<String,org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout> repositoryLayoutsMap that contains the repository layouts. -
localRepositoryPath
The path for a specific local repository directory. If not specified the local repository path configured in the Maven settings will be used.- Since:
- 2.2
-
modelValidator
@Component private org.apache.maven.project.validation.ModelValidator modelValidatorThe component used to validate the user-supplied artifact coordinates.
-
-
Constructor Details
-
InstallFileMojo
public InstallFileMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException- See Also:
-
readModel
private org.apache.maven.model.Model readModel(File pomFile) throws org.apache.maven.plugin.MojoExecutionException Parses a POM.- 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 POM could not be parsed.
-
readModel
private org.apache.maven.model.Model readModel(InputStream pomFile) throws org.apache.maven.plugin.MojoExecutionException Parses a POM.- 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 POM could not be parsed.
-
processModel
private void processModel(org.apache.maven.model.Model model) Populates missing mojo parameters from the specified POM.- Parameters:
model- The POM to extract missing artifact coordinates from, must not benull.
-
validateArtifactInformation
private void validateArtifactInformation() throws org.apache.maven.plugin.MojoExecutionExceptionValidates the user-supplied artifact information.- Throws:
org.apache.maven.plugin.MojoExecutionException- 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.
-
generatePomFile
Generates a (temporary) POM file from the plugin configuration. It's the responsibility of the caller to delete the generated file when no longer needed.- Returns:
- The path to the generated POM file, never
null. - Throws:
org.apache.maven.plugin.MojoExecutionException- If the POM file could not be generated.
-
getLocalRepositoryPath
- Returns:
- the localRepositoryPath
-
setLocalRepositoryPath
- Parameters:
theLocalRepositoryPath- the localRepositoryPath to set
-