Tycho Maven:使用第三方捆绑包和功能导出产品

时间:2014-09-10 08:49:26

标签: eclipse maven eclipse-rcp tycho

目前我有一个RCP项目,我想使用Tycho-packaging导出产品,但我有第三方插件和功能,我知道如何管理它?

1 个答案:

答案 0 :(得分:0)

但你的问题是什么?如果您已将这些第三方插件添加到目标平台 - 它们将由Tycho导出。如果您在工作区中将这些作为项目 - 将pom.xml添加到具有适当打包类型的每个此类项目中:"eclipse-plugin""eclipse-feature"等。如果这些项目在服务器和客户端之间共享,则需要不同的打包类型,用你的东西配置你的客户项目的父pom.xml,比如这个

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

其中pom.osgi.xml包含Tycho和&#34; commons&#34;的包装类型。 project包含带有服务器打包类型的标准pom.xml(例如&#34; jar&#34;)。

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

MANIFEST.MF的内容

Bundle-SymbolicName: com.company.activity

此外,pom.osgi.xml和MANIFEST.MF中的版本必须匹配 - 这就是我们的构建系统配置为更新这两个文件的原因。

UPD 2: 目标平台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>