【问题标题】:rename ZIP files created by tycho-p2-director-plugin重命名 tycho-p2-director-plugin 创建的 ZIP 文件
【发布时间】:2011-12-21 00:51:50
【问题描述】:

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 资源插件重命名?还有什么?

【问题讨论】:

    标签: eclipse maven-3 tycho


    【解决方案1】:

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

    关键位在末尾的&lt;configuration&gt; 部分,您可以在其中使用&lt;archiveFileName&gt; 标签指定压缩文件的前缀。该文件的后缀仍然是-&lt;os&gt;.&lt;ws&gt;.&lt;arch&gt;.&lt;archiveExtension&gt;,正如人们所希望的那样。

    【讨论】:

      【解决方案2】:

      以下是我在项目中所做的,

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

      【讨论】:

      【解决方案3】:

      答案不是第谷特有的:

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

      【讨论】:

      • 这是错误的。 Tycho 为“产品”构建提供了一种自定义包装类型。这些工件是由需要自己配置的 Tycho 插件创建的。
      猜你喜欢
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      • 2018-08-14
      • 2011-03-08
      • 1970-01-01
      • 2011-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多