Fork me on GitHub

The following is an example of a Maven configuration for this plugin.

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>my.group</groupId>
	<artifactId>my-library</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>An example project</name>

	<build>
		<plugins>
			<plugin>
				<groupId>dev.metaschema.java</groupId>
				<artifactId>metaschema-maven-plugin</artifactId>
				<version>3.0.0.M2</version>
				<executions>
					<execution>
						<id>generate-model-sources</id>
						<goals>
							<goal>generate-sources</goal>
						</goals>
						<configuration>
							<!-- defines where to find the Metaschemas to generate Java classes from -->
							<metaschemaDir>${project.build.directory}/src/main/metaschema</metaschemaDir>
							<!-- defines which metaschema in the above directory to use -->
							<includes>
								<include>*_metaschema.xml</include>
							</includes>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

When using binding configuration to specify custom superinterfaces or base classes for generated code, those classes must be available on the plugin's classpath during code generation.

The code generator uses reflection to:

  1. Detect method overrides - Check if getter/setter methods are declared in superinterfaces to add @Override annotations
  2. Determine IBoundObject extension - Check if configured superinterfaces extend IBoundObject to avoid adding redundant interface declarations

If the classes are not on the classpath, you will see warnings during code generation, and the generated code may have missing @Override annotations or redundant interface declarations.

To make custom interfaces available during code generation, add them as plugin dependencies:

<plugin>
	<groupId>dev.metaschema.java</groupId>
	<artifactId>metaschema-maven-plugin</artifactId>
	<version>3.0.0.M2</version>
	<executions>
		<execution>
			<id>generate-model-sources</id>
			<goals>
				<goal>generate-sources</goal>
			</goals>
			<configuration>
				<configs>
					<config>src/main/metaschema-bindings/bindings.xml</config>
				</configs>
			</configuration>
		</execution>
	</executions>
	<!-- Add dependencies containing custom interfaces/base classes -->
	<dependencies>
		<dependency>
			<groupId>com.example</groupId>
			<artifactId>my-interfaces</artifactId>
			<version>1.0.0</version>
		</dependency>
	</dependencies>
</plugin>

When the superinterface is defined in another module of the same project, ensure that module is built before code generation runs. You can use Maven's reactor build order by declaring appropriate dependencies, or use a multi-phase build approach.