Maven-Assembly-plugin 步骤失败:"[WARNING] The following patterns were never triggered in this artifact i



我正在尝试向我的多模块添加全局版本属性Maven项目,以便我可以轻松更新所有版本通过更新单个属性而不是几个POM来模块文件。问题是该属性正在破坏Maven-将编译模块罐收集到拉链中用于分发的文件夹。当该版本都被硬编码时POM文件,一切都在游泳。当我转换为但是,一个属性,单个模块罐仍在编译中,但是,在以下情况之后警告:" [警告]以下模式从未触发在此工件包容过滤器中"

组装过滤器似乎缺少模块,我只是无法解释为什么当我使用全球属性或如何使用时会发生这种情况修复它。

项目结构:

    MyProject
        --ModuleA
          pom.xml
        --ModuleB
          pom.xml
        --Distribution
          srcmainassemblydistribution-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>

modulea/pom.xml:

    <parent>
        <artifactId>MyProject</artifactId>
        <groupId>com.mycompany</groupId>
        <version>${global.version}</version>
    </parent>
    <artifactId>ModuleA</artifactId>

moduleb/pom.xml:

    <parent>
        <artifactId>MyProject</artifactId>
        <groupId>com.mycompany</groupId>
        <version>${global.version}</version>
    </parent>
    <artifactId>ModuleB</artifactId>

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

Distribution/src/main/assembly/assigtrbly/distribution-sembly.xml:

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

尝试添加您的模块和模块作为发行pom的依赖。

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

相关内容

最新更新