gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 22:19:02 27 4
gpt4 key购买 nike

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com