Maven 生成空 JAR
我有以下 pom 文件:
<build>
<defaultGoal>package</defaultGoal>
<sourceDirectory>src/web</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<includes>
<include>src/web/**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
我的源文件位于 src/web/org/myCompany/ 文件夹中。当我运行 pom 文件时,我生成了一个没有类文件的 JAR。我指定源目录的方式有什么问题?我没有收到任何错误消息,只是一个空 JAR(带有一些 META-INF 文件)。
顺便说一句,为什么maven在maven编译器插件上同时具有
标签和
标签?它们似乎是多余的(除了 include 标记允许多个源目录)。
I have the following pom file:
<build>
<defaultGoal>package</defaultGoal>
<sourceDirectory>src/web</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<includes>
<include>src/web/**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
My source files are in the src/web/org/myCompany/ folder. When I run the pom file, I get a JAR generated with no class files. What is wrong with the way that I specified the source directories? I do not get any error messages, just an empty JAR (with some META-INF files).
On a sidenote, why does maven have both the <sourceDirectory>
tag and the <include>
tag on the maven compiler plugin? They seem to be redundant (except that the include tag allows multiple source directories).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用最新版本的
maven 编译器插件
(删除< 后的
部分如其他人所示?2.3.2
怎么样? ;configuration>无论如何,我认为
将是
中的过滤器,因此不能再次指定src/web
。How about trying this with the latest version of
maven compiler plugin
, which is2.3.2
after removing the<includes>
<configuration>
section as indicated by others?In any case, I think
<includes>
would be a filter within the<sourceDirectory>
and thus cannot havesrc/web
specified again.如果没记错的话,你不需要包含这些内容。 sourceDirectory 规范应该足够了。然后运行
If memory serves you don't need the includes. The sourceDirectory specification should be enough. Then run