【问题标题】:How to make Eclipse unpack bundles without Eclipse-BundleShape header如何在没有 Eclipse-BundleShape 标头的情况下制作 Eclipse 解包包
【发布时间】:2014-10-31 15:05:12
【问题描述】:

我有大量来自遗留 Eclipse RCP 应用程序的捆绑包,我希望能够在 Tycho 构建中使用它们。这些包还没有 p2 存储库,所以我创建了一个。这已经很好地工作了,除了需要在安装中解包的包仍然作为 JAR 安装。

我创建 p2 存储库的第一种方法是将包部署到 Maven 存储库,然后使用 pomDependency=consider 将它们包含在 eclipse-featureeclipse-repository 中。但是,Tycho 忽略了 feature.xml 中的 unpack 属性,因此这不起作用(参见 documentation)。此问题的推荐解决方案是在包含的捆绑包的清单中添加Eclipse-BundleShape: dir。我可以这样做 - 但由于我有数百个捆绑包,这将是一项相当大的工作。

然后,我得到了使用“Features and Bundles Publisher Application”的提示:使用此应用程序,功能和捆绑工件同时在 p2 存储库中创建,因此有关捆绑形状的信息可以从 feature.xml 复制到相应的包中。

但这仍然不起作用:虽然我已经为正在发布的捆绑包之一设置了unpack="true",但捆绑包没有

<instruction key='zipped'>
  true
</instruction>

在 p2 存储库的 content.xml 中,因此在安装时不会解压缩。有什么想法我可能做错了吗?还有其他想法如何让它发挥作用吗?


这是我用于创建 p2 存储库的 pom.xml

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycorp.xyz.expose</groupId>
    <artifactId>com.mycorp.xyz.expose.orbit</artifactId>
    <version>1.0.0</version>

    <dependencies>
        <dependency>
            <groupId>com.mycorp.xyz.expose</groupId>
            <artifactId>com.mycorp.somelib</artifactId>
            <version>6.40.0</version>
        </dependency>
        <!-- and many more... -->
    </dependencies>

    <build>
        <outputDirectory>${project.build.directory}/artifacts</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/artifacts/plugins</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho.extras</groupId>
                <artifactId>tycho-p2-extras-plugin</artifactId>
                <version>0.21.0</version>
                <executions>
                    <execution>
                        <id>publish-features-and-bundles</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>publish-features-and-bundles</goal>
                        </goals>
                        <configuration>
                            <sourceLocation>${project.build.directory}/artifacts</sourceLocation>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-repository-plugin</artifactId>
                <version>0.21.0</version>
                <executions>
                    <execution>
                        <id>assemble</id>
                        <phase>package</phase>
                        <goals>
                            <goal>verify-repository</goal>
                            <goal>archive-repository</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project> 

项目中唯一的其他文件是 src/main/resources/features` 中的以下 feature.xml

<?xml version="1.0" encoding="UTF-8"?>
<feature
      id="com.mycorp.xyz.expose.orbit"
      label="..."
      version="1.0.0">

   <plugin
         id="com.mycorp.somelib"
         download-size="0"
         install-size="0"
         version="0.0.0"
         unpack="true"/>

   <!-- and many more... -->

</feature>

【问题讨论】:

  • 这是我今天在内部得到的一个非常好的问题(几乎完美的解决方案)。我正在分享它以供其他人从问题和答案中受益。

标签: eclipse-plugin eclipse-rcp tycho p2


【解决方案1】:

我已经调试了在所述设置中运行的功能和捆绑发布者应用程序,结果发现发布者没有将 feature.xml 中的 unpack="true" 与捆绑包相关联,因为版本不匹配。

因此,您需要在 feature.xml 中提供所引用包的实际 OSGi 版本,而不是 0.0.0。没有像普通 Tycho 构建那样的自动替换。所以 feature.xml 会例如看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<feature
      id="com.mycorp.xyz.expose.orbit"
      label="..."
      version="1.0.0">

   <plugin
         id="com.mycorp.somelib"
         download-size="0"
         install-size="0"
         version="6.40.0.140829051758"
         unpack="true"/>

</feature>

然后,捆绑包在安装时按预期解压。

【讨论】:

    猜你喜欢
    • 2011-10-11
    • 2013-09-06
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    相关资源
    最近更新 更多