Eclipse maven 插件 (m2e) 包含意外文件



我正在处理 eclipse 中的一个 maven 项目。当我使用"运行As->Maven安装"运行时,jar会正确生成到目标文件夹中。但是我检测到目标jar的大小与通过命令行构建项目的大小不同:

mvn clean install

我已经比较了两个 jar 文件,我看到由 eclipse 创建的 jar 包含的文件不在用 commad 行生成的 jar 中。所有文件都放入许多包中的src文件夹中。例如:/src/main/java/Dummy/resources/file.pdf

文件扩展名包含在 jar 文件生成的 Eclipse: bd cer cfg 类 css cvsignore DLD gitignore htm jar jardesc jasper jrxml MF odt pdf properties sql txt wsdd xml xsl

使用命令行生成的jar文件中包含的文件扩展名:类MF属性xml

我只需要:类,MF,属性,xml,cfg和xsl扩展

我在 https://github.com/RubenPozoMolina/49939684 中创建了一个示例

该项目包含 src/main/resources/test.pdf 和 src/main/java/dummy/iddummy/resources/test.odt

使用 Eclipse iddummy-0.0.1-SNAPSHOT.jar 包含 test.odt 文件使用命令行 test 执行.odt文件不在 jar 文件中

如何配置要包含在 eclipse 中的文件?

您的文件夹中有非 Java 文件src/main/java。 他们需要在其他地方。

为了确保罐子中包含的文件,我用以下方法修改了我的pom:

<build>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>**/*.MF</include>
<include>**/*.cfg</include>
<include>**/*.properties</include>
<exclude>**/*.xml</exclude>
<exclude>**/*.xsl</exclude>
</includes>
<excludes>
<exclude>**/*.bd</exclude>
<exclude>**/*.cer</exclude>
<exclude>**/*.cvsignore</exclude>
<exclude>**/*.css</exclude>
<exclude>**/*.htm</exclude>
<exclude>**/*.gitignore</exclude>
<exclude>**/*.jardesc</exclude>
<exclude>**/*.jasper</exclude>
<exclude>**/*.jrxml</exclude>
<exclude>**/*.sql</exclude>
<exclude>**/*.wsdd</exclude>
<exclude>**/*.odt</exclude>
<exclude>**/*.pdf</exclude>
</excludes>
</resource>
</resources>
</build>

现在 eclipse 和 maven 通过命令行生成的文件是相同的

最新更新