Search code examples
javaeclipsemaventycho

How to insert a file in a specific target file


I've an osgi server, developed under eclipse, that runs on windows, macosx and linux. Tycho and maven are doing the target building configuration for theses platforms perfectly.

Now, I need to insert a startup.sh or startup.bat in the final .zip file according to the final os + ws and arch plateform. Is there something like a "configuration.environments.environment.os" and so on maven variables I could use to copy my scripts folder next to the product target folder like this:

delivery_folder/
->x86_64/
->scripts/

Here's an extract of the product pom file:

<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>install</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/products/${project.artifactId}/${configuration.environments.environment.os}</outputDirectory>
              <resources>          
                <resource>
                  <directory>scripts</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>              
            </configuration>            
          </execution>
        </executions>
      </plugin>

I'd like to use Tycho target-environnement mechanism.

I've setup Tycho with:

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
 <configuration>
 <environments>
    <environment>
    <os>linux</os>
    <ws>gtk</ws>
    <arch>x86_64</arch>
 </environment>
 <environment>
    <os>win32</os>
    <ws>win32</ws>
    <arch>x86</arch>
 </environment>
 <environment>
    <os>win32</os>
    <ws>win32</ws>
    <arch>x86_64</arch>
 </environment>
 <environment>
    <os>macosx</os>
    <ws>cocoa</ws>
    <arch>x86_64</arch>
    </environment>
 </environments>
</configuration>
 </plugin>

Thank you for your help


Solution

  • Rather than using the rather low-level maven-resoures-plugin, you can also use PDE-style rootfiles, which allow platform-specific files to be included in an eclipse-repository (which I assume is the packaging type producing your ZIP):

    root.win32.win32.x86=rootfiles
    

    See the Tycho FAQ for details. (Note that the upcoming Tycho version 1.0.0 will further improve rootfiles support in Tycho by supporting the root.folder.<subfolder> syntax.)