Class InstallFileMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.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 org.apache.maven.plugin.AbstractMojo
Installs a file in the local repository.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringArtifactId of the artifact to be installed.private StringClassifier type of the artifact to be installed.private StringExtension 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.private StringGroupId of the artifact to be installed.private static final Stringprivate FileThe bundled API docs for the artifact.private FileThe path for a specific local repository directory.private final org.slf4j.Loggerprivate static final Stringprivate StringPackaging type of the artifact to be installed.private static final Patternprivate FileLocation of an existing POM file to be installed alongside the main artifact, given by thefileparameter.private org.eclipse.aether.RepositorySystemprivate org.apache.maven.execution.MavenSessionprivate FileThe bundled sources for the artifact.private StringVersion of the artifact to be installed.Fields 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 FilegetLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact) Gets the path of the specified artifact within the local repository.private FilegetPomLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact) Gets the path of the specified artifact POM within the local repository.private booleanReturnstrueif passed in string is "valid Maven ID" (groupId or artifactId).private booleanisValidVersion(String version) Returnstrueif passed in string is "valid Maven (simple.private voidprocessModel(org.apache.maven.model.Model model) Populates missing mojo parameters from the specified POM.private Fileprivate org.apache.maven.model.ModelParses a POM.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
LS
-
log
private final org.slf4j.Logger log -
repositorySystem
@Component private org.eclipse.aether.RepositorySystem repositorySystem -
session
@Parameter(defaultValue="${session}", required=true, readonly=true) private org.apache.maven.execution.MavenSession session -
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
-
extension
Extension of the artifact to be installed. If set, will override plugin own logic to detect extension. If not set, as Maven expected, packaging determines the artifact extension.- Since:
- 3.1.3
-
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
-
generatePom
-
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
-
IS_EMPTY
-
IS_POM_PACKAGING
-
POM_ENTRY_PATTERN
-
IS_POM_ENTRY
-
ILLEGAL_VERSION_CHARS
- See Also:
-
-
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
-
readingPomFromJarFile
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
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.
-
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.
-
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.
-
getLocalRepositoryFile
private File getLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact) Gets the path of the specified artifact within the local repository. Note that the returned path need not exist (yet). -
getPomLocalRepositoryFile
private File getPomLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact) Gets the path of the specified artifact POM within the local repository. Note that the returned path need not exist (yet). -
isValidId
Returnstrueif passed in string is "valid Maven ID" (groupId or artifactId). -
isValidVersion
Returnstrueif passed in string is "valid Maven (simple. non range, expression, etc) version".
-