【发布时间】:2018-01-22 20:34:21
【问题描述】:
我的 maven 项目的 src/main/resources 目录中有一些属性和 XML 文件。我想排除这些文件
在构建二进制文件时,这些文件都不会被排除,即使我是这样设置的。我不知道我做错了什么。
我的 pom.xml 设置
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/assembly-plugin/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
assembly.xml 设置
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>distribution</id>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources/common-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/dotcom-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/olb-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
我正在执行mvn package assembly:single 命令来做同样的事情。
错误日志
[INFO] Skipping project-jar
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.074s
[INFO] Finished at: Sat Aug 23 13:30:25 PDT 2014
[INFO] Final Memory: 29M/45M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4.1:single (make-assembly) on project project-jar: Failed to create assembly: Error creating assembly archive distribution: You must set at least one file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
【问题讨论】:
-
你能准确描述哪些文件/文件夹应该通过 maven-assembly-plugin 打包,哪些不应该?
-
我要排除 src/main/resources/olb-conf/、src/main/resources/common-conf 和 src/main/resources/common-conf 中的所有文件
-
如果您想排除所有这些文件,为什么不将它们放入不同的文件夹中,例如
src/main/olb-conf? -
@khmarbaise 大约 5 年的旧代码。我无法更改包结构,因为它破坏了很多东西。我试过了。
标签: java maven maven-assembly-plugin