简体   繁体   English

动态生成声纳sonar-project.properties

[英]generate sonar sonar-project.properties on the fly

I am working in a big multi-module java maven project & my work is to setup reporting sonarQube issue at in the pull request of bitbucket after the build. 我正在一个大型的多模块Java Maven项目中工作,我的工作是在构建后在bitbucket请求中设置报告sonarQube问题。

I have created the sonar-project.properties according to the project structure, setup the job in jenkins , so far this is working properly. 我已经根据项目结构创建了sonar-project.properties ,并在jenkins设置了工作,到目前为止,它已经可以正常工作了。

Now the problem is, as this is the parent of a lot of other projects, lots is new modules/sub-modules kept getting added in the project. 现在的问题是,由于这是许多其他项目的父项,因此很多新的模块/子模块不断添加到项目中。 Every time there is new module, the sonar-project.properties have to be modified accordingly. 每次有新模块时,必须相应地修改sonar-project.properties Although that is expected, but its forgotten sometimes. 虽然这是预料之中的,但有时却将其遗忘。

This is the reason I was thinking of, is there a way to generate the sonar-project.properties on the fly before sonar-scanner starts executing. 这就是我一直在想的原因,有没有一种方法可以在sonar-scanner开始执行之前即时生成sonar-project.properties

This is the project structure we are following. 这是我们正在遵循的项目结构。

project-root/
    moduleA/
    .
    .
    moduleB/
    submoduleOfmoduleB/
    moduleC/
        submoduleOfmoduleC
        .

Is there any way to generate the sonar-project.properties by reading the pom files or some other way? 有什么方法可以通过读取pom文件或其他方法来生成sonar-project.properties

You do not need to use sonar-project.properties at all. 您根本不需要使用sonar-project.properties You can use the sonar-maven-plugin with some standard properties in your pom and new projects are added automatically. 您可以在pom中使用具有一些标准属性的sonar-maven-plugin并自动添加新项目。

We use the following settings 我们使用以下设置

<sonar.host.url>http://sonar:9000</sonar.host.url>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.jacoco.reportPaths>target/coverage-reports/jacoco-ut.exec, target/coverage-reports/jacoco-it.exec</sonar.jacoco.reportPaths>
<sonar.exclusions>file:**/generated-sources/**,file:**/pom.xml,file:**/node_modules/**</sonar.exclusions>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM