簡體   English   中英

jacoco-maven-plugin導致站點插件在多模塊項目中失敗

[英]jacoco-maven-plugin causes site plugin to fail in multimodule project

上次我決定在我的Java項目Maven構建中,用JaCoCo插件替換Cobertura插件。

其中之一是具有模塊間依賴性的多模塊項目:

*-- pl.chilldev.commons
    |-- commons-concurrent
    |-- commons-daemon
    `-- commons-exception

問題是commons-daemon依賴於commons-exception

我有以下方式配置的jacoco-maven-plugin

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.1.201405082137</version>
            <executions>
                <execution>
                    <id>jacoco-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jacoco-report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

一切正常,測試運行,但是site目標失敗並顯示以下信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project commons: failed to get report for org.apache.maven.plugins:maven-javadoc-plugin: Failed to execute goal on project commons-daemon: Could not resolve dependencies for project pl.chilldev.commons:commons-daemon:jar:0.0.3-SNAPSHOT: Could not find artifact pl.chilldev.commons:commons-exception:jar:0.0.3-SNAPSHOT -> [Help 1]

沒有jacoco-maven-plugin即使對於site目標,一切都可以正常工作。

設法使其工作。 問題是,默認情況下, prepare-agent目標綁定到initialize階段,這意味着所有事情都將使用JaCoCo Java代理執行,而JaCoCo Java代理可能無法在Maven計算類路徑之前解析類路徑(我只是假設,我不知道內部結構) 。

添加:

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.1.201405082137</version>
            <executions>
                <execution>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

修復。

順便說一句-也不需要將report目標添加到執行列表中,我認為將其添加到報表插件中是更正確的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM