我正在使用 Maven 版本。3 使用以下插件生成带有测试的分离 *.jar 文件。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>core-tests</id>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
我的发布插件配置如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-8</version>
<configuration>
<releaseProfiles>release</releaseProfiles>
<preparationGoals>clean install</preparationGoals>
<generateReleasePoms>false</generateReleasePoms>
<scmCommentPrefix>
release plugin -
</scmCommentPrefix>
</configuration>
</plugin>
在单独的 jar 中生成测试类可以正常工作,直到我使用:
maven clean deploy
当我发布时,我的测试罐没有创建:
-Dresume=false release:prepare release:perform
释放输出:
...
[INFO] [INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] [INFO] Not compiling test sources
[INFO] [INFO] [surefire:test {execution: default-test}]
[INFO] [INFO] Tests are skipped.
[INFO] [INFO] [jar:jar {execution: default-jar}]
[INFO] [INFO] Building jar: /home/tomcat/hudson_home/jobs/project-core/workspace/target/core-1.2-SNAPSHOT.jar
[INFO] [INFO] [jar:test-jar {execution: core-tests}]
[INFO] [INFO] Skipping packaging of the test-jar
...
我也尝试使用DskipTests但也没有成功
-Dresume=false -Darguments="-DskipTests" release:prepare release:perform -Prelease
或者
-Dresume=false -Darguments="-Dmaven.test.skip.exec=true" release:prepare release:perform -Prelease
如何在发布期间生成我的测试罐?为什么会被跳过?
编辑
我发现只有当我有活动的发布配置文件时才会出现这个问题。我在任何父 pom 中都找不到此配置文件。它来自哪里?来自 maven-release-plugin 定义?
解决
我在 hudsons .m2/settings.xml上找到了配置文件发布:
<profile>
<id>release</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<username>*****</username>
<password>*****</password>
<skipTests>true</skipTests>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
我只需要删除maven.test.skip,现在一切正常。