Maven程序集插件未使用finalName通过attach = true进行安装? [英] The maven assembly plugin is not using the finalName for installing with attach=true?

查看:88
本文介绍了Maven程序集插件未使用finalName通过attach = true进行安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置了以下程序集:

I have configured following assembly:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2-beta-5</version>
            <executions>
                <execution>
                    <id>${project.name}-test-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>${project.name}-test</finalName>
                        <filters>
                            <filter>src/assemble/test/distribution.properties</filter>
                        </filters>
                        <descriptors>
                            <descriptor>src/assemble/distribution.xml</descriptor>
                        </descriptors>
                        <attach>true</attach>
                    </configuration>
                </execution>
                <execution>
                    <id>${project.name}-prod-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>${project.name}-prod</finalName>
                        <filters>
                            <filter>src/assemble/prod/distribution.properties</filter>
                        </filters>
                        <descriptors>
                            <descriptor>src/assemble/distribution.xml</descriptor>
                        </descriptors>
                        <attach>true</attach>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这产生了两个压缩文件:

This produced two zip-files:

  • distribution-prod.zip
  • distribution-test.zip

我对属性 attach = true 的期望是,两个zip文件的安装名称均在属性 finalName 中. 但是结果是,仅一个文件被安装(附加)到工件. Maven协议是:

My expectation for the property attach=true is, that the two zip-files are installed with the name as given in property finalName. But the result is, only one file is installed (attached) to the artifact. The maven protocol is:

  • distrib-0.1-SNAPSHOT.zip
  • distrib-0.1-SNAPSHOT.zip

插件正在使用工件ID而不是属性finalName! 这是一个错误吗?

The plugin is using the artifact-id instead of property finalName! Is this a bug?

上次安装将覆盖第一个. 如何安装这两个名称不同的文件?

The last installation is overwriting the first one. What can i do to install this two files with different names?

感谢您的调查. 罗兰(Roland)

Thanks for your investigation. Roland

推荐答案

上次安装将覆盖第一个.如何安装这两个名称不同的文件?

The last installation is overwriting the first one. What can i do to install this two files with different names?

如预期的那样(我不知道这是否是一个错误,但这就是程序集插件的工作方式).为避免这种情况,您必须将appendAssemblyId属性设置为true,并获得等效的结果,才能将finalName更改为${project.name},并将assemby id更改为testprod (即使用两个程序集描述符).像这样:

As expected (I don't know if this is a bug or not but that's how the assembly plugin works). To avoid this, you will have to set the appendAssemblyId properties to true and, to obtain an equivalent result, to change the finalName to ${project.name} and the assemby id to test and prod (i.e. to use two assembly descriptors). Something like this:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-5</version>
      <executions>
        <execution>
          <id>${project.name}-test-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <appendAssemblyId>true</appendAssemblyId>
            <finalName>${project.name}</finalName>
            <filters>
                <filter>src/assemble/test/distribution.properties</filter>
            </filters>
            <descriptors>
              <descriptor>src/assemble/distribution-test.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
        <execution>
          <id>${project.name}-prod-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <appendAssemblyId>true</appendAssemblyId>
            <finalName>${project.name}</finalName>
            <filters>
              <filter>src/assemble/prod/distribution.properties</filter>
            </filters>
            <descriptors>
              <descriptor>src/assemble/distribution-prod.xml</descriptor>
            </descriptors>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

distribution-test.xmldistribution-prod.xml分别声明程序集id testprod的地方.

Where distribution-test.xml and distribution-prod.xml declare assembly id test and prod respectively.

这篇关于Maven程序集插件未使用finalName通过attach = true进行安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆