Class UnpackPluginMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.dependency.AbstractDependencyMojo
org.apache.maven.plugins.dependency.fromConfiguration.AbstractFromConfigurationMojo
org.apache.maven.plugins.dependency.fromConfiguration.UnpackMojo
de.iip_ecosphere.platform.tools.maven.dependencies.CleaningUnpackMojo
de.iip_ecosphere.platform.tools.maven.dependencies.UnpackPluginMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="unpack-plugins",
defaultPhase=TEST_COMPILE,
requiresProject=false,
threadSafe=true,
requiresDependencyResolution=RUNTIME,
requiresDependencyCollection=RUNTIME)
public class UnpackPluginMojo
extends CleaningUnpackMojo
Extended unpack Mojo for plugins.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classStores classpath file names with additional information for moving in the file system.static classRepresents a plugin, an extended artifact.private classUsed for relocating classpath files, i.e., to rename them with their plugin short (artifactId) name.private static classRepresents an OS-customized tokenizer. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate List<UnpackPluginMojo.ClasspathFile> private booleanprivate static final Stringprivate List<UnpackPluginMojo.PluginItem> private booleanprivate Fileprivate List<org.apache.maven.artifact.repository.ArtifactRepository> private List<org.eclipse.aether.repository.RemoteRepository> private org.eclipse.aether.RepositorySystemSessionprivate org.eclipse.aether.RepositorySystemprivate booleanprivate Stringprivate Resolverprivate org.apache.maven.execution.MavenSessionprivate Fileprivate Stringprivate booleanFields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
outputAbsoluteArtifactFilename, reactorProjectsFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate static StringextractSuffix(String prefix, String line, String dflt) Extracts the suffix after removing the prefix.private intfindArtifactId(String name) Returns the position of the "." after the groupId inname.private StringfixPrefix(String prefix, UnpackPluginMojo.Tokenizer tokenizer) Fixes the prefix by appending a path separator if needed.private StringReturns the actual (overridden) version of the given plugin item.private FileReturns the path to a (more qualified) classpath file based on the output directory for a plugin/classpath file name.private FilegetOutputDir(String name) Returns the output directory for a plugin/classpath file name.private voidHandles the appends.private voidHandles appends, if specified, by passing elements that are not yet inknownTokenstohandler.private voidHandles explicit setup descriptors by rewriting the classpath files.private booleanisModeResolve(String mode) Returns whether we are in resolve mode, i.e., eithermodeindicates "resolve" orforceResolve.private voidmergeFiles(File src, File tgt) Merges files fromsrcintotgtby only copying those that do not already exist.org.apache.maven.project.ProjectBuildingRequestprivate org.eclipse.aether.artifact.DefaultArtifactParses a classpath path back into a maven artifact.private voidprocessCpLineNoRelocation(String name, String mode, String line, PrintStream out, UnpackPluginMojo.Tokenizer tokenizer, String prefix) Processes a classpath line without plugin relocation.private voidprocessCpLineRelocation(String name, String mode, PrintStream out, UnpackPluginMojo.Tokenizer tokenizer, String prefix, File jarFolder) Processes a classpath line while plugin relocation.private voidrelocate()Relocates the unpacked files.private StringTries to resolve the path.private StringrewriteToken(String token, String mode, String prefix, File jarFolder, UnpackPluginMojo.Tokenizer tokenizer) Rewrites a classpath token.private voidStores the resolved dependencies if enabled.private StringstripPrefix(String prefix, String cpToken) Strips a prefix from a classpath token.private org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItemTurns aUnpackPluginMojo.PluginItemto a pre-configuredArtifactItempassed on for resolution/download.Methods inherited from class de.iip_ecosphere.platform.tools.maven.dependencies.CleaningUnpackMojo
getCleanupLog, getInitiallyAllowed, matches, setCleanup, setForce, setForceCleanup, setLogCleanup, setSkipIfExists, skipIfExistsMethods inherited from class org.apache.maven.plugins.dependency.fromConfiguration.UnpackMojo
getExcludes, getFileMappers, getIncludes, getMarkersDirectory, getProcessedArtifactItems, setExcludes, setFileMappers, setIncludes, setMarkersDirectoryMethods inherited from class org.apache.maven.plugins.dependency.fromConfiguration.AbstractFromConfigurationMojo
getArtifact, getArtifactItems, getOutputDirectory, getProcessedArtifactItems, isOverWriteIfNewer, isOverWriteReleases, isOverWriteSnapshots, setArtifact, setArtifactItems, setLocalRepositoryDirectory, setOutputDirectory, setOverWriteIfNewer, setOverWriteReleases, setOverWriteSnapshots, verifyRequirementsMethods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
copyFile, execute, getArchiverManager, getProject, isSilent, isSkip, isUseJvmChmod, newResolvePluginProjectBuildingRequest, setArchiverManager, setSilent, setSkip, setUseJvmChmod, unpack, unpack, unpackMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
NAME_CLASSPATH_FILE
- See Also:
-
plugins
@Parameter(property="unpack.plugins", required=false) private List<UnpackPluginMojo.PluginItem> plugins -
version
-
relocate
@Parameter(property="unpack.relocate", required=false, defaultValue="false") private boolean relocate -
always
@Parameter(property="unpack.always", required=false, defaultValue="false") private boolean always -
relocateTarget
@Parameter(property="unpack.relocateTarget", required=false, defaultValue="jars") private File relocateTarget -
forceResolve
@Parameter(property="unpack.forceResolve", required=false, defaultValue="false") private boolean forceResolve -
resolveAndCopy
@Parameter(property="unpack.resolveAndCopy", required=false, defaultValue="false") private boolean resolveAndCopy -
targetDirectory
-
writeResolved
@Parameter(property="mdep.writeResolved", defaultValue="false") private boolean writeResolved -
resolvedFile
-
classpathFiles
-
remoteArtifactRepositories
@Parameter(defaultValue="${project.remoteArtifactRepositories}", readonly=true, required=true) private List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories -
remoteRepositories
@Parameter(defaultValue="${project.remoteProjectRepositories}", readonly=true) private List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories -
repoSession
@Parameter(defaultValue="${repositorySystemSession}", readonly=true) private org.eclipse.aether.RepositorySystemSession repoSession -
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session -
repoSystem
@Component private org.eclipse.aether.RepositorySystem repoSystem -
pluginAppends
-
resolver
-
-
Constructor Details
-
UnpackPluginMojo
public UnpackPluginMojo()
-
-
Method Details
-
doExecute
public void doExecute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Overrides:
doExecutein classCleaningUnpackMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getActualVersion
Returns the actual (overridden) version of the given plugin item.- Parameters:
pl- the plugin item- Returns:
- the version
-
toArtifactItem
private org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem toArtifactItem(UnpackPluginMojo.PluginItem pl) Turns aUnpackPluginMojo.PluginItemto a pre-configuredArtifactItempassed on for resolution/download.- Parameters:
pl- the plugin item to convert- Returns:
- the converted artifact item
-
storeResolved
private void storeResolved() throws org.apache.maven.plugin.MojoExecutionExceptionStores the resolved dependencies if enabled.- Throws:
org.apache.maven.plugin.MojoExecutionException- if obtaining the dependencies fails
-
getOutputDir
Returns the output directory for a plugin/classpath file name.- Parameters:
name- the name, may be null or empty for none/base dir/independent of name- Returns:
- the output directory
-
getCpFile
Returns the path to a (more qualified) classpath file based on the output directory for a plugin/classpath file name.- Parameters:
name- the name- Returns:
- the output directory
-
handleAppends
private void handleAppends()Handles the appends. -
handleSetupDescriptors
private void handleSetupDescriptors()Handles explicit setup descriptors by rewriting the classpath files. -
mergeFiles
Merges files fromsrcintotgtby only copying those that do not already exist.- Parameters:
src- the source foldertgt- the target folder- Throws:
IOException- if copying fails
-
extractSuffix
Extracts the suffix after removing the prefix.- Parameters:
prefix- the prefix to look for, may be nullline- the line to extract the suffix fromdflt- the default value if there is no prefix, usuallyline- Returns:
lineor the line without the prefix
-
fixPrefix
Fixes the prefix by appending a path separator if needed.- Parameters:
prefix- the prefixtokenizer- the tokenizer determining the path separator- Returns:
- the fixed prefix
-
stripPrefix
Strips a prefix from a classpath token.- Parameters:
prefix- the prefixcpToken- the classpath token- Returns:
- the stripped
cpTokenif there is something to strip
-
relocate
private void relocate() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionRelocates the unpacked files.- Throws:
org.apache.maven.plugin.MojoExecutionException- if the execution failsorg.apache.maven.plugin.MojoFailureException- if a remarkable processing failure occurred
-
processCpLineRelocation
private void processCpLineRelocation(String name, String mode, PrintStream out, UnpackPluginMojo.Tokenizer tokenizer, String prefix, File jarFolder) Processes a classpath line while plugin relocation.- Parameters:
name- the name of the pluginmode- the unpack mode, may be nullout- the output stream for the rewritten classpath filetokenizer- the tokenizerprefix- the classpath token prefixjarFolder- the folder where to copy the jars to
-
processCpLineNoRelocation
private void processCpLineNoRelocation(String name, String mode, String line, PrintStream out, UnpackPluginMojo.Tokenizer tokenizer, String prefix) Processes a classpath line without plugin relocation.- Parameters:
name- the name of the pluginmode- the unpack mode, may be nullline- the classpath lineout- the output stream for the rewritten classpath filetokenizer- the tokenizerprefix- the classpath token prefix (forforceResolve)
-
rewriteToken
private String rewriteToken(String token, String mode, String prefix, File jarFolder, UnpackPluginMojo.Tokenizer tokenizer) Rewrites a classpath token.- Parameters:
token- the tokenmode- the unpack mode, may be nullprefix- the classpath token prefix (forforceResolve)jarFolder- the folder where to copy the jars to (considerd only forresolveAndCopy, may be null considered as ifresolveAndCopyisfalse)tokenizer- the tokenizer- Returns:
tokenor the rewritten token
-
isModeResolve
Returns whether we are in resolve mode, i.e., eithermodeindicates "resolve" orforceResolve.- Parameters:
mode- the unpack mode, may be null- Returns:
truefor resolve,falseelse
-
handleAppends
Handles appends, if specified, by passing elements that are not yet inknownTokenstohandler.- Parameters:
name- the name of the pluginknownTokens- the tokens known so far (classpath entries), modified as a side effecthandler- the handler to be called
-
parsePath
Parses a classpath path back into a maven artifact.- Parameters:
path- the path- Returns:
- the artifact
-
findArtifactId
Returns the position of the "." after the groupId inname.- Parameters:
name- the name to analyze- Returns:
- the position
-
resolve
Tries to resolve the path.- Parameters:
path- the given classpath pathjarFolder- the folder where to copy the jars to (considerd only forresolveAndCopy, may be null considered as ifresolveAndCopyisfalse)- Returns:
pathor the resolved path (in the local maven repo)
-
newResolveArtifactProjectBuildingRequest
public org.apache.maven.project.ProjectBuildingRequest newResolveArtifactProjectBuildingRequest()- Overrides:
newResolveArtifactProjectBuildingRequestin classorg.apache.maven.plugins.dependency.AbstractDependencyMojo
-