Package org.xwiki.tool.xar
Class VerifyMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.xwiki.tool.xar.AbstractVerifyMojo
-
- org.xwiki.tool.xar.VerifyMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="verify", defaultPhase=VERIFY, threadSafe=true) public class VerifyMojo extends AbstractVerifyMojo
Perform various verifications of the XAR files in this project. Namely:- ensure that the encoding is UTF8
- (optional) ensure that all pages have a parent (except for
Main.WebHome
) - ensure that the author/contentAuthor/creator/attachment authors are
xwiki:XWiki.Admin
- ensure that the version is
1.1
- ensure that comment is empty
- ensure that minor edit is false
- ensure that technical pages are hidden. We consider by default that all pages are technical unless specified otherwise
- ensure that the default language is set properly
- ensure titles follow any defined rules (when defined by the user)
- ensure that Translations pages are using the plain/1.0 syntax
- ensure that Translations pages don't have a GLOBAL or USER visibility (USER makes no sense and GLOBAL would require Programming Rights, which is an issue in farm-based use cases)
- ensure that translated pages don't contain any attachment
- ensure that translated pages don't contain any object
- ensure that attachments have a mimetype set. If the mimetype is missing then the attachment won't be filterable in the attachment view in Page Index.
- Version:
- $Id: edd386630084ed2fde18edb86a5eada6bbccd31c $
-
-
Field Summary
Fields Modifier and Type Field Description 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 inlink #PACKAGE_XML
.protected static String
FILES_TAG
The name of the tag that marks the list of files inlink #PACKAGE_XML
.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 XAR descriptor file.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 class org.xwiki.tool.xar.AbstractVerifyMojo
AUTHOR, commonsVersion, contentPages, defaultLanguage, force, formatLicense, skipAuthors, skipAuthorsDocumentList, skipDates, skipDatesDocumentList, translatablePages, VERSION, visibleTechnicalPages
-
-
Constructor Summary
Constructors Constructor Description VerifyMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
protected org.xwiki.tool.xar.internal.XWikiDocument
getDocFromXML(File file)
Load a XWiki document from its XML representation.protected Map<String,XAREntry>
getEntryMap()
protected String[]
getExcludes()
protected String[]
getIncludes()
org.apache.maven.project.MavenProject
getProject()
protected File
getResourcesDirectory()
protected void
initializePatterns()
Initialize regex Patterns for performance reasons.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.xwiki.tool.xar.AbstractVerifyMojo
executeLicenseGoal, getXARXMLFiles, getXWikiCommonsVersion, guessDefaultLocale, isContentPage, isTranslatablePage, isVisibleTechnicalPage
-
-
-
-
Field Detail
-
PACKAGE_XML
protected static final String PACKAGE_XML
The name of the XAR descriptor file.- See Also:
- Constant Field Values
-
FILES_TAG
protected static final String FILES_TAG
The name of the tag that marks the list of files inlink #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 inlink #PACKAGE_XML
.- See Also:
- Constant Field Values
-
includes
@Parameter(property="includes") protected String[] includes
List of files to include. Specified as fileset patterns.
-
excludes
@Parameter(property="excludes") protected String[] excludes
List of files to exclude. Specified as fileset patterns.
-
project
@Parameter(property="project", required=true, readonly=true) protected org.apache.maven.project.MavenProject project
The maven project.
-
encoding
@Parameter(property="project.build.sourceEncoding") protected String 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> remoteRepos
List of Remote Repositories used by the resolver.
-
mavenProjectBuilder
@Component protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
Project builder -- builds a model from a pom.xml.
-
factory
@Component protected org.apache.maven.artifact.factory.ArtifactFactory factory
Used to look up Artifacts in the remote repository.
-
resolver
@Component protected org.apache.maven.artifact.resolver.ArtifactResolver resolver
Used to look up Artifacts in the remote repository.
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
initializePatterns
protected void initializePatterns()
Description copied from class:AbstractVerifyMojo
Initialize regex Patterns for performance reasons.- Overrides:
initializePatterns
in classAbstractVerifyMojo
-
getIncludes
protected String[] getIncludes()
- Returns:
- the includes
-
getExcludes
protected String[] getExcludes()
- Returns:
- the excludes
-
getEntryMap
protected Map<String,XAREntry> 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
protected File getResourcesDirectory()
- Returns:
- the Maven Resources directory for the project
-
-