简体   繁体   English

使用jaxb2-maven-plugin运行schemagen时,可以包含多个项目的Java源代码吗?

[英]Can I include java source from multiple projects when running schemagen using the jaxb2-maven-plugin?

I have a multi module maven project and I need to build an XML schema from JaxB annotated classes. 我有一个多模块maven项目,我需要从JaxB注释类构建XML模式。 These classes are in different maven projects. 这些类在不同的Maven项目中。 Can I use the jaxb2-maven-plugin to generate a single schema by pointing at the source from all of the projects? 我可以使用jaxb2-maven-plugin通过指向所有项目的源代码来生成单个模式吗? Perhaps like this ... 也许像这样...

<configuration>
    ...
    <includes>    
        <include>../OtherProj1/src/main/java/**/*.java</include>
        <include>../OtherProj2/src/main/java/**/*.java</include>
        <include>**/*.java</include>
    </includes>
    ...
</configuration>

Or do I need to create a schema for each project individually and then import them into a parent schema instead? 还是我需要为每个项目分别创建一个架构,然后将其导入父架构?

I am using maven 2.2.1 and jaxb2-maven-plugin 1.3. 我正在使用Maven 2.2.1和jaxb2-maven-plugin 1.3。

I think the antrun plugin is the only way to include sources from outside of the mvn project for generating the XML schema. 我认为antrun插件是包含来自mvn项目外部的源以生成XML模式的唯一方法。

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <configuration>
                <target>                        
                    <taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask">
                    </taskdef>
                    <schemagen destdir="src/main/resources/" includes="<comma separated paths to include>"
                        excludes="<comma separated paths to exclude>">
                        <src path="src/main/java" />
                        <src path="../OtherProj1/src/main/java" />
                        <src path="../OtherProj2/src/main/java" />                  
                    </schemagen>
                    <move file="src/main/resources/schema1.xsd" tofile="src/main/resources/<filename>.xsd" />
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

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

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