java - 如何使用 Maven 插件在构建路径中添加多个生成的文件夹

标签 java jaxb maven-plugin

generated files

我正在尝试从多个 xsd 生成 Java 类,并希望将其添加到构建路径中,但只有一个包(即 xjc)添加而不是全部(xjc08 和 xjc09) 下面是pom.xml

            <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.14.0</version>
            <executions>
                <execution>
                    <id>schema-generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>src/main/resources</schemaDirectory>
                        <schemaIncludes>
                            <include>text.xsd</include>
                        </schemaIncludes>
                        <generatePackage>com.model</generatePackage>
                        <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>


                    </configuration>

                </execution>
                <execution>
                    <id>schema2-generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>src/main/resources</schemaDirectory>
                        <schemaIncludes>
                            <include>test1.xsd</include>
                        </schemaIncludes>
                        <generatePackage>com.model1</generatePackage>
                        <generateDirectory>${project.build.directory}/generated-sources/xjc08</generateDirectory>

                    </configuration>
                </execution>
                <execution>
                    <id>schema3-generate</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <schemaDirectory>src/main/resources</schemaDirectory>
                        <schemaIncludes>
                            <include>Test2.xsd</include>
                        </schemaIncludes>
                        <generatePackage>com.model2</generatePackage>

     <generateDirectory>${project.build.directory}/generated- 
     sources/xjc09</generateDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

请告知需要做什么才能在构建路径中添加整个目标文件夹。

最佳答案

在 pom.xml 中添加以下插件后尝试。只需指定生成 java 类的目录即可。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
      <execution>
        <id>add-source</id>
        <phase>generate-sources</phase>
        <goals>
          <goal>add-source</goal>
        </goals>
        <configuration>
          <sources>
            <source>some directory</source>     
          </sources>
        </configuration>
      </execution>
    </executions>
  </plugin>

或者

<build>
    <sourceDirectory>.</sourceDirectory>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
        <includes>
            <include>src/main/java/**/*.java</include>
            <include>src/main2/java/**/*.java</include>
        </includes>
        </configuration>
        </plugin>
    </plugins>
</build>

关于java - 如何使用 Maven 插件在构建路径中添加多个生成的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58605851/

相关文章:

javax 和 @XmlElementRef 以及扩展容器

maven-2 - 如何使用 Maven 执行程序?

java - 将完整的 Maven 远程存储库下载到本地存储库?

javafx 8 : How to update TreeCell in TreeView on SlectedItemProperty Change

Java:随机生成的零数

java - 如何使用 JAXB 输出对象集合?

java - 如何解码 FaultMessageResolver 中的 SOAP 错误?

java - 你如何强制 Maven MOJO 在构建结束时只执行一次?

java - 通过提供视频路径获取视频缩略图的路径

java - OnFrameAvailable 回调未到来