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
FieldsModifier and TypeFieldDescriptionprivate boolean
Whether creating the transformed files should be forced.private TransformationSet[]
Specifies one or more sets of files, which are being transformed.private String
Transformer factory use.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addToClasspath
(File pOutputDir) void
execute()
Called by Maven to run the plugin.protected long
findLastModified
(List<?> files, boolean oldest) private static String
getAllExMsgs
(Throwable ex, boolean includeExName) private File
private File
private File
getOutputDir
(File pOutputDir) private File
getOutputFile
(File targetDir, String pName, org.codehaus.plexus.components.io.filemappers.FileMapper[] pFileMappers) private Templates
getTemplate
(Resolver pResolver, Source stylesheet, TransformationSet transformationSet) private TransformerFactory
Creates a new instance ofTransformerFactory
.protected boolean
isUpdToDate
(List<?> dependsFiles, List<?> producesFiles) private Transformer
newTransformer
(Templates template, TransformationSet pTransformationSet) static TransformerFactory
newTransformerFactory
(String factoryClassName, ClassLoader classLoader) private void
setFeature
(TransformerFactory pTransformerFactory, String name, Boolean value) private void
transform
(Transformer pTransformer, File input, 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
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
transformationSets
Specifies one or more sets of files, which are being transformed. -
forceCreation
@Parameter(property="xml.forceCreation", defaultValue="false") private boolean forceCreationWhether creating the transformed files should be forced. -
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
-
-
Constructor Details
-
TransformMojo
public TransformMojo()
-
-
Method Details
-
setFeature
private void setFeature(TransformerFactory pTransformerFactory, String name, Boolean value) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
getTemplate
private Templates getTemplate(Resolver pResolver, 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 TransformerFactory getTransformerFactory() throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionExceptionCreates a new instance ofTransformerFactory
.- Throws:
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
-
newTransformerFactory
public static TransformerFactory newTransformerFactory(String factoryClassName, ClassLoader classLoader) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException -
getFile
-
getDir
-
addToClasspath
-
getOutputDir
-
getAllExMsgs
-
findLastModified
- 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
- 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(Transformer pTransformer, File input, File output, Resolver pResolver) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
getOutputFile
-
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 Transformer newTransformer(Templates template, TransformationSet pTransformationSet) throws TransformerConfigurationException, org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException - Throws:
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.MojoFailureExceptionCalled by Maven to run the plugin.- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-