Issue
I am using the schemagen
goal of jaxb2-maven-plugin
to convert Java classes to xsd.
The classes in com.example.entities
& com.example.model
should be converted & the rest of the packages ignored.
How to do this in pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>schemagen</id>
<goals><goal>schemagen</goal></goals>
</execution>
</executions>
</plugin>
Solution
After wading through really odd FileNotFoundException
and ClassNotFoundException
,
I discovered through this StackOverflow answer, that the jaxb2-maven-plugin
has issues with Java 11.
Now, I am using jax-maven-plugin instead, which has simple configuration to include particular folders/packages.
In order to include classes org.examples.models
& org.examples.entities
only, to be converted to xml:
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>0.2</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/org/examples/models</source>
<source>${basedir}/src/main/java/org/examples/entities</source>
</sources>
<arguments>
<argument>-d</argument>
<argument>${jaxb.generated}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Answered By - Nice Books
Answer Checked By - Candace Johnson (JavaFixing Volunteer)