项目作者: BarrieShieh

项目描述 :
Maven plugin for scanning source code with combination of dependency-check, checkstyle, spotbugs, pmd and generate reports for SonarQube
高级语言: Java
项目地址: git://github.com/BarrieShieh/sonar-oss-scanner-maven-plugin.git
创建时间: 2020-04-22T15:23:14Z
项目社区:https://github.com/BarrieShieh/sonar-oss-scanner-maven-plugin

开源协议:Apache License 2.0

下载


This plugin will scan the code with source code with dependency-check, checkstyle, spotbugs, pmd and
generate reports for SonarQube

Embedded scanner

This scanner is embedded with following scanner by default

Embedded Plugin name Embedded Plugin version Description
dependency-check-maven 6.1.0
maven-checkstyle-plugin 3.1.2 With Google Java Style
spotbugs-maven-plugin 4.2.0 With findsecbugs(LATEST), sb-contrib(LATEST)
maven-pmd-plugin 3.14.0

Example Usage

How to use this plugin in the project

```shell script

Build the project

mvn clean compile package

Generate the reports

mvn oss:scan

Do the sonar scan

mvn sonar:sonar

  1. SonarQube properties
  2. =============
  3. ```xml
  4. <properties>
  5. <sonar.dependencyCheck.jsonReportPath>${project.build.directory}/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
  6. <sonar.dependencyCheck.htmlReportPath>${project.build.directory}/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
  7. <sonar.dependencyCheck.xmlReportPath>${project.build.directory}/dependency-check-report.xml</sonar.dependencyCheck.xmlReportPath>
  8. <sonar.java.checkstyle.reportPaths>${project.build.directory}/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
  9. <sonar.java.spotbugs.reportPaths>${project.build.directory}/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
  10. <sonar.java.pmd.reportPaths>${project.build.directory}/pmd.xml</sonar.java.pmd.reportPaths>
  11. </properties>

Maven Dependency

NOTE: This plugin is not in the central maven yet. You need to use mvn install to add it to local repository.

Add this to your pom.xml:

  1. <plugin>
  2. <groupId>org.twdata.maven</groupId>
  3. <artifactId>sonar-oss-scanner-plugin</artifactId>
  4. <version>1.0.5</version>
  5. </plugin>

Parameter configLocation is optional. You can specify the absolute path for the external plugin configurations.

  1. <plugin>
  2. <groupId>org.twdata.maven</groupId>
  3. <artifactId>sonar-oss-scanner-plugin</artifactId>
  4. <version>1.0.5</version>
  5. <configuration>
  6. <configLocation>
  7. C:/plugins.xml
  8. </configLocation>
  9. </configuration>
  10. </plugin>

You can add more analyzer to the plugins.xml with following format

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <plugins>
  4. <plugin>
  5. <goal>${goal}</goal>
  6. <plugin>
  7. <groupId>${groupId}</groupId>
  8. <artifactId>${artifactId}</artifactId>
  9. <version>${version}</version>
  10. </plugin>
  11. <configuration>
  12. ...
  13. ${pluginConfiguration}
  14. </configuration>
  15. </plugin>
  16. </plugins>
  17. </configuration>

License

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Apache License, Version 2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

mojo-executor

sonarqube-licensecheck

checkstyle

spotbugs

pmd

mojo-api