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.
  • Field Details

    • 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 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
  • 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.MojoExecutionException
      Creates a new instance of TransformerFactory.
      Throws:
      org.apache.maven.plugin.MojoFailureException
      org.apache.maven.plugin.MojoExecutionException
    • newTransformerFactory

      public static TransformerFactory newTransformerFactory(String factoryClassName, ClassLoader classLoader) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
      Throws:
      NoSuchMethodException
      IllegalAccessException
      InvocationTargetException
    • getFile

      private File getFile(File pDir, String pFile)
    • getDir

      private File getDir(File pDir)
    • addToClasspath

      private void addToClasspath(File pOutputDir)
    • getOutputDir

      private File getOutputDir(File pOutputDir)
    • getAllExMsgs

      private static String getAllExMsgs(Throwable ex, boolean includeExName)
    • findLastModified

      protected long findLastModified(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(List<?> dependsFiles, 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(Transformer pTransformer, File input, File output, Resolver pResolver) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getOutputFile

      private File getOutputFile(File targetDir, 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 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.MojoFailureException
      Called by Maven to run the plugin.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException