Source code generation for Java (Maven Plugin)
- 0.4.3 (or later) = Java 11 before namespace change from 'javax' to 'jakarta'
- 0.4.2 (or previous) = Java 8
The project provides a Maven plugin that executes a parse/generate workflow based on the srcgen4j-common/srcgen4j-core projects.
Simply add the plugin to your project's Maven POM and add configuration an dependencies.
<plugin>
<groupId>org.fuin.srcgen4j</groupId>
<artifactId>srcgen4j-maven-plugin</artifactId>
<version>0.4.3-SNAPSHOT</version>
<configuration>
<jaxbClassesToBeBound>
<param>org.fuin.srcgen4j.core.velocity.VelocityGeneratorConfig</param>
<param>org.fuin.srcgen4j.core.velocity.ParameterizedTemplateParserConfig</param>
<param>org.fuin.srcgen4j.core.velocity.ParameterizedTemplateGeneratorConfig</param>
</jaxbClassesToBeBound>
</configuration>
<executions>
<execution>
<id>srcgen4j</id>
<phase>process-sources</phase>
<goals>
<goal>process-template</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.5</version>
</dependency>
</dependencies>
</plugin>
You can also find an example project here: test-project.
To start the generation process in debug mode you can checkout the srcgen4j-maven-app project.
Snapshots can be found on the OSS Sonatype Snapshots Repository.
Add the following to your .m2/settings.xml (section "repositories") to enable snapshots in your Maven build:
<repository>
<id>sonatype.oss.snapshots</id>
<name>Sonatype OSS Snapshot Repository</name>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
An additional entry to the "pluginRepositories" section is also required:
<pluginRepository>
<id>sonatype.oss.snapshots</id>
<name>Sonatype OSS Snapshot Repository</name>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>