Package org.xwiki.tool.xar
Class AbstractVerifyMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.xwiki.tool.xar.AbstractVerifyMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
FormatMojo
,VerifyMojo
public abstract class AbstractVerifyMojo
extends org.apache.maven.plugin.AbstractMojo
Common code for the Verify and Format Mojos.
- Since:
- 4.0M2
- Version:
- $Id: 6d45d429d12082f8f5d8c2cd35878973b8ae14ea $
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Admin author for creator/contentAuthor and author.protected String
The Commons version to be used by this mojo.Explicitly define a list of pages (it's a regex) that should be considered as content pages (rather than technical pages which is the default).protected String
The language in which non-translated documents are written in.protected 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 boolean
If true then don't check if the packaging is XAR before running mojos.protected boolean
If true then check for cliense and add a license header to XML files.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.protected boolean
Disables the check for the existence of the author fields.Disables the check for the existence of the author fields.protected boolean
Disables the check for the existence of the date fields.Disables the check for the existence of the date fields.Explicitly define a list of pages (it's a regex) that can have translations and thus which must have a default language not empty.protected static final String
First version.Explicitly define a list of pages (it's a regex) that are technical pages but that should be visible (not hidden).Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
executeLicenseGoal
(String goal) Executes a goal of the Maven License plugin (used for adding or checking for license headers.protected org.xwiki.tool.xar.internal.XWikiDocument
getDocFromXML
(File file) Load a XWiki document from its XML representation.protected String[]
protected String[]
org.apache.maven.project.MavenProject
protected File
protected Collection<File>
protected String
protected Locale
guessDefaultLocale
(File file, Collection<File> xwikiXmlFiles) Guess the<defaultLanguage>
value to use for the passed file using the following algorithm: If the page name matches one of the regexes defined by the user as a translated page, then check that the default language isdefaultLanguage
. Otherwise, if the page name matches one of the regexes defined by the user as a content page, then check that the default language isdefaultLanguage
. Otherwise, if there's no other translation of the file then check that the default language is empty since it's a technical page. Otherwise, if there are other translations ("(prefix).(language).xml" format) then check that the default language should isdefaultLanguage
protected void
Initialize regex Patterns for performance reasons.protected boolean
isContentPage
(String filePath) protected boolean
isTranslatablePage
(String filePath) protected boolean
isVisibleTechnicalPage
(String filePath) 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
AUTHOR
Admin author for creator/contentAuthor and author.- See Also:
-
VERSION
First version.- See Also:
-
force
@Parameter(property="xar.force", readonly=true) protected boolean forceIf true then don't check if the packaging is XAR before running mojos. -
defaultLanguage
The language in which non-translated documents are written in. -
formatLicense
@Parameter(property="xar.formatLicense", readonly=true) protected boolean formatLicenseIf true then check for cliense and add a license header to XML files. -
commonsVersion
The Commons version to be used by this mojo. -
skipDates
@Parameter(property="xar.dates.skip", defaultValue="false") protected boolean skipDatesDisables the check for the existence of the date fields.- Since:
- 10.8RC1
-
skipDatesDocumentList
Disables the check for the existence of the date fields.- Since:
- 10.8RC1
-
skipAuthors
@Parameter(property="xar.authors.skip", defaultValue="false") protected boolean skipAuthorsDisables the check for the existence of the author fields.- Since:
- 14.5
-
skipAuthorsDocumentList
Disables the check for the existence of the author fields.- Since:
- 14.5
-
contentPages
Explicitly define a list of pages (it's a regex) that should be considered as content pages (rather than technical pages which is the default). Note that content pages must have a non-empty default language specified.- Since:
- 7.1M1
-
translatablePages
@Parameter(property="xar.translatablePages", defaultValue=".*/.*Translations\\.xml") protected List<String> translatablePagesExplicitly define a list of pages (it's a regex) that can have translations and thus which must have a default language not empty. If not defined then defaults to considering that*Translations.xml
pages are translated pages.- Since:
- 12.3RC1
-
visibleTechnicalPages
Explicitly define a list of pages (it's a regex) that are technical pages but that should be visible (not hidden). For example, home pages of applications. These pages must have their default langue set to empty so that a search in a given language doesn't return them as they're not content.- Since:
- 12.3RC1
-
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
-
AbstractVerifyMojo
public AbstractVerifyMojo()
-
-
Method Details
-
initializePatterns
protected void initializePatterns()Initialize regex Patterns for performance reasons. -
getXARXMLFiles
- Returns:
- the list of XAR XML files in this project
- Throws:
org.apache.maven.plugin.MojoFailureException
- when an error happens reading the XAR XML files on the file system
-
guessDefaultLocale
Guess the<defaultLanguage>
value to use for the passed file using the following algorithm:- If the page name matches one of the regexes defined by the user as a translated page, then check that
the default language is
defaultLanguage
. - Otherwise, if the page name matches one of the regexes defined by the user as a content page, then check
that the default language is
defaultLanguage
. - Otherwise, if there's no other translation of the file then check that the default language is empty since it's a technical page.
- Otherwise, if there are other translations ("(prefix).(language).xml" format) then check that the default
language should is
defaultLanguage
- Parameters:
file
- the XML file for which to guess the default language that it should havexwikiXmlFiles
- the list of all XML files that is used to check for translations of the passed XML file- Returns:
- the default language as a string (e.g. "en" for English or "" for an empty default language)
- Since:
- 15.7RC1, 15.5.2, 14.10.15
- If the page name matches one of the regexes defined by the user as a translated page, then check that
the default language is
-
isContentPage
-
isTranslatablePage
-
isVisibleTechnicalPage
-
getXWikiCommonsVersion
- Returns:
- the version of the XWiki Commons project, either configured in the project using this plugin or taken
from the
commons.version
property if defined, defaulting to the current project version if not defined
-
executeLicenseGoal
protected void executeLicenseGoal(String goal) throws org.apache.maven.plugin.MojoExecutionException Executes a goal of the Maven License plugin (used for adding or checking for license headers.- Parameters:
goal
- the goal of the Maven License plugin to call- Throws:
org.apache.maven.plugin.MojoExecutionException
- when the License plugins fails or if it's not found
-
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
-