Package org.xwiki.tool.xar
Class XARMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.xwiki.tool.xar.XARMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="xar",
defaultPhase=PACKAGE,
requiresDependencyResolution=COMPILE,
threadSafe=true)
public class XARMojo
extends org.apache.maven.plugin.AbstractMojo
Gather all resources in a XAR file (which is actually a ZIP file). Also generates a XAR descriptor if none is
provided.
- Version:
- $Id: 31e26e9991826de8afb492d9920be4bbb451704a $
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The encoding to use when generating the package summary file and when storing file names.protected String[]
List of files to exclude.protected org.apache.maven.artifact.factory.ArtifactFactory
Used to look up Artifacts in the remote repository.protected static final String
The name of the tag that marks a specific file inlink #PACKAGE_XML
.protected static final String
The name of the tag that marks the list of files inlink #PACKAGE_XML
.protected String[]
List of files to include.protected org.apache.maven.project.MavenProjectBuilder
Project builder -- builds a model from a pom.xml.protected static final String
The name of the XAR descriptor file.protected org.apache.maven.project.MavenProject
The maven project.protected List<org.apache.maven.artifact.repository.ArtifactRepository>
List of Remote Repositories used by the resolver.protected org.apache.maven.artifact.resolver.ArtifactResolver
Used to look up Artifacts in the remote repository.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
protected org.xwiki.tool.xar.internal.XWikiDocument
getDocFromXML
(File file) Load a XWiki document from its XML representation.protected static Collection<String>
getDocumentNamesFromXML
(File file) Gets the list of document names from a 'package.xml'-like document.static Collection<String>
getDocumentNamesFromXML
(InputStream stream) protected String[]
protected String[]
org.apache.maven.project.MavenProject
protected File
getXarEntriesMapFromXML
(File file) Gets the list of entry from a 'package.xml'-like document.getXarEntriesMapFromXML
(InputStream stream) Gets the list of entry from a 'package.xml'-like document.protected Set<org.apache.maven.artifact.Artifact>
resolveArtifactDependencies
(org.apache.maven.artifact.Artifact artifact) This method resolves all transitive dependencies of an artifact.protected Set<org.apache.maven.artifact.Artifact>
resolveDependencyArtifacts
(org.apache.maven.project.MavenProject pomProject) protected void
unpack
(File file, File location, String logName, boolean overwrite, String[] includes, String[] excludes) Unpacks the XAR file (exclude the package.xml file if it exists).protected void
unpackXARToOutputDirectory
(org.apache.maven.artifact.Artifact artifact, String[] includes, String[] excludes) Unpacks A XAR artifacts into the build output directory, along with the project's XAR files.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
PACKAGE_XML
The name of the XAR descriptor file.- See Also:
-
FILES_TAG
The name of the tag that marks the list of files inlink #PACKAGE_XML
.- See Also:
-
FILE_TAG
The name of the tag that marks a specific file inlink #PACKAGE_XML
.- See Also:
-
includes
List of files to include. Specified as fileset patterns. -
excludes
List of files to exclude. Specified as fileset patterns. -
project
@Parameter(property="project", required=true, readonly=true) protected org.apache.maven.project.MavenProject projectThe maven project. -
encoding
The encoding to use when generating the package summary file and when storing file names. -
remoteRepos
@Parameter(property="project.remoteArtifactRepositories", readonly=true, required=true) protected List<org.apache.maven.artifact.repository.ArtifactRepository> remoteReposList of Remote Repositories used by the resolver. -
mavenProjectBuilder
@Component protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilderProject builder -- builds a model from a pom.xml. -
factory
@Component protected org.apache.maven.artifact.factory.ArtifactFactory factoryUsed to look up Artifacts in the remote repository. -
resolver
@Component protected org.apache.maven.artifact.resolver.ArtifactResolver resolverUsed to look up Artifacts in the remote repository.
-
-
Constructor Details
-
XARMojo
public XARMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getXarEntriesMapFromXML
Gets the list of entry from a 'package.xml'-like document.- Parameters:
file
- the XML document to parse- Returns:
- the Map of entries contained in the XML document (ordered in the same order as the file)
- Throws:
Exception
- if the XML document is invalid or it contains no document list or it doesn't exist- Since:
- 10.3
-
getXarEntriesMapFromXML
Gets the list of entry from a 'package.xml'-like document.- Parameters:
stream
- the XML document to parse- Returns:
- the Map of entries contained in the XML document (ordered in the same order as the file)
- Throws:
Exception
- if the XML document is invalid or it contains no document list or it doesn't exist- Since:
- 10.3
-
getDocumentNamesFromXML
Gets the list of document names from a 'package.xml'-like document.- Parameters:
file
- the XML document to parse- Returns:
- the list of document names contained in the XML document
- Throws:
Exception
- if the XML document is invalid or it contains no document list or it doesn't exist
-
getDocumentNamesFromXML
- Throws:
Exception
-
getIncludes
- Returns:
- the includes
-
getExcludes
- Returns:
- the excludes
-
getEntryMap
- Returns:
- the map containing all the XAR entries
-
unpack
protected void unpack(File file, File location, String logName, boolean overwrite, String[] includes, String[] excludes) throws org.apache.maven.plugin.MojoExecutionException Unpacks the XAR file (exclude the package.xml file if it exists).- Parameters:
file
- the file to be unpacked.location
- the location where to put the unpacket files.logName
- the name use withConsoleLogger
.overwrite
- indicate if extracted files has to overwrite existing ones.- Throws:
org.apache.maven.plugin.MojoExecutionException
- error when unpacking the file.
-
unpackXARToOutputDirectory
protected void unpackXARToOutputDirectory(org.apache.maven.artifact.Artifact artifact, String[] includes, String[] excludes) throws org.apache.maven.plugin.MojoExecutionException Unpacks A XAR artifacts into the build output directory, along with the project's XAR files.- Parameters:
artifact
- the XAR artifact to unpack.- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of unpack error
-
getProject
public org.apache.maven.project.MavenProject getProject()- Returns:
- Returns the project.
-
resolveArtifactDependencies
protected Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.artifact.resolver.ArtifactResolutionException, org.apache.maven.artifact.resolver.ArtifactNotFoundException, org.apache.maven.project.ProjectBuildingException This method resolves all transitive dependencies of an artifact.- Parameters:
artifact
- the artifact used to retrieve dependencies- Returns:
- resolved set of dependencies
- Throws:
org.apache.maven.artifact.resolver.ArtifactResolutionException
- errororg.apache.maven.artifact.resolver.ArtifactNotFoundException
- errororg.apache.maven.project.ProjectBuildingException
- errororg.apache.maven.project.artifact.InvalidDependencyVersionException
- error
-
resolveDependencyArtifacts
protected Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts(org.apache.maven.project.MavenProject pomProject) throws org.apache.maven.artifact.resolver.ArtifactResolutionException, org.apache.maven.artifact.resolver.ArtifactNotFoundException, org.apache.maven.project.artifact.InvalidDependencyVersionException - Parameters:
pomProject
- the project- Returns:
- set of dependencies
- Throws:
org.apache.maven.artifact.resolver.ArtifactResolutionException
- errororg.apache.maven.artifact.resolver.ArtifactNotFoundException
- errororg.apache.maven.project.artifact.InvalidDependencyVersionException
- error
-
getDocFromXML
protected org.xwiki.tool.xar.internal.XWikiDocument getDocFromXML(File file) throws org.apache.maven.plugin.MojoExecutionException Load a XWiki document from its XML representation.- Parameters:
file
- the file to parse.- Returns:
- the loaded document object or null if the document cannot be parsed
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getResourcesDirectory
- Returns:
- the Maven Resources directory for the project
-