Class SchemaGenerationMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="schemagen",
          defaultPhase=GENERATE_RESOURCES,
          requiresDependencyResolution=COMPILE,
          threadSafe=true)
    public class SchemaGenerationMojo
    extends AbstractXsdGeneratorMojo

    Mojo that creates XML schema(s) from compile-scope Java sources or binaries by invoking the JAXB SchemaGenerator. This implementation is tailored to use the JAXB Reference Implementation from project Kenai.

    Note that the SchemaGenerationMojo was completely re-implemented for the 2.x versions. Its configuration semantics and parameter set is not necessarily backwards compatible with the 1.x plugin versions. If you are upgrading from version 1.x of the plugin, read the documentation carefully.

    Author:
    Lennart Jörelid
    See Also:
    The JAXB Reference Implementation
    • Field Detail

      • STALE_FILENAME

        public static final String STALE_FILENAME
        The last part of the stale fileName for this SchemaGenerationMojo.
        See Also:
        Constant Field Values
      • STANDARD_SOURCE_EXCLUDE_FILTERS

        public static final List<Filter<File>> STANDARD_SOURCE_EXCLUDE_FILTERS

        Default exclude file name suffixes for sources, used unless overridden by an explicit configuration in the sourceExcludeSuffixes parameter. The default values are found as follows:

             
                 final List<Filter<File>> srcTemp = new ArrayList<Filter<File>>();
                 srcTemp.addAll(AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS);
                 srcTemp.add(new PatternFileFilter(Arrays.asList("\\.xjb", "\\.xsd", "\\.properties"), true));
                 STANDARD_SOURCE_EXCLUDE_FILTERS = Collections.unmodifiableList(srcTemp);
             
         
        See Also:
        AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS
    • Constructor Detail

      • SchemaGenerationMojo

        public SchemaGenerationMojo()
    • Method Detail

      • getCompiledClassNames

        protected List<URL> getCompiledClassNames()
        Finds a List containing URLs to compiled bytecode files within this Compilation Unit. Typically this equals the resolved files under the project's build directories, plus any JAR artifacts found on the classpath.
        Specified by:
        getCompiledClassNames in class AbstractXsdGeneratorMojo
        Returns:
        A non-null List containing URLs to bytecode files within this compilation unit. Typically this equals the resolved files under the project's build directories, plus any JAR artifacts found on the classpath.
      • getSources

        protected List<URL> getSources()
        Override this method to acquire a List holding all URLs to the SchemaGen Java sources for which this AbstractXsdGeneratorMojo should generate Xml Schema Descriptor files.
        Specified by:
        getSources in class AbstractXsdGeneratorMojo
        Returns:
        A non-null List holding URLs to sources for the XSD generation.
      • getOutputDirectory

        protected File getOutputDirectory()
        Retrieves the directory where the generated files should be written to.
        Specified by:
        getOutputDirectory in class AbstractJaxbMojo
        Returns:
        the directory where the generated files should be written to.
      • getClasspath

        protected List<String> getClasspath()
                                     throws org.apache.maven.plugin.MojoExecutionException
        Retrieves the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read bytecode classes.
        Specified by:
        getClasspath in class AbstractJaxbMojo
        Returns:
        the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read classes.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if the classpath could not be retrieved.
      • getStaleFileName

        protected String getStaleFileName()
        Retrieves the last name part of the stale file. The full name of the stale file will be generated by pre-pending "." + getExecution().getExecutionId() before this staleFileName.
        Specified by:
        getStaleFileName in class AbstractJaxbMojo
        Returns:
        The name of the stale file used by this AbstractJavaGeneratorMojo to detect staleness amongst its generated files.
      • getWorkDirectory

        protected File getWorkDirectory()
        Specified by:
        getWorkDirectory in class AbstractXsdGeneratorMojo
        Returns:
        The working directory to which the SchemaGenerator should initially copy all its generated files, including bytecode files, compiled from java sources.
      • addResource

        protected void addResource​(org.apache.maven.model.Resource resource)
        Adds the supplied Resource to the project using the appropriate scope (i.e. resource or testResource) depending on the exact implementation of this AbstractJaxbMojo.
        Specified by:
        addResource in class AbstractJaxbMojo
        Parameters:
        resource - The resource to add.