【问题标题】:Installable units are missing in p2 repository, so that tycho-p2-director fails when setting source=repositoryp2 存储库中缺少可安装单元,因此设置 source=repository 时 tycho-p2-director 失败
【发布时间】:2013-07-25 10:32:31
【问题描述】:

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

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

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

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

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

如何配置构建以在 project/repository/content.jar 中也包含该可安装单元?

这是我的 p2.inf 文件的 sn-p:

# 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

以及来自 Tycho 构建的错误:

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

【问题讨论】:

  • “我想修改一些捆绑包...” - 这似乎是错误的。我不知道您要达到什么目的,但是使用 source=repository 在其模块构建之外修改捆绑包不是一个合适的解决方案。
  • 首先感谢您再次回答我的问题:-)。修改仅包括对捆绑包进行签名。所以我想这闻起来没有你最初想象的那么强烈。知道为什么生成的 p2 存储库中的可安装单元不完整吗?
  • 您是否将您的project.build.directory 更改为project?通常路径是target/repository/, target/targetPlatformRepository/, ...
  • 对不起,我的意思是 /target/... 编辑了路径。

标签: tycho p2


【解决方案1】:

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

由于您说通过 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 都没有关系。

【讨论】:

  • 如果不是这样,我需要构建失败的错误消息。
  • 你 p2.inf 看起来不错,所以includeAllDependencies=true 应该将 configure.org.sample.bundle 拉到构建结果存储库中。您能否使用mvn clean verify -Dtycho.localArtifacts=ignore 再试一次(以确保问题不是由本地安装的工件引起的)?如果这没有帮助,可能会有bug in Tycho。 (报告错误时请附上您的示例项目。)
  • 感谢您的回复。使用给定属性执行构建会导致相同的错误。我正在尝试建立一个小样本构建并在白天报告错误。
  • 您需要在产品所在的模块中配置includeAllDependencies=true。然后就可以了。
  • 在正确的配置下确实可以发挥魅力。没有得到将产品配置为包含所有依赖项的意义。有很多陷阱要跳 - 感谢您帮助我。
猜你喜欢
  • 1970-01-01
  • 2018-10-25
  • 2012-01-24
  • 2016-05-22
  • 1970-01-01
  • 2019-12-13
  • 1970-01-01
  • 2016-09-29
  • 1970-01-01
相关资源
最近更新 更多