Class 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 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
    • Constructor Detail

      • TransformMojo

        public TransformMojo()
    • 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 of TransformerFactory.
        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