在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):davidmoten/jax-maven-plugin开源软件地址(OpenSource Url):https://github.com/davidmoten/jax-maven-plugin开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):jax-maven-pluginStatus: released to Maven Central Features
Constraints
HistoryThe development of this plugin was motivated by problems with the jaxb2-maven-plugin with Java 9+. My company's codebase used jaxb2-maven-plugin in ~15 locations (the What about exec-maven-plugin?It is possible to use exec-maven-plugin to call
Instead of these poor options, use jax-maven-plugin! How to build
Getting startedXJC exampleHere's an <properties>
<jaxb.generated>${project.build.directory}/generated-sources/jaxb</jaxb.generated>
</properties>
...
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<executions>
<execution>
<id>xjc-generate-from-dtd</id>
<!-- generate sources from the java.util.logging DTD -->
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<systemProperties>
<enableExternalEntityProcessing>true</enableExternalEntityProcessing>
</systemProperties>
<jvmArguments>
<jvmArgument>-Xms32m</jvmArgument>
</jvmArguments>
<arguments>
<!-- These are the arguments you would normally
have put with a call to xjc -->
<argument>-verbose</argument>
<argument>-d</argument>
<argument>${jaxb.generated}</argument>
<argument>-p</argument>
<argument>dummy</argument>
<argument>-dtd</argument>
<argument>${project.basedir}/src/main/dtd/logger.dtd</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- OPTIONAL -->
<!-- ensure the generated sources are detected by Eclipse and other IDEs -->
<!-- the plugin will by default add generated sources to the compile source path -->
<!-- and generated resources to the built artifact but an IDE does not know -->
<!-- that this happened. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${jaxb.generated}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin> OutputHere's sample output from the plugin:
Note that the If you want more detail including all classpath items for the mvn clean install -X Examples for wsgen, wsimport, schemagenSee the relevant executions for jax-maven-plugin in the unit test project pom.xml. Configuration options for the pluginAbove are examples of ArgumentsSee the Java 8 documentation for descriptions of the arguments to pass to tools using the plugin. Note that if you don't specify the destination directories for generated code and resources then the generated files will be placed in the root of the project directory. In short, always specify those parameters. schemagenThe <plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<executions>
<execution>
<id>schemagen-source-option</id>
<phase>generate-sources</phase>
<goals>
<goal>schemagen</goal>
</goals>
<configuration>
<classpathScope>compile</classpathScope>
<sources>
<source>${basedir}/src/main/java</source>
</sources>
<arguments>
<argument>-d</argument>
<argument>${jaxb.generated}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin> Using JAXB extensionsNote: only valid pre migration to Jakarta dependencies. To use jaxb2-basics you'll need to use version 0.1.8 of jax-maven-plugin. version 0.2 of jax-maven-plugin is not compatible with jaxb2-basics. If you add dependencies to the classpath used by <plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>1.11.1</version>
</dependency>
</dependencies>
<executions>
...
</executions>
</plugin> A fully worked example that generates A big thank you to @Glebcher601 for contributing extension support! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论