简体   繁体   English

jaxb2-maven-plugin将classpath添加到生成的源中

[英]jaxb2-maven-plugin add classpath to generated sources

I use the codehaus jaxb-maven-plugin to create java classes from xml schemas: 我使用codehaus jaxb-maven-plugin从xml架构创建java类:

        <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. 这些类按预期生成到target/generated-sources/jaxb ,但此路径未添加到类路径中。

So, if I use some of generated classes in other (not generated) classes, maven cannot found it during the compile process. 因此,如果我在其他(未生成的)类中使用某些生成的类,则maven在编译过程中无法找到它。

Any ideas? 有任何想法吗? TIA! TIA!

It is a bug in the jaxb2-maven-plugin: 这是jaxb2-maven-plugin中的一个错误:

https://github.com/mojohaus/jaxb2-maven-plugin/issues/44 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. 我正在使用插件2.2版运行MacOS El Capitain,如果运行“mvn clean compile”,则会正确生成源路径。 If you subsequently run "mvn compile", then the source path does not include the path to the generated files. 如果随后运行“mvn compile”,则源路径不包括生成文件的路径。

Correct: during first invocation 正确:在第一次调用期间

-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java:/Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/target/generated-sources/jaxb:

Missing jaxb path: 缺少jaxb路径:

-sourcepath /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/src/main/java: -s /Users/nastacio/rsawga-rtc/workspace_trunk/ml-common/target/generated-sources/annotations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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