我的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:
答案 0 :(得分:0)
你能解释一下你的$ {basedir}是什么吗?它是通过maven资源进程过滤的属性?然后,你必须知道:删除文件不能用src,它与生成的工件无关,你应该用target / classes / your-package替换它们。
这是一个参考,它可能没用,但你可以学习如何配置
<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>target/classes/common-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/classes/dotcom-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/classes/olb-conf</directory>
<outputDirectory></outputDirectory>
<excludes>
<exclude>*.*</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>