Package org.apache.sis.internal.maven
Class JarCollector
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.sis.internal.maven.JarCollector
- All Implemented Interfaces:
FileFilter,org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="collect-jars",
defaultPhase=PACKAGE,
requiresDependencyResolution=RUNTIME)
public final class JarCollector
extends org.apache.maven.plugin.AbstractMojo
implements FileFilter
Collects
.jar files in a single "target/binaries" directory.
Dependencies are collected as well, except if already presents. This mojo uses hard links
on platforms that support them. If hard links are not supported, then this mojo will instead
creates a "target/binaries/other_dependencies.txt" file listing the dependencies.- Since:
- 0.3
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.maven.project.MavenProjectThe Maven project running this plugin.private StringThe root directory (without the "target/binaries" sub-directory) where JARs are to be copied.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanFilters the content of the "target" directory in order to keep only the project build result.private voidcollect()Implementation of theexecute()method.voidexecute()Copies the*.jarfiles to the collect directory.private static StringgetFinalName(File file, org.apache.maven.artifact.Artifact artifact) Returns the name of the given file.private FileReturns the JAR file, ornullif none.private static voidlinkFileToDirectory(File file, File copy) Creates a link from the given source file to the given target file.loadDependencyList(File dependenciesFile) Loads the from the given directory, if it exists.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
project
@Parameter(property="project", required=true, readonly=true) private org.apache.maven.project.MavenProject projectThe Maven project running this plugin. -
rootDirectory
The root directory (without the "target/binaries" sub-directory) where JARs are to be copied. It should be the directory of the rootpom.xml.
-
-
Constructor Details
-
JarCollector
public JarCollector()Invoked by reflection for creating the MOJO.
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionCopies the*.jarfiles to the collect directory.- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionException- if the plugin execution failed.
-
collect
Implementation of theexecute()method.- Throws:
org.apache.maven.plugin.MojoExecutionExceptionIOException
-
accept
Filters the content of the "target" directory in order to keep only the project build result. We scan the directory because the final name may be different than the actual file name, because a classifier may have been added to the name.The
.jarextension is not quite appropriate for source and Javadoc files; a better extension would be.zip. Unfortunately, the.jarextension for those content is a very common practice, so we have to filter them.- Specified by:
acceptin interfaceFileFilter
-
getProjectFile
Returns the JAR file, ornullif none. In case of doubt, conservatively returnsnull. -
getFinalName
Returns the name of the given file. If the given file is a snapshot, then the"SNAPSHOT"will be replaced by the timestamp if possible.- Parameters:
file- the file from which to get the filename.artifact- the artifact that produced the given file.- Returns:
- the filename to use.
-
linkFileToDirectory
Creates a link from the given source file to the given target file. On platforms that do not support links, this method rather updates the "other_dependencies.txt" file.- Parameters:
file- the source file to read.copy- the destination file to create.- Throws:
IOException
-
loadDependencyList
Loads the from the given directory, if it exists. Otherwise returns an empty but modifiable set. This method is invoked on platforms that do not support hard links.- Throws:
IOException
-