Class BuildClasspathMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.BuildClasspathMojo
-
- All Implemented Interfaces:
Comparator<org.apache.maven.artifact.Artifact>
,org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="build-classpath", requiresDependencyResolution=TEST, defaultPhase=GENERATE_SOURCES, threadSafe=true) public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements Comparator<org.apache.maven.artifact.Artifact>
This goal will output a classpath string of dependencies from the local repository to a file or log.- Since:
- 2.0-alpha-2
- Author:
- ankostis
-
-
Field Summary
-
Fields inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
classifier, excludeArtifactIds, excludeClassifiers, excludeGroupIds, excludeScope, excludeTransitive, excludeTypes, includeArtifactIds, includeClassifiers, includeGroupIds, includeScope, includeTypes, markersDirectory, overWriteIfNewer, overWriteReleases, overWriteSnapshots, prependGroupId, type
-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
outputAbsoluteArtifactFilename, reactorProjects, session
-
-
Constructor Summary
Constructors Constructor Description BuildClasspathMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendArtifactPath(org.apache.maven.artifact.Artifact art, StringBuilder sb)
Appends the artifact path into the specified StringBuilder.protected void
attachFile(String cpString)
int
compare(org.apache.maven.artifact.Artifact art1, org.apache.maven.artifact.Artifact art2)
Compares artifacts lexicographically, using pattern [group_id][artifact_id][version].protected void
doExecute()
Main entry into mojo.protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter
getMarkedArtifactFilter()
Return anArtifactsFilter
indicating which artifacts must be filtered out.boolean
isStripVersion()
protected String
readClasspathFile()
Reads into a string the file specified by the mojo param 'outputFile'.void
setFileSeparator(String theFileSeparator)
void
setLocalRepoProperty(String localRepoProperty)
void
setOutputFile(File outputFile)
void
setOutputProperty(String theOutputProperty)
void
setPathSeparator(String thePathSeparator)
void
setPrefix(String thePrefix)
void
setRegenerateFile(boolean theRegenerateFile)
void
setStripVersion(boolean theStripVersion)
-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
filterMarkedDependencies, getArtifactResolver, getClassifierTranslatedDependencies, getDependencyResolver, getDependencySets, getDependencySets, getMarkersDirectory, getRepositoryManager, getResolvedDependencies, isPrependGroupId, resolve, setMarkersDirectory, setPrependGroupId
-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
copyFile, execute, getArchiverManager, getProject, isSilent, isSkip, isUseJvmChmod, newResolveArtifactProjectBuildingRequest, setArchiverManager, setSilent, setSkip, setUseJvmChmod, unpack, unpack, unpack
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
doExecute
protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException
Main entry into mojo. Gets the list of dependencies and iterates to create a classpath.- Specified by:
doExecute
in classAbstractDependencyMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
- with a message if an error occurs.- See Also:
AbstractDependencyFilterMojo.getResolvedDependencies(boolean)
-
attachFile
protected void attachFile(String cpString) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
cpString
- The classpath.- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
appendArtifactPath
protected void appendArtifactPath(org.apache.maven.artifact.Artifact art, StringBuilder sb)
Appends the artifact path into the specified StringBuilder.- Parameters:
art
-Artifact
sb
-StringBuilder
-
readClasspathFile
protected String readClasspathFile() throws IOException
Reads into a string the file specified by the mojo param 'outputFile'. Assumes, the instance variable 'outputFile' is not null.- Returns:
- the string contained in the classpathFile, if exists, or null otherwise.
- Throws:
IOException
- in case of an error.
-
compare
public int compare(org.apache.maven.artifact.Artifact art1, org.apache.maven.artifact.Artifact art2)
Compares artifacts lexicographically, using pattern [group_id][artifact_id][version].- Specified by:
compare
in interfaceComparator<org.apache.maven.artifact.Artifact>
- Parameters:
art1
- first objectart2
- second object- Returns:
- the value
0
if the argument string is equal to this string; a value less than0
if this string is lexicographically less than the string argument; and a value greater than0
if this string is lexicographically greater than the string argument.
-
getMarkedArtifactFilter
protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter getMarkedArtifactFilter()
Description copied from class:AbstractDependencyFilterMojo
Return anArtifactsFilter
indicating which artifacts must be filtered out.- Specified by:
getMarkedArtifactFilter
in classAbstractDependencyFilterMojo
- Returns:
- an
ArtifactsFilter
indicating which artifacts must be filtered out.
-
setOutputFile
public void setOutputFile(File outputFile)
- Parameters:
outputFile
- the outputFile to set
-
setOutputProperty
public void setOutputProperty(String theOutputProperty)
- Parameters:
theOutputProperty
- the outputProperty to set
-
setFileSeparator
public void setFileSeparator(String theFileSeparator)
- Parameters:
theFileSeparator
- the fileSeparator to set
-
setPathSeparator
public void setPathSeparator(String thePathSeparator)
- Parameters:
thePathSeparator
- the pathSeparator to set
-
setPrefix
public void setPrefix(String thePrefix)
- Parameters:
thePrefix
- the prefix to set
-
setRegenerateFile
public void setRegenerateFile(boolean theRegenerateFile)
- Parameters:
theRegenerateFile
- the regenerateFile to set
-
isStripVersion
public boolean isStripVersion()
- Returns:
- the stripVersion
-
setStripVersion
public void setStripVersion(boolean theStripVersion)
- Parameters:
theStripVersion
- the stripVersion to set
-
setLocalRepoProperty
public void setLocalRepoProperty(String localRepoProperty)
- Parameters:
localRepoProperty
-localRepoProperty
-
-