com.xpn.xwiki.tool.xar
Class XarMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.xpn.xwiki.tool.xar.XarMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

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$

Field Summary
protected  org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager
          To look up Archiver/UnArchiver implementations.
protected  String encoding
          The encoding to use when generating the package summary file and when storing file names.
protected  String[] excludes
          List of files to exclude.
protected  org.apache.maven.artifact.factory.ArtifactFactory factory
          Used to look up Artifacts in the remote repository.
protected static String FILE_TAG
          The name of the tag that marks a specific file in PACKAGE_XML.
protected static String FILES_TAG
          The name of the tag that marks the list of files in PACKAGE_XML.
protected static String HOOK_CLOSE
          Close hook.
protected static String HOOK_OPEN
          Open hook.
protected  String[] includes
          List of files to include.
protected  org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
          Project builder -- builds a model from a pom.xml.
protected static String PACKAGE_XML
          The name of the file in the package when to find general informations.
protected  org.apache.maven.project.MavenProject project
          The maven project.
protected  List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepos
          List of Remote Repositories used by the resolver.
protected  org.apache.maven.artifact.resolver.ArtifactResolver resolver
          Used to look up Artifacts in the remote repository.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
XarMojo()
           
 
Method Summary
 void execute()
           
protected static Collection<String> getDocumentNamesFromXML(File file)
          Gets the list of document names from a 'package.xml'-like document.
protected  String[] getExcludes()
           
protected  String[] getIncludes()
           
 org.apache.maven.project.MavenProject getProject()
           
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)
          Unpacks the XAR file (exclude the package.xml file if it exists).
protected  void unpackXarToOutputDirectory(org.apache.maven.artifact.Artifact artifact)
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

archiverManager

protected org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager
To look up Archiver/UnArchiver implementations.


HOOK_OPEN

protected static final String HOOK_OPEN
Open hook.

See Also:
Constant Field Values

HOOK_CLOSE

protected static final String HOOK_CLOSE
Close hook.

See Also:
Constant Field Values

PACKAGE_XML

protected static final String PACKAGE_XML
The name of the file in the package when to find general informations.

See Also:
Constant Field Values

FILES_TAG

protected static final String FILES_TAG
The name of the tag that marks the list of files in PACKAGE_XML.

See Also:
Constant Field Values

FILE_TAG

protected static final String FILE_TAG
The name of the tag that marks a specific file in PACKAGE_XML.

See Also:
Constant Field Values

includes

protected String[] includes
List of files to include. Specified as fileset patterns.


excludes

protected String[] excludes
List of files to exclude. Specified as fileset patterns.


project

protected org.apache.maven.project.MavenProject project
The maven project.


encoding

protected String encoding
The encoding to use when generating the package summary file and when storing file names.


remoteRepos

protected List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepos
List of Remote Repositories used by the resolver.


mavenProjectBuilder

protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
Project builder -- builds a model from a pom.xml.


factory

protected org.apache.maven.artifact.factory.ArtifactFactory factory
Used to look up Artifacts in the remote repository.


resolver

protected org.apache.maven.artifact.resolver.ArtifactResolver resolver
Used to look up Artifacts in the remote repository.

Constructor Detail

XarMojo

public XarMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getDocumentNamesFromXML

protected static Collection<String> getDocumentNamesFromXML(File file)
                                                     throws Exception
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

getIncludes

protected String[] getIncludes()
Returns:
the includes

getExcludes

protected String[] getExcludes()
Returns:
the excludes

unpack

protected void unpack(File file,
                      File location,
                      String logName,
                      boolean overwrite)
               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 with ConsoleLogger.
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)
                                   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,
                                                                              org.apache.maven.project.artifact.InvalidDependencyVersionException
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 - error
org.apache.maven.artifact.resolver.ArtifactNotFoundException - error
org.apache.maven.project.ProjectBuildingException - error
org.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 - error
org.apache.maven.artifact.resolver.ArtifactNotFoundException - error
org.apache.maven.project.artifact.InvalidDependencyVersionException - error


Copyright © 2004-2012 XWiki. All Rights Reserved.