Maven clean和package不会产生万无一失的报告

时间:2015-06-02 09:14:30

标签: java maven maven-surefire-plugin

我有一个多模块maven项目,其中模块A / B / C依赖于模块D. 插件maven-surefire-plugin用于测试短语。

然而,

mvn clean package

不会在** / target /下生成surefire报告 和

mvn clean; mvn package

可以按预期生成确定报告。

这让我很困惑。虽然我的解决方法只是拆分为两个mvn命令,但我想知道为什么?

版本:

  • maven 3.3.3
  • jdk 1.7.0
  • maven-surefire-plugin 2.14

Root Pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.jzako.test</groupId>
    <artifactId>FeedbackSystem</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>FeedbackSystem</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-testng</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <modules>
        <module>ModuleA</module>
        <module>ModuleB</module>
        <module>ModuleC</module>
        <module>Utility</module>
  </modules>  
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14</version>
                <configuration>
                    <forkMode>never</forkMode>
                </configuration>
            </plugin>
        </plugins>
    </build> 
</project>

模块A Pom:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.jzako.test</groupId>
        <artifactId>FeedbackSystem</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>org.jzako.test</groupId>
    <artifactId>ModuleA</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>ModuleA</name>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>   
                          <mainClass>org.jzako.test.main.LightweightFeedbackStatisticsMain</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>${basedir}/../conf/dev</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${basedir}/../conf/dev</directory>
            </testResource>
        </testResources>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.jzako.test</groupId>
            <artifactId>Utility</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

多模块关系 模块A / B / C依赖于实用程序模块,模块A / B / C之间没有依赖关系。

更新 对于单个maven模块项目来说,似乎一切都很好。与多模块有关的东西?

0 个答案:

没有答案