Maven Plugin
Executing the plugin
The maven plugin is part of the xmlbeans artifact starting with XmlBeans 5.0.0. You can invoke it via the following POM example.
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>de.kiwiwings</groupId>
<artifactId>toomany</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.2.1</version>
<executions><execution><goals><goal>compile</goal></goals></execution></executions>
<configuration>
<repackage>my.company.project.metadata</repackage>
<name>MySchema</name>
<partialMethods>ALL,-GET_LIST,-XGET_LIST,-XGET_ARRAY</partialMethods>
<mdefNamespaces>
<mdefNamespace>schubidubi</mdefNamespace>
</mdefNamespaces>
<extensions>
<extension>
<className>org.apache.xmlbeans.impl.tool.Extension</className>
<params>
<param>
<name>name</name>
<value>value</value>
</param>
</params>
</extension>
</extensions>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.23.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.2.1</version>
</dependency>
</dependencies>
</project>
Default file layout
If not otherwise specified the *.xsd,*.wsdl will be looked up in ${basedir}/src/main/schema
The source files will be generated into ${basedir}/target/generated-sources.
The resources incl. the TypeSystemHolder class will be generated into ${basedir}/target/generated-resources.
The generated sources and resources will be added to the project resources on-the-fly, so there's no additional configuration necessary.
Configuration parameters
The current supported option of the plugin can be retrieved via ...:
mvn xmlbeans.plugin:help -Ddetail=true -Dgoal=compile
Example output:
xmlbeans.plugin:compile
Available parameters:
project (Default: ${project})
reference to the project
Required: Yes
baseSchemaLocation (Default: schemaorg_apache_xmlbeans/src)
destination directory of the copied xsd files
buildSchemas (Default: true)
buildSchemas sets build process of the generated sources
catalogLocation
catalogLocation is the location of an entity resolver catalog to use for
resolving namespace to schema locations.
classPath
Comma-separated list of jars and class folders
classTargetDir (Default: ${project.basedir}/target/generated-resources)
classTargetDir is where you want compiled class files to appear
javaTargetDir (Default: ${project.basedir}/target/generated-sources)
javaTargetdir is where you want generated java source to appear
resources
Singleton list containing the output directory for resources (output only,
i.e. inputs are overridden)
sourceDir (Default: ${project.basedir}/src/main/schema)
sourceDir is a base directory for the list in sourceschema
sourceSchemas (Default: *.xsd,*.wsdl,*.java)
sourceSchemas is a comma-delimited list of all the schemas you want to
compile
xmlConfigs (Default: ${project.basedir}/src/schema/xmlconfig.xml)
xmlConfigs points to your xmlconfig.xml file
name (Default: ${project.artifactId})
schema system name
repackage (Default: ${project.groupId}.${project.artifactId}.metadata)
Metadata package name. If explicitly set empty, generates to
org.apache.xmlbeans.metadata
mdefNamespaces
If this option is set, then the schema compiler will permit and
ignore multiple definitions of the same component (element, attribute,
type, etc) names in the given namespaces. If multiple definitions
with the same name appear, the definitions that happen to be processed
last will be ignored.
Format:
<mdefNamespaces>
<mdefNamespace>http://lazy.dev/duplicated/namespace</mdefNamespace>
<mdefNamespaces>
partialMethods
Only generate a subset of the bean methods. Comma-seperated list of the
following method types:
GET, XGET, IS_SET, IS_NIL, IS_NIL_IDX, SET, SET_NIL, SET_NIL_IDX, XSET,
UNSET,
GET_ARRAY, XGET_ARRAY, GET_IDX, XGET_IDX, XSET_ARRAY, XSET_IDX,
SIZE_OF_ARRAY, SET_ARRAY, SET_IDX,
INSERT_IDX, INSERT_NEW_IDX,
ADD, ADD_NEW, REMOVE_IDX,
GET_LIST, XGET_LIST, SET_LIST,
INSTANCE_TYPE
Example: "ALL,-GET_LIST,-XGET_LIST" excludes GET_LIST and XGET_LIST
methods
verbose (Default: false)
verbose output
quiet (Default: true)
no output
noUpa (Default: false)
deactivate unique particle attribution
noPvr (Default: false)
deactivate particle valid (restriction)
noAnn (Default: false)
deactivate annotation generation
noVDoc (Default: false)
do not validate contents of documentation-tags
download (Default: false)
permit network downloads for imports and includes
debug (Default: false)
compile with debug symbols
sourceOnly (Default: true)
do not compile .java files or jar the output
basedir
basedir of the source files - defaults to the directory of the first
source file
compiler
path to the javac compiler
memoryInitialSize (Default: 8m)
initial memory for external java compiler
memoryMaximumSize (Default: 256m)
maximum memory for external java compiler
outputJar (Default:
${project.basedir}/target/${project.artifactId}-${project.version}-xmltypes.jar)
the name of the output jar
extensions
(experimental) registers a schema compiler extensions implementing
org.apache.xmlbeans.impl.tool.SchemaCompilerExtension
Example:
<extensions>
<extension>
<className>org.custom.MySchemaCompilerExtension</className>
<params>
<param>
<name>name</name>
<value>value</value>
</param>
</params>
</extension>
</extensions>