[英]Maven Source Plugin - How do I generate the source jar for ONLY the classes I want included
Currently, the project I am working on has all of the code for the web service in a single and is creating a war and a jar file. 当前,我正在处理的项目将Web服务的所有代码都集成在一个文件中,并且正在创建war和jar文件。
The Jar file only contains the bare minimum of classes shared by other projects. Jar文件仅包含其他项目共享的最少类。
I don't have the option to split the shared classes out into a separate core project at this time. 我目前无法选择将共享类拆分为一个单独的核心项目。 (Though I would prefer that)
(尽管我更喜欢)
I'm trying to put only the necessary java files in the source jar: 我试图将仅必要的java文件放在源jar中:
Common_Model-1.1.2.jar
Common_Model-1.1.2.jar-sources
I have something like this in my POM: 我的POM中有这样的内容:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<includes>
<include>gov/app/api/common/models/**</include>
<include>gov/app/api/intra/models/**</include>
<include>gov/app/api/models/**</include>
</includes>
<finalName>Common_Model-1.1.2</finalName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<includes>
<include>gov/app/api/common/models/**</include>
<include>gov/app/api/intra/models/**</include>
<include>gov/app/api/models/**</include>
</includes>
<finalName>Common_Model-1.1.2</finalName>
</configuration>
</execution>
</executions>
</plugin>
While this does create the sources jar, it ignores the includes configuration and adds all of the .java files from the entire project. 尽管这确实创建了源jar,但它忽略了include配置并添加了整个项目中的所有.java文件。
I've also tried using <excludes>
, but that too is ignored. 我也尝试过使用
<excludes>
,但这也被忽略了。
I tried this in my project: 我在我的项目中尝试过:
<include>com/sandbox/**/Permutations*</include>
And the resulting Common_Model-1.1.2-sources.jar only had this one file in it named Permutations.java When I tried 当我尝试时,生成的Common_Model-1.1.2-sources.jar中只有一个名为Permutations.java的文件。
<include>com/sandbox/Permutations*</include>
<include>com/sandbox/Sandbox*</include>
The jar had only those two files. 罐子只有两个文件。 So what you've got should work.
因此,您所拥有的应该可以工作。 I suspect your patterns are too broad.
我怀疑您的模式太宽泛了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.