我有这样的项目结构:
Parent
ProjectA
ProjectB
ProjectA生产耳朵。基于Arquillian的ProjectB测试依赖于ProjectA的耳朵(使用ProjectA耳朵创建额外部署)。 Maven安装目标工作正常但release:prepare
和release:perform
不是。第一阶段之一的maven-release-plugin增加了项目的版本。当ProjectB构建ProjectA的部署时,它找不到具有新版本的工件(但它存在于工作空间中 - 而不是本地存储库中):
java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.EnterpriseArchive com.....SchemaCreationTest.createFleetEmulator()
[INFO] at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:434)
[INFO] at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
[INFO] at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
[INFO] at org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenRepositorySystem.resolveDependencies(MavenRepositorySystem.java:121)
[INFO] at org.jboss.shrinkwrap.resolver.impl.maven.MavenWorkingSessionImpl.resolveDependencies(MavenWorkingSessionImpl.java:228)
[INFO] at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.using(MavenStrategyStageBaseImpl.java:71)
[INFO] at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withoutTransitivity(MavenStrategyStageBaseImpl.java:58)
[INFO] at org.jboss.shrinkwrap.resolver.impl.maven.MavenStrategyStageBaseImpl.withoutTransitivity(MavenStrategyStageBaseImpl.java:40)
我使用这样的命令解决工件:
Maven.configureResolver().offline().loadPomFromFile("pom.xml").importRuntimeAndTestDependencies().resolve().withoutTransitivity().asResolvedArtifact();
P.S。如果我设置了dryRun选项,mvn release:prepare
可以正常工作。
如何在maven release:prepare工作时解决工件?
答案 0 :(得分:1)
根据测试用例的结构,将Arquillian测试作为集成测试,可以单独执行。
如果需要,请集成maven-failsafe-plugin:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<parallel>methods</parallel>
<threadCount>1</threadCount>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
重命名您的测试类,以便将其检测为集成测试。即将AcmeTest重命名为AcmeIT,然后您的arquillian测试将作为集成测试执行,即使用mvn verify
运行arquillian测试。
这本身并不能解决问题。作为一个简单的解决方法,如果这是唯一正在执行的集成测试,您可以将-Darguments="-DskipITs"
添加到mvn release:prepare
,并且将跳过您的arquillian测试。您还可以将JUnit类别添加到arquillian测试并在该级别进行过滤。有关详情,请访问maven-failsafe-plugin site。