How to create java classes in source folder using jaxb2-maven-plugin?

I am using jaxb2-maven-plugin to create Java classes. Plugin Properties:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>2.3</version> <executions> <execution> <id>xjc</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <!-- The package of your generated sources --> <packageName>com.bcap.me.JaxB</packageName> <sources> <source>src/main/resources/xsds/pos.xsd</source> </sources> </configuration> </plugin> 

After running mvn clean compile plugin creates classes in the target\classes\com\bcap\me\JaxB . But I need to have classes in the source folder (package): src\main\java\com\bcap\me\JaxB How to do this?

UPDATE I am adding the outputDirectory property, but I'm not sure if this approach is correct:

 <!--<packageName>com.bcap.me.JaxB</packageName>--> <outputDirectory>src/main/java/com/bcap/me/JaxB</outputDirectory> 

UPDATE

I solved my case like:

  <execution> <id>xjc_pos</id> <goals> <goal>xjc</goal> </goals> <configuration> <!-- The package of your generated sources --> <packageName>com.bcap.me.JaxB</packageName> <outputDirectory>src/main/java</outputDirectory> <sources> <source>src/main/resources/xsds/pos.xsd</source> </sources> <generateEpisode>false</generateEpisode> <clearOutputDir>false</clearOutputDir> </configuration> </execution> 

Thanks @ulab

+6
source share
1 answer

You can use the following maven plugin

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>target/generated-sources/xjc</source> </sources> </configuration> </execution> </executions> </plugin> 
0
source

Source: https://habr.com/ru/post/1014965/


All Articles