3

我正在构建一个产品(在 eclipse-repository 模块中),其中包含几个功能,这些功能通过 p2.inf 文件创建的可安装单元配置其插件。

只要我使用tycho-p2-director-plugintargetPlatformsource配置参数的默认值,它就可以工作。AFAIK 这使得导演可以从本地 Maven 存储库访问 p2 元数据和工件。<project_dir>/target/targetPlatformRepository/context.xml

由于我想修改一些捆绑包,我将source参数更改为repository. 这使得导演使用生成的存储库中的工件和元数据<project_dir>/target/repository并破坏我的构建;-)

似乎通过 p2.inf 创建的可安装单元在<project_dir>/target/repository/content.jar<project_dir>/target/targetPlatformRepository/context.xml完整的情况下丢失了。例如,以下单元仅包含在后者中:

<unit id='configure.org.sample.bundle' ...>
  <!-- config -->
</unit>

如何将构建配置为也包含该可安装单元project/repository/content.jar

这是我的 p2.inf 文件的片段:

# org.sample.bundle
requires.0.namespace=org.eclipse.equinox.p2.iu
requires.0.name=configure.org.sample.bundle
requires.0.greedy=true

units.0.id=configure.org.sample.bundle
units.0.version=1.0.0
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=configure.org.sample.bundle
units.0.provides.1.version=1.0.0
units.0.instructions.install=org.eclipse.equinox.p2.touchpoint.eclipse.installBundle(bundle:${artifact});
units.0.instructions.configure=org.eclipse.equinox.p2.touchpoint.eclipse.setStartLevel(startLevel:2); org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(started:true);
units.0.hostRequirements.1.namespace=osgi.bundle
units.0.hostRequirements.1.name=org.sample.bundle
units.0.hostRequirements.1.greedy=false
units.0.hostRequirements.2.namespace=org.eclipse.equinox.p2.eclipse.type
units.0.hostRequirements.2.name=bundle
units.0.hostRequirements.2.range=[1.0.0,2.0.0)
units.0.hostRequirements.2.greedy=false
units.0.requires.1.namespace=osgi.bundle
units.0.requires.1.name=org.sample.bundle
units.0.requires.1.greedy=false

第谷构建的错误:

Cannot complete the install because one or more required items could not be found.
Software being installed: sample 1.0.0.201308060715 (sample.product 1.0.0.201308060715)
Missing requirement: Sample Feature 1.0.0.201308060715 (sample.feature.feature.group
1.0.0.201308060715) requires 'configure.org.sample.bundle 0.0.0' but it could not be found
4

1 回答 1

2

创建产品安装时,p2 控制器需要解析产品的所有传递依赖项。但是默认情况下,在 eclipse-repository 模块(通常位于target/repository/)中构建的 p2 存储库仅聚合包含的内容。

由于您说通过 p2.inf 创建的单元在target/repository/p2 存储库中丢失,因此它们可能不包含在功能中,而仅作为依赖项引用。尽管您也可以更改 p2.inf 以生成包含,但这可能不是最简单的解决方案。

相反,只需将tycho-p2-repository-plugin配置为不仅聚合包含,而且聚合所有依赖项:

<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>tycho-p2-repository-plugin</artifactId>
      <version>${tycho-version}</version>
      <configuration>
        <includeAllDependencies>true</includeAllDependencies>
      </configuration>
    </plugin>
  </plugins>
</build>

然后,您是直接从目标平台还是从聚合的 p2 存储库安装tycho-p2-director-plugin都没有关系。

于 2013-08-05T14:01:52.317 回答