简体   繁体   English

Maven程序集插件不排除存档中的资源

[英]Maven assembly plugin not excluding resources from archive

I have some properties and XML files in my src/main/resources directory of my maven project. 我的Maven项目的src / main / resources目录中有一些属性和XML文件。 I would like to exclude these files 我想排除这些文件

When building the binary, none of these files are being excluded even though I have set them up that way. 构建二进制文件时,即使我以这种方式进行设置,也不会排除所有这些文件。 I don't know what I am doing wrong. 我不知道我在做什么错。

My pom.xml set up 我的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 set up 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>

I am executing mvn package assembly:single command to do the same. 我正在执行mvn package assembly:single命令来执行相同的操作。

The error logs 错误日志

[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:

could you explain what's your ${basedir}? 您能解释一下您的$ {basedir}吗? It's an property to filter by maven resource process? 这是按Maven资源过程过滤的属性吗? then, you have to know: it's useless to exclue files unser src, it's not relative to generated artifact, you should replace them with target/classes/your-package. 然后,您必须知道:取消文件unser src没用,它与生成的工件无关,您应该将它们替换为target / classs / your-package。

here is an reference, it might no work, but you can learn how to config the 这是参考,可能没有用,但是您可以学习如何配置

    <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM