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

后端 未结 1 617
夕颜
夕颜 2021-01-06 16:54

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 autom

相关标签:
1条回答
  • 2021-01-06 17:50

    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.

    0 讨论(0)
提交回复
热议问题