复制,但没有答案,不能对此发表评论
背景信息:我有一个模块,它使用xmlbeans-maven-plugin从xsd生成java源文件并编译到自己的jar中。这可以工作,还可以使用java源创建一个模块1/target/generated文件夹。模块是构建的,但是jar内部有生成的源,这是不必要的,因为xmlbean插件创建了一个单独的jar,保存编译生成的源。
我试图将目标/生成源目录排除在模块的jar工件中。我尝试在maven编译器插件和maven-jar插件中使用target/generated-sources/xmlbeans/noNamespace/**/*.java,但没有成功。
我在这里错过了什么?
下面是模块的pom.xml,如果需要父pom,我也会发布:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent</artifactId>
<groupId>parent</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>workflow</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>WorkFlow processing App</name>
<build>
<finalName>workflow</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<schemaDirectory>src/main/xsd</schemaDirectory>
<outputJar>${build.dir}/lib/WorkflowResponse.jar</outputJar>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin.version}</version>
<configuration>
<source>${compiler.source.version}</source>
<target>${compiler.target.version}</target>
<generatedSourcesDirectory>target</generatedSourcesDirectory>
<!--<includes>-->
<!--<include>src/main/java/**/*.java</include>-->
<!--</includes>-->
<excludes>
<exclude>target/generated-sources/xmlbeans/noNamespace/**/*.java</exclude>
</excludes>
</configuration>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-jar-plugin</artifactId>-->
<!--<version>2.4</version>-->
<!--<configuration>-->
<!--<includes>-->
<!--<include>src/main/java/com/company/appname/*.java</include>-->
<!--</includes>-->
<!--</configuration>-->
<!--</plugin>-->
</plugins>
</build>
*更新*
我设法排除了生成的源,但它很难看,而且不可移植:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<includes>
<include>com/**</include>
</includes>
</configuration>
</plugin>这将只包括目标/classes/com下的内容,在编译之后,以及当maven将模块打包到一个不干净的jar中时。理想情况下,排除应该发生在编译器中,这样就不会将目标/生成的源的内容编译成目标/类/
发布于 2014-10-02 14:15:23
类似于您在更新中使用includes的方式,有一个排除元素可以实现您想要的功能。您只需指明要排除的包,而不是包含包。
http://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html
https://stackoverflow.com/questions/24067295
复制相似问题