简体   繁体   English

当自动化Eclipse的“Export as Feature”时,Maven / Tycho没有看到我的插件

[英]When automating Eclipse's “Export as Feature”, Maven/Tycho doesn't see my plugin

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: 我将功能项目转换为Maven项目并填充pom.xml:

<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? 我以为pom.xml使用了项目的feature.xml,不是吗? 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. 与Eclipse导出向导不同, eclipse-feature仅处理feature.xml - 并且它期望引用的插件在其他地方构建。

So what you need to do is to set up a Maven reactor which includes both an eclipse-feature and an eclipse-plugin project. 所以你需要做的是建立一个Maven反应器,其中包括eclipse-featureeclipse-plugin项目。 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 (eg MyProject.parent ), and move the pom.xml into a new general project in your workspace. 使您当前的pom.xml成为父POM:将包装更改为pom ,将artifactId调整为有意义的内容(例如MyProject.parent ),并将pom.xml移动到工作区中的新常规项目中。
  2. Add a pom.xml in the root of the feature project: 在功能项目的根目录中添加pom.xml:

     <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 . 在插件项目的根目录中添加另一个pom.xml,除了artifactId之外,它与上面的相同 - 这需要与插件的Bundle-SymbolicName - 以及需要eclipse-pluginpackaging

  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: 通过在父POM中添加<modules>部分以及这些项目的路径,在Maven反应器中包含插件和功能项目:

      <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). 请注意,需要调整路径以使它们对于磁盘上的项目位置是正确的(这可能与Eclipse工作区中显示的不同)。 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. 现在,您可以在父POM上触发Maven构建,该功能应该能够解析对插件的引用。 In Eclipse, you can trigger the Maven build from the context menu of the pom.xml file. 在Eclipse中,您可以从pom.xml文件的上下文菜单中触发Maven构建。 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. 或者,如果您还将父项目转换为Maven项目,您还可以从项目根目录的上下文菜单中运行Maven构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM