重命名由tycho-p2-director-plugin创建的ZIP文件

时间:2011-12-21 00:51:50

标签: eclipse maven-3 tycho

tycho-p2-director-plugin似乎没有办法在最终的ZIP文件名中添加版本号。它产生

myproduct-win32.win32.x86.zip
myproduct-macosx.cocoa.x86.zip
myproduct-linux.gtk.x86.zip

虽然我想

myproduct-1.6.0-win32.zip
myproduct-1.6.0-linux32.zip
myproduct-1.6.0-macos.zip

最好的方法是什么?不知何故用maven-antrun-plugin重命名?用maven资源插件重命名?什么东西?

3 个答案:

答案 0 :(得分:9)

https://bugs.eclipse.org/bugs/show_bug.cgi?id=357503的错误报告中,他们似乎已经添加了直接从Tycho 0.14.0更改zip文件的文件名的功能。我将以下内容用于我的tycho-p2-director-plugin块。

<plugins>
  <plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-p2-director-plugin</artifactId>
    <version>0.16.0</version>
    <executions>
      <execution>
        <id>materialize-products</id>
        <goals>
          <goal>materialize-products</goal>
        </goals>
      </execution>
      <execution>
        <id>archive-products</id>
        <goals>
          <goal>archive-products</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <products>
        <product>
          <id>MY_PRODUCT_ID</id>
          <archiveFileName>MyProduct-${project.version}</archiveFileName>
        </product>
      </products>
    </configuration>
  </plugin>

关键位位于末尾的<configuration>部分,您可以使用<archiveFileName>标记指定zip文件的前缀。人们可能希望文件的后缀仍为-<os>.<ws>.<arch>.<archiveExtension>

答案 1 :(得分:1)

以下是我在项目中的工作,

        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-p2-director-plugin</artifactId>
            <version>${tycho-version}</version>
            <executions>
                <execution>
                    <id>materialize-products</id>
                    <goals>
                        <goal>materialize-products</goal>
                    </goals>
                    <configuration>
                        <installFeatures>false</installFeatures>
                        <profile>Installer</profile>
                    </configuration>
                </execution>
                <execution>
                    <id>archive-products</id>
                    <goals>
                        <goal>archive-products</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- ANT actions -->
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <!-- Rename the ZIP files -->
                <execution>
                    <id>update-zip-files</id>
                    <phase>install</phase>
                    <configuration>
                        <target>
                            <!-- Rename the products -->
                            <move verbose="true" todir="${project.build.directory}/products">
                                <mapper type="regexp" from="^(Installer-)(.*)$$"
                                    to="\1N-${maven.build.timestamp}-\2" />

                                <fileset dir="${project.build.directory}/products">
                                    <include name="*.zip" />
                                </fileset>
                            </move>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

答案 2 :(得分:-1)

答案不是第谷特定的:

<build>
    <finalName>myproduct</finalName>
</build>