【问题标题】:${session.executionRootDirectory} is not recognized by sonar-maven-pluginsonar-maven-plugin 无法识别 ${session.executionRootDirectory}
【发布时间】:2016-08-04 12:23:02
【问题描述】:

我有几个级别的嵌套 Maven 项目,每个模块都可以参与全局集成测试。为了获得全局、多模块覆盖,我配置 jacoco 使用 Maven 变量 ${session.executionRootDirectory} 跨模块共享相同文件:

<execution>
    <id>pre-integration-test</id>
    <phase>pre-integration-test</phase>
    <goals>
        <goal>prepare-agent-integration</goal>
    </goals>
    <configuration>
        <propertyName>jacoco.failsafeArgLine</propertyName>
        <destFile>${session.executionRootDirectory}/target/jacoco-it.exec</destFile>
    </configuration>
</execution>

这样,每个模块都使用相同的数据文件,无论它在子模块中嵌套多深。我查过了,jacoco在启动“mvn clean install”时生成了正确的数据文件。

现在启动mvn sonar:sonar 时出现问题。似乎插件无法用真实路径替换该变量。我可以在日志中看到以下内容

[INFO] JaCoCoItSensor: JaCoCo IT report not found: /home/tomcat/.jenkins/jobs/MYJOB/workspace/${session.executionRootDirectory}/target/jacoco-it.exec

使用@{session.executionRootDirectory}时效果不好。

有什么解决方法吗?

【问题讨论】:

    标签: maven sonar-maven-plugin


    【解决方案1】:

    关注a comment in this bug report at SonarSource,建议使用以下配置:

    <plugin>
        <groupId>com.github.goldin</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>0.2.5</version>
        <executions>
            <execution>
                <id>set-sonar.jacoco.reportPath</id>
                <goals>
                    <goal>set-properties</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                    <rawProperties>
                        sonar.jacoco.itReportPath = ${session.executionRootDirectory}/target/jacoco-it.exec
                    </rawProperties>
                    <addDollar>true</addDollar>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    ...不幸的是,它与 Maven 3.1+ 不兼容,我使用并从源代码 that fork 构建,然后我能够使用 Maven 3.2.3 使一切正常工作。

    【讨论】:

      猜你喜欢
      • 2022-11-17
      • 2016-03-15
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 2023-02-08
      • 2021-03-11
      • 2013-04-07
      • 2021-02-15
      相关资源
      最近更新 更多