Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven程序集插件不从存档中排除资源_Java_Maven_Maven Assembly Plugin - Fatal编程技术网

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

Java Maven程序集插件不从存档中排除资源,java,maven,maven-assembly-plugin,Java,Maven,Maven Assembly Plugin,我在maven项目的src/main/resources目录中有一些属性和XML文件。我想排除这些文件 在构建二进制文件时,这些文件都不会被排除,即使我已经这样设置了它们。我不知道我做错了什么 我的pom.xml设置 <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.4.1</version> <configuration

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

你能解释一下你的${basedir}是什么吗?它是由maven资源流程过滤的属性?然后,您必须知道:在src中排除文件是无用的,它与生成的工件无关,您应该用target/classes/your包替换它们

这里是一个参考,它可能不起作用,但您可以学习如何配置

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

分配
罐子
目标/类/通用配置
*.*
target/classes/dotcom-conf
*.*
目标/类/olb配置
*.*

你能准确描述哪些文件/文件夹应该通过maven assembly插件打包,哪些不应该吗?我想排除src/main/resources/olb conf/、src/main/resources/common conf中的所有文件,和src/main/resources/common confi如果您想排除所有这些文件,为什么不将它们放在另一个文件夹中,如
src/main/olb conf
?@khmarbaise Legacy code大约5年前。我不能改变包的结构,因为它破坏了很多东西。我确实试过了。
[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:
    <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>