Package org.codehaus.mojo.xml
Class TransformMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.xml.AbstractXmlMojo
-
- org.codehaus.mojo.xml.TransformMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(defaultPhase=GENERATE_RESOURCES, name="transform", threadSafe=true) public class TransformMojo extends AbstractXmlMojo
The TransformMojo is used for transforming a set of files using a common stylesheet.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
AbstractXmlMojo.CatalogHandling
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
forceCreation
Whether creating the transformed files should be forced.private TransformationSet[]
transformationSets
Specifies one or more sets of files, which are being transformed.private java.lang.String
transformerFactory
Transformer factory use.
-
Constructor Summary
Constructors Constructor Description TransformMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addToClasspath(java.io.File pOutputDir)
void
execute()
Called by Maven to run the plugin.protected long
findLastModified(java.util.List<?> files, boolean oldest)
private static java.lang.String
getAllExMsgs(java.lang.Throwable ex, boolean includeExName)
private java.io.File
getDir(java.io.File pDir)
private java.io.File
getFile(java.io.File pDir, java.lang.String pFile)
private java.io.File
getOutputDir(java.io.File pOutputDir)
private java.io.File
getOutputFile(java.io.File targetDir, java.lang.String pName, org.codehaus.plexus.components.io.filemappers.FileMapper[] pFileMappers)
private javax.xml.transform.Templates
getTemplate(Resolver pResolver, javax.xml.transform.Source stylesheet, TransformationSet transformationSet)
private javax.xml.transform.TransformerFactory
getTransformerFactory()
Creates a new instance ofTransformerFactory
.protected boolean
isUpdToDate(java.util.List<?> dependsFiles, java.util.List<?> producesFiles)
private javax.xml.transform.Transformer
newTransformer(javax.xml.transform.Templates template, TransformationSet pTransformationSet)
static javax.xml.transform.TransformerFactory
newTransformerFactory(java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
private void
setFeature(javax.xml.transform.TransformerFactory pTransformerFactory, java.lang.String name, java.lang.Boolean value)
private void
transform(javax.xml.transform.Transformer pTransformer, java.io.File input, java.io.File output, Resolver pResolver)
private void
transform(Resolver pResolver, TransformationSet pTransformationSet)
-
Methods inherited from class org.codehaus.mojo.xml.AbstractXmlMojo
activateProxy, asAbsoluteFile, asFiles, checkCatalogHandling, getBasedir, getCatalogHandling, getExcludes, getFileNames, getFiles, getLocator, getProject, getResolver, getResource, isSkipping, passivateProxy, setCatalogs
-
-
-
-
Field Detail
-
transformationSets
@Parameter private TransformationSet[] transformationSets
Specifies one or more sets of files, which are being transformed.
-
forceCreation
@Parameter(property="xml.forceCreation", defaultValue="false") private boolean forceCreation
Whether creating the transformed files should be forced.
-
transformerFactory
@Parameter(property="xml.transformerFactory") private java.lang.String transformerFactory
Transformer factory use. By default, the systems default transformer factory is used. If you use this feature you must use at least jdk 1.6
-
-
Method Detail
-
setFeature
private void setFeature(javax.xml.transform.TransformerFactory pTransformerFactory, java.lang.String name, java.lang.Boolean value) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getTemplate
private javax.xml.transform.Templates getTemplate(Resolver pResolver, javax.xml.transform.Source stylesheet, TransformationSet transformationSet) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
getTransformerFactory
private javax.xml.transform.TransformerFactory getTransformerFactory() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionException
Creates a new instance ofTransformerFactory
.- Throws:
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
-
newTransformerFactory
public static javax.xml.transform.TransformerFactory newTransformerFactory(java.lang.String factoryClassName, java.lang.ClassLoader classLoader) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
- Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
-
getFile
private java.io.File getFile(java.io.File pDir, java.lang.String pFile)
-
getDir
private java.io.File getDir(java.io.File pDir)
-
addToClasspath
private void addToClasspath(java.io.File pOutputDir)
-
getOutputDir
private java.io.File getOutputDir(java.io.File pOutputDir)
-
getAllExMsgs
private static java.lang.String getAllExMsgs(java.lang.Throwable ex, boolean includeExName)
-
findLastModified
protected long findLastModified(java.util.List<?> files, boolean oldest)
- Parameters:
files
- the fileNames or URLs to scan their lastModified timestamp.oldest
- if true, returns the latest modificationDate of all files, otherwise returns the earliest.- Returns:
- the older or younger last modification timestamp of all files.
-
isUpdToDate
protected boolean isUpdToDate(java.util.List<?> dependsFiles, java.util.List<?> producesFiles)
- Returns:
- true to indicate results are up-to-date, that is, when the latest from input files is earlier than the younger from the output files (meaning no re-execution required).
-
transform
private void transform(javax.xml.transform.Transformer pTransformer, java.io.File input, java.io.File output, Resolver pResolver) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getOutputFile
private java.io.File getOutputFile(java.io.File targetDir, java.lang.String pName, org.codehaus.plexus.components.io.filemappers.FileMapper[] pFileMappers)
-
transform
private void transform(Resolver pResolver, TransformationSet pTransformationSet) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
newTransformer
private javax.xml.transform.Transformer newTransformer(javax.xml.transform.Templates template, TransformationSet pTransformationSet) throws javax.xml.transform.TransformerConfigurationException, org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
javax.xml.transform.TransformerConfigurationException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
Called by Maven to run the plugin.- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
-