简体   繁体   中英

jaxb2-maven-plugin add classpath to generated sources

I use the codehaus jaxb-maven-plugin to create java classes from xml schemas:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/my.xsd</source>
                        </sources>                           
                            <packageName>mypackage</packageName>
                    </configuration>
                </execution>
            </executions>
         </plugin>

The classes are generated as expected to target/generated-sources/jaxb , but this path is not added to the classpath.

So, if I use some of generated classes in other (not generated) classes, maven cannot found it during the compile process.

Any ideas? TIA!

It is a bug in the jaxb2-maven-plugin:

https://github.com/mojohaus/jaxb2-maven-plugin/issues/44

I am running MacOS El Capitain, with version 2.2 of the plugin, if you run "mvn clean compile", the sourcepath is generated correctly. If you subsequently run "mvn compile", then the source path does not include the path to the generated files.

Correct: during first invocation

-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java::

Missing jaxb path:

-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM