maven发布:准备跳过test-jar

时间:2013-07-11 07:36:58

标签: maven junit release maven-jar-plugin

我正在使用maven ver。 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

当我正在释放时,我的测试jar不会被创建:

-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

如何在发布期间生成我的测试jar?为什么会跳过它?

修改

我发现仅当我有活动发布个人资料时才会出现此问题。我无法在任何父母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 ,现在一切正常。

0 个答案:

没有答案