How can I get tycho materialize-product and archive-product to use a directory prefix for my RCP app archive file

StackOverflow https://stackoverflow.com/questions/18365235

  •  26-06-2022
  •  | 
  •  

Question

How can I add a prefix directory so when I unpack the zip containing my RCP app I get a directory containing the contents?

When tycho materalizes and archives my rcp app it zips up target/products/my.rcp.app/linux/gtk/x86_64/ contents without a directory prefix.

Current zip contents:

  • ./features
  • ./plugins
  • ...

Desired zip contents:

  • ./myapp/features
  • ./myapp/plugins
  • ...

When a user unpacks the zip, I'd like the app directory to be created. I looked through the tycho docs but neither archive nor materialize seems the right place to configure this. I could always use antrun or assembly plugin to do the work but that doesn't feel like the right maven way to solve the problem.

Please let me know how to add a prefix directory.

Was it helpful?

Solution

The configuration is really a bit messed up and not really documented. Since you (currently) can have multiple product files in one eclipse-repository module, you need to select the product ID for which you want to apply the configuration.

So to set the archive root folder for the product with ID product.id, you need the following configuration:

<build>
  <plugins>
    <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>
        </execution>
        <execution>
          <id>archive-products</id>
            <goals>
              <goal>archive-products</goal>
            </goals>
        </execution>
      </executions>
      <configuration>
        <products>
          <product>
            <id>product.id</id>
            <rootFolder>myapp</rootFolder>
          </product>
        </products>
      </configuration>
    </plugin>
  </plugins>
</build>

OTHER TIPS

Thanks but I needed to use the rootFolder option to add the extra directory. I tried injecting achivePrefix into the .product file but that didn't work. I finally broken down, grabbed tycho source and worked backwards to find rootFolder. After this journey, I saw it in the doc and grocked the meaning.

Doc: http://wiki.eclipse.org/Tycho/Packaging_Types#Creating_Product_Zip_Files

Related: https://issues.sonatype.org/browse/TYCHO-507

        <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-p2-director-plugin</artifactId>
            <version>${tycho-version}</version>
            <configuration>
            <products>
              <product>
         <id>match-product-uid-field-from-foo.product-file</id>
         <rootFolder>workbench</rootFolder>
                </product>
          </products>
            </configuration>
            <executions>
                <execution>
                    <!-- install the product using the p2 director -->
                    <id>materialize-products</id>
                    <goals>
                        <goal>materialize-products</goal>
                    </goals>
                </execution>
                <execution>
                    <!-- create zip file with the installed product -->
                    <id>archive-products</id>
                    <goals>
                        <goal>archive-products</goal>
                    </goals>
                    <configuration>
                        <formats>
                            <linux>tar.gz</linux>
                            <win32>zip</win32>
                        </formats>                          
                    </configuration>
                </execution>
            </executions>
        </plugin>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top