当Eclipse自动化“导出为功能”时,Maven / Tycho看不到我的插件 [英] When automating Eclipse's "Export as Feature", Maven/Tycho doesn't see my plugin

查看:102
本文介绍了当Eclipse自动化“导出为功能”时,Maven / Tycho看不到我的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作空间中有一个插件和一个功能项目。当我通过文件>导出为>功能手动导出功能一切都很好。我正在尝试编写一个自动插件构建和导出脚本来摆脱这种烦恼。我将功能项目转换为Maven项目,并填充pom.xml:

 < project xmlns =http:// maven。 apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi: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> MyProject< / groupId>
< artifactId> NMGDBPluginFeature< / artifactId>
< version> 1.0.0-SNAPSHOT< / version>
< packaging> eclipse-feature< / packaging>

< properties>
< tycho-version> 0.22.0< / tycho-version>
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
< / properties>

< repositories>
< repository>
< id> eclipse-luna< / id>
< layout> p2< / layout>
< url> http://download.eclipse.org/releases/luna< / url>
< / repository>
< / repositories>

< build>
< plugins>
< plugin>
< groupId> org.eclipse.tycho< / groupId>
< artifactId> tycho-maven-plugin< / artifactId>
< version> $ {tycho-version}< / version>
< extensions> true< / extensions>
< / plugin>
< / plugins>
< / build>

< / project>

但是脚本抛出:

  [ERROR]无法解决项目依赖关系:
[ERROR]正在安装的软件:NMGDBPluginFeature.feature.group 1.0.0.qualifier
[错误]缺少要求:NMGDBPluginFeature.feature。组1.0.0.qualifier需要'GDBFifoBlocks [1.0.0.gdbfifoblocks]'但是找不到

怎么会发生这种情况?我以为pom.xml使用的是项目的feature.xml,不是吗?什么是正确的配置?

解决方案

到目前为止,您的配置看起来不错。但是,您目前只拥有自己的功能,而不是插件。与Eclipse导出向导不同, eclipse-feature 仅处理feature.xml - 并且期望引用的插件在别处构建。



所以你需要做的是设置一个Maven反应器,它包含一个 eclipse-feature 和一个 eclipse-plugin 项目。以下是您如何执行此操作:


  1. 将您当前的pom.xml设置为父POM:将包装更改为 pom ,将 artifactId 修改为有意义的东西(例如 MyProject.parent ),将pom.xml移动到工作区中的新的常规项目中。

  2. 在功能项目的根目录中添加一个pom.xml:

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

    < parent>
    < groupId> MyProject< / groupId>
    < artifactId> MyProject.parent< / artifactId>
    < version> 1.0.0-SNAPSHOT< / version>
    < relativePath> relative / path / to / parent / project< / relativePath>
    < / parent>

    < artifactId> NMGDBPluginFeature< / artifactId>
    < packaging> eclipse-feature< / packaging>

    < / project>


  3. 在插件项目的根目录中添加另一个pom.xml,它与除了 artifactId 之外的一个,这需要与插件的 Bundle-SymbolicName 相同,而包装需要 eclipse-plugin


  4. p>通过在父POM中添加一个< modules> 部分,并将这些项目的路径添加到Maven反应器中:

     < modules> 
    < module> relative / path / to / plugin / project< / module>
    < module> relative / path / to / feature / project< / module>
    < / modules>


请注意,路径需要适应它们对于磁盘上的项目位置(可能与Eclipse工作空间中显示的不同)是正确的。路径需要是相对的,所以他们可能从 ../ 开始。



现在你可以触发一个Maven构建在您的父POM上,该功能应该能够解析对您的插件的引用。在Eclipse中,您可以从pom.xml文件的上下文菜单中触发Maven构建。或者,如果您还将父项目转换为Maven项目,则还可以从项目根的上下文菜单运行Maven构建。


I have a plugin and a feature project in my workspace. When I export the feature manually via File > Export As > Feature everything works well. I'm trying to write an automatic plugin building and exporting script to get rid of this chore. I converted feature project to Maven project and filled pom.xml with:

<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>MyProject</groupId>
   <artifactId>NMGDBPluginFeature</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <packaging>eclipse-feature</packaging>

   <properties>
      <tycho-version>0.22.0</tycho-version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
   </properties>

   <repositories>
      <repository>
         <id>eclipse-luna</id>
         <layout>p2</layout>
         <url>http://download.eclipse.org/releases/luna</url>
      </repository>
   </repositories>

   <build>
      <plugins>
         <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>${tycho-version}</version>
            <extensions>true</extensions>
         </plugin>
      </plugins>
   </build>

</project>

However script throws:

[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: NMGDBPluginFeature.feature.group 1.0.0.qualifier
[ERROR]   Missing requirement: NMGDBPluginFeature.feature.group 1.0.0.qualifier requires 'GDBFifoBlocks [1.0.0.gdbfifoblocks]' but it could not be found

How could that happen? I thought pom.xml uses feature.xml of project, doesn't it? What is a proper configuration?

解决方案

So far, your configuration looks good. However you currently only have an automated build for your feature, but not the for the plugin. Unlike the Eclipse export wizard, eclipse-feature only processes the feature.xml - and it expects that the referenced plugins are built elsewhere.

So what you need to do is to set up a Maven reactor which includes both an eclipse-feature and an eclipse-plugin project. Here is how you do this:

  1. Make your current pom.xml the parent POM: Change the packaging to pom, adapt the artifactId to something which makes sense (e.g. MyProject.parent), and move the pom.xml into a new general project in your workspace.
  2. Add a pom.xml in the root of the feature project:

    <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>
    
      <parent>
        <groupId>MyProject</groupId>
        <artifactId>MyProject.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>relative/path/to/parent/project</relativePath>
      </parent>
    
      <artifactId>NMGDBPluginFeature</artifactId>
      <packaging>eclipse-feature</packaging>
    
    </project>
    

  3. Add another pom.xml in the root of the plugin project, which is the same as the one above except for the artifactId - this needs to be the same as the plugin's Bundle-SymbolicName - and the packaging which needs to be eclipse-plugin.

  4. Include the plugin and feature projects in the Maven reactor by adding a <modules> section in the parent POM with the paths to these projects:

      <modules>
        <module>relative/path/to/plugin/project</module>
        <module>relative/path/to/feature/project</module>
      </modules>
    

Note that the paths need to be adapted so that they are correct for the project locations on disk (which may be different to what is shown in the Eclipse workspace). The paths need to be relative, so they probably start with ../.

Now you can trigger a Maven build on your parent POM, and the feature should be able to resolve the reference to your plugin. In Eclipse, you can trigger the Maven build from the context menu of the pom.xml file. Or, if you also convert the parent project to a Maven project, the you can also run Maven builds from the context menu of the project root.

这篇关于当Eclipse自动化“导出为功能”时,Maven / Tycho看不到我的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆