我开始通过maven-invoker-plugin
测试一个Maven插件,但我遇到了一个奇怪的例外:
[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
我添加了maven-invoker-plugin
,如下所示:
<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-从this Maven plug-in借用了 settings.xml 。而 pom.xml 中测试失败的是这个调用:
<plugin>
<groupId>my.company</groupId>
<artifactId>plugin</artifactId>
<version>@project.version@</version>
</plugin>
经过多次挖掘,我认为第谷至少是问题的一部分:
<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>
如果我删除它@project.version@
它可行,但它显然不是当前版本的测试插件。所以我想我必须留下它。我尝试添加maven-compat
(as suggested here),但它没有做任何事情。
当我不在 pom.xml 中添加插件时会显示相同的异常,但是通过以下方式调用它:
invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:goal
有关如何处理该问题的任何建议吗?
答案 0 :(得分:0)
显然这个插件以某种方式丢失了,再添加它使得例外消失了:
<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>