Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 assembly插件步骤失败:“[警告]此工件包含筛选器中从未触发以下模式”_Java_Maven_Maven Assembly Plugin - Fatal编程技术网

Java maven assembly插件步骤失败:“[警告]此工件包含筛选器中从未触发以下模式”

Java maven assembly插件步骤失败:“[警告]此工件包含筛选器中从未触发以下模式”,java,maven,maven-assembly-plugin,Java,Maven,Maven Assembly Plugin,我正在尝试向我的多模块添加全局版本属性 Maven项目,使我可以轻松地更新所有版本 通过更新单个属性而不是多个pom来创建模块 文件夹。问题是这个属性正在破坏maven- 将编译模块JAR收集到zip中的汇编插件 用于分发的文件夹。当版本全部硬编码时 pom文件,一切都很顺利。当我转换成 但是,一个属性仍然编译单个模块JAR, 但是maven组装插件步骤在以下步骤之后失败 警告:[警告]以下模式从未触发 在这个工件包含过滤器中 组件过滤器似乎缺少模块,我就是不能 解释当我使用全局属性时为什么会发

我正在尝试向我的多模块添加全局版本属性 Maven项目,使我可以轻松地更新所有版本 通过更新单个属性而不是多个pom来创建模块 文件夹。问题是这个属性正在破坏maven- 将编译模块JAR收集到zip中的汇编插件 用于分发的文件夹。当版本全部硬编码时 pom文件,一切都很顺利。当我转换成 但是,一个属性仍然编译单个模块JAR, 但是maven组装插件步骤在以下步骤之后失败 警告:[警告]以下模式从未触发 在这个工件包含过滤器中

组件过滤器似乎缺少模块,我就是不能 解释当我使用全局属性时为什么会发生这种情况,或者是如何发生的 去修理它

项目结构:

    MyProject
        --ModuleA
          pom.xml
        --ModuleB
          pom.xml
        --Distribution
          src\main\assembly\distribution-assembly.xml
          pom.xml
    pom.xml
MyProject/pom.xml:

    <groupId>com.mycompany</groupId>
    <artifactId>MyProject</artifactId>
    <packaging>pom</packaging>
    <version>${global.version}</version>

    <properties>
        <global.version>1.0.1-SNAPSHOT</global.version>
    </properties>
错误:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly- 
    plugin:2.4:single (make-assembly) on project Distribution: 
    Failed to create assembly: Error creating assembly archive bin: You must 
    set at least one file. -> [Help 1]

尝试将ModuleA和ModuleB添加为分发pom的依赖项

dsibution/pom.xml应如下所示:

<parent>
    <artifactId>MyProject</artifactId>
    <groupId>com.mycompany</groupId>
    <version>${global.version}</version>
</parent>
<packaging>pom</packaging>
<artifactId>Distribution</artifactId>

<dependencies>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>ModuleA</artifactId>
        <version>${global.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>ModuleB</artifactId>
        <version>${global.version}</version>
    </dependency>
</dependencies>

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <descriptors>
          <descriptor>
            src/main/assembly/distribution-assembly.xml
          </descriptor>
        </descriptors>
      </configuration>
      <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
          <goals>
          <goal>
            single
          </goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

你执行什么命令?如何在pom中声明汇编插件?我尝试过mvn clean安装和mvn clean部署,但都失败了。我已经更新了上面的发行版/pom.xml,以展示如何声明插件。
    <parent>
        <artifactId>MyProject</artifactId>
        <groupId>com.mycompany</groupId>
        <version>${global.version}</version>
    </parent>
    <packaging>pom</packaging>
    <artifactId>Distribution</artifactId>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <descriptors>
            <descriptor>
              src/main/assembly/distribution-assembly.xml
            </descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>
                single
              </goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
    <id>bin</id>
    <formats>
      <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <moduleSets>
      <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <includes>
          <include>com.mycompany:ModuleA</include>
          <include>com.mycompany:ModuleB</include>
        </includes>
        <binaries>
          <outputDirectory>MyBuildFolder</outputDirectory>
          <outputFileNameMapping>mycompany${module.artifactId}.${module.extension}</outputFileNameMapping>
          <unpack>false</unpack>
         </binaries>
       </moduleSet>
     <moduleSets>
    [WARNING] The following patterns were never triggered in this artifact 
    inclusion filter:
    o  'com.mycompany:ModuleA'
    o  'com.mycompany:ModuleB'
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly- 
    plugin:2.4:single (make-assembly) on project Distribution: 
    Failed to create assembly: Error creating assembly archive bin: You must 
    set at least one file. -> [Help 1]
<parent>
    <artifactId>MyProject</artifactId>
    <groupId>com.mycompany</groupId>
    <version>${global.version}</version>
</parent>
<packaging>pom</packaging>
<artifactId>Distribution</artifactId>

<dependencies>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>ModuleA</artifactId>
        <version>${global.version}</version>
    </dependency>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>ModuleB</artifactId>
        <version>${global.version}</version>
    </dependency>
</dependencies>

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <descriptors>
          <descriptor>
            src/main/assembly/distribution-assembly.xml
          </descriptor>
        </descriptors>
      </configuration>
      <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
          <goals>
          <goal>
            single
          </goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>