Search code examples
maventycho

Could not lookup required component: java.util.NoSuchElementException


I started testing a Maven plug-in via the maven-invoker-plugin, and am stuck with a weird exception:

[ERROR] Failed to execute goal my.company:plugin:1.0.4-SNAPSHOT:goal on project org.acme.simple: Could not lookup required component: java.util.NoSuchElementException 
[ERROR] role: my.company.plugin.SomeClass

I added the maven-invoker-plugin like this:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>2.0.0</version>
            <configuration>
                <pomIncludes>
                    <pomInclude>simple/pom.xml</pomInclude>
                </pomIncludes>
                <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                <settingsFile>src/it/settings.xml</settingsFile>
            </configuration>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>install</goal>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I -erm- borrowed the settings.xml from this Maven plug-in. And what fails in the pom.xml to be tested is this call:

        <plugin>
            <groupId>my.company</groupId>
            <artifactId>plugin</artifactId>
            <version>@project.version@</version>
        </plugin>

After some more digging around, I figure that Tycho is at least part of the problem:

<packaging>eclipse-plugin</packaging>

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

If I remove @project.version@ it works, but it's evidently not the current version of the plug-in that is tested. So I guess I have to leave it in. I tried adding maven-compat (as suggested here), but it didn't do anything.

The same exception is displayed when I don't add the plug-in in the pom.xml, but call it via:

invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:goal

Any advice how to handle that problem?


Solution

  • Evidently this plug-in got lost somehow, adding it again made the exception go away:

            <plugin>
                <groupId>org.codehaus.plexus</groupId>
                <artifactId>plexus-component-metadata</artifactId>
                <version>1.5.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-metadata</goal>
                            <goal>generate-test-metadata</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>