When automating Eclipse's "Export as Feature", Maven/Tycho doesn't see my plugin
Asked Answered
G

1

2

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?

Galenism answered 26/2, 2015 at 10:6 Comment(0)
G
6

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.

Gargan answered 27/2, 2015 at 14:37 Comment(1)
Thank you for verbose and quick answer. That wasn't intuitive.Galenism

© 2022 - 2024 — McMap. All rights reserved.