Search code examples
eclipsemaven-3tycho

rename ZIP files created by tycho-p2-director-plugin


tycho-p2-director-plugin does not seem to have a way to add a version number to the final ZIP file names. it produces

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

while I'd like to have

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

what's the best way? rename with maven-antrun-plugin somehow? rename with maven resources plugin? anything elese?


Solution

  • Below is what I do in my project,

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