Search code examples
eclipsemaveneclipse-rcptycho

Tycho Maven: Export Product with third party bundles and features


Currently I have a RCP project and I want to export product using Tycho-packaging, but I have third party plugins and features, any idea that how can I manage it?


Solution

  • But what is your problem? If you have added those 3rd party plugins to the target platform - they will be exported by Tycho. If you have those as projects in your workspace - add pom.xml to each of such project with appropriate packaging type: "eclipse-plugin", "eclipse-feature", etc. If these projects are shared between server and client, and require different packaging types, configure parent pom.xml of your client projects with something, like this

    <module>../commons/pom.osgi.xml</module>
    

    where pom.osgi.xml contains packaging type for Tycho and "commons" project contains standard pom.xml with server packaging type (for example "jar").

    UPD: Example contents of pom.osgi.xml:

    <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.company</groupId>
        <version>5.4.0.v20140625-0169</version>
        <packaging>eclipse-plugin</packaging>
    
        <parent>
            <groupId>com.company</groupId>
            <artifactId>app.client</artifactId>
            <version>5.4.0-SNAPSHOT</version>
            <relativePath>../parent.project.path</relativePath>
        </parent>
        <artifactId>com.company.activity</artifactId>
    </project>
    

    Contents of MANIFEST.MF

    Bundle-SymbolicName: com.company.activity
    

    Also, versions in both pom.osgi.xml and MANIFEST.MF must match - that is why our build system is configured to update both of these files.

    UPD 2: Target Platform pom.xml:

    <properties>
            <product.dir>${project.basedir}/eclipse</product.dir>
            <p2.dir>${project.basedir}/../repository/base</p2.dir>
        </properties>
    
        <dependencies>
            <!-- Eclipse Helios -->
            <!-- Includes JUnit -->
            <dependency>
                <groupId>org.eclipse</groupId>
                <artifactId>rcp-helios</artifactId>
                <version>${eclipse.rcp.version}</version>
                <type>zip</type>
                <optional>true</optional>
            </dependency>
    
            <!-- Delta Pack for MultiPlatform Build -->
            <dependency>
                <groupId>org.eclipse</groupId>
                <artifactId>delta-pack</artifactId>
                <version>${eclipse.rcp.version}</version>
                <classifier>pack</classifier>
                <type>zip</type>
                <optional>true</optional>
            </dependency>
    
            <!-- babel.de Language Pack -->
            <dependency>
                <groupId>org.eclipse</groupId>
                <artifactId>BabelLanguagePack-de</artifactId>
                <version>${eclipse.babel.version}</version>
                <type>zip</type>
            </dependency>
    
        </dependencies>
    
        <build>
    
            <plugins>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.5</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${product.dir}</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>${project.basedir}/../ajdt/eclipse</directory>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.4</version>
                    <executions>
                        <execution>
                            <id>unpack-eclipseRcp</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>unpack-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeGroupIds>org.eclipse</includeGroupIds>
                                <includeArtifactIds>rcp-helios,delta-pack,BabelLanguagePack-de</includeArtifactIds>
                                <outputDirectory>${product.dir}/../</outputDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <excludeArtifactIds>rcp-helios,delta-pack,BabelLanguagePack-de</excludeArtifactIds>
                                <outputDirectory>${product.dir}/plugins</outputDirectory>
                                <overWriteReleases>false</overWriteReleases>
                                <overWriteSnapshots>false</overWriteSnapshots>
                                <overWriteIfNewer>true</overWriteIfNewer>
                                <includeScope>runtime</includeScope>
                                <artifactItems>
                                </artifactItems>
                            </configuration>
                        </execution>
                        <execution>
                            <id>copy</id>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${product.dir}/plugins</outputDirectory>
                                <artifactItems>
                                        ....
                                        <!-- Jersey -->
                                    <artifactItem>
                                        <groupId>org.glassfish.jersey.core</groupId>
                                        <artifactId>jersey-client</artifactId>
                                        <version>${org.glassfish.jersey.core.version}</version>
                                        <destFileName>org.glassfish.jersey.core.jersey-client_${org.glassfish.jersey.core.version}.jar</destFileName>
                                    </artifactItem>
    
                                    <artifactItem>
                                        <groupId>org.glassfish.jersey.core</groupId>
                                        <artifactId>jersey-client</artifactId>
                                        <version>${org.glassfish.jersey.core.version}</version>
                                        <destFileName>org.glassfish.jersey.core.jersey-client-source_${org.glassfish.jersey.core.version}.jar</destFileName>
                                    </artifactItem>
    
                                    <!-- SLF4j -->
                                    <artifactItem>
                                        <groupId>org.slf4j</groupId>
                                        <artifactId>slf4j-api</artifactId>
                                        <version>${slf4j.version}</version>
                                        <destFileName>slf4j.api_${slf4j.version}.jar</destFileName>
                                    </artifactItem>
    
                                    <artifactItem>
                                        <groupId>ch.qos.logback</groupId>
                                        <artifactId>logback-core</artifactId>
                                        <version>${ch.qos.logback.version}</version>
                                         <destFileName>ch.qos.logback.core_${ch.qos.logback.version}.jar</destFileName>
                                    </artifactItem>
                                     ....
                                     <dependency>
                                        <groupId>org.codehaus.jackson</groupId>
                                        <artifactId>jackson-mapper-asl</artifactId>
                                        <destFileName>jackson-mapper-asl_${jackson-mapper-asl.version}.jar</destFileName>
                                        <version>${jackson-mapper-asl.version}</version>
                                    </dependency>
    
                                    <dependency>
                                        <groupId>org.hamcrest</groupId>
                                        <artifactId>hamcrest-all</artifactId>
                                        <version>${hamcrest.version}</version>
                                        <destFileName>org.hamcrest.all_${hamcrest.version}.jar</destFileName>
                                    </dependency>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.tycho.extras</groupId>
                    <artifactId>tycho-p2-extras-plugin</artifactId>
                    <version>0.13.0</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>publish-features-and-bundles</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <compress>false</compress>
                        <metadataRepositoryLocation>${p2.dir}</metadataRepositoryLocation>
                        <artifactRepositoryLocation>${p2.dir}</artifactRepositoryLocation>
                        <sourceLocation>${product.dir}</sourceLocation>
                        <publishArtifacts>true</publishArtifacts>
                        <append>true</append>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.4.1</version>
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>eclipse</directory>
                                <followSymlinks>false</followSymlinks>
                            </fileset>
                            <fileset>
                                <directory>${p2.dir}</directory>
                                <followSymlinks>false</followSymlinks>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
            </plugins>