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 booleanWhether creating the transformed files should be forced.private TransformationSet[]Specifies one or more sets of files, which are being transformed.private StringTransformer factory use.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddToClasspath(File pOutputDir) voidexecute()Called by Maven to run the plugin.protected longfindLastModified(List<?> files, boolean oldest) private static StringgetAllExMsgs(Throwable ex, boolean includeExName) private Fileprivate Fileprivate FilegetOutputDir(File pOutputDir) private FilegetOutputFile(File targetDir, String pName, org.codehaus.plexus.components.io.filemappers.FileMapper[] pFileMappers) private TemplatesgetTemplate(Resolver pResolver, Source stylesheet, TransformationSet transformationSet) private TransformerFactoryCreates a new instance ofTransformerFactory.protected booleanisUpdToDate(List<?> dependsFiles, List<?> producesFiles) private TransformernewTransformer(Templates template, TransformationSet pTransformationSet) static TransformerFactorynewTransformerFactory(String factoryClassName, ClassLoader classLoader) private voidsetFeature(TransformerFactory pTransformerFactory, String name, Boolean value) private voidtransform(Transformer pTransformer, File input, File output, Resolver pResolver) private voidtransform(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, setCatalogsMethods 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. See Transforming XML Files- Since:
- 1.0
-
forceCreation
@Parameter(property="xml.forceCreation", defaultValue="false") private boolean forceCreationWhether creating the transformed files should be forced.- Since:
- 1.0
-
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- Since:
- 1.0
-
-
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.MojoExecutionExceptionorg.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.MojoFailureExceptionorg.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.MojoExecutionExceptionorg.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:
TransformerConfigurationExceptionorg.apache.maven.plugin.MojoExecutionExceptionorg.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.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-