问题描述
我有以下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文件)。
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).
在旁注中,为什么maven同时拥有< sourceDirectory>
标签和maven编译器插件上的< include>
标签?它们似乎是多余的(除了include标签允许多个源目录)。
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).
推荐答案
如何使用最新版本进行尝试删除< includes> maven编译器插件
, 2.3.2
/ code> < configuration>
其他人指出的部分?
How about trying this with the latest version of maven compiler plugin
, which is 2.3.2
after removing the <includes>
<configuration>
section as indicated by others?
无论如何,我认为< includes>
将是< sourceDirectory>
内的过滤器,因此无法拥有 src / web
再次指定。
In any case, I think <includes>
would be a filter within the <sourceDirectory>
and thus cannot have src/web
specified again.
这篇关于Maven制作空JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!