码迷,mamicode.com
首页 > 其他好文 > 详细

maven + sonar, gradle + sonar

时间:2016-01-02 12:10:56      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

sonar installation and configuration

  1. Download sonar
    http://downloads.sonarsource.com/sonarqube/
  2. Decompression sonar package for installation
  3. Set sonar environment variable
    SONAR_HOME: “D:\sonarqube”
    PATH: “%SONAR_HOME%\bin\windows-x86-64”
  4. Start-up sonar
    CMD: StartSonar
    技术分享
  5. log into sonar
    http://localhost:9000/
  6. check issue in sonar web page
    技术分享

eclipse plug-in installation

  1. installation from “Eclipse Marketplace”
    技术分享
  2. Configuration sonar server
    技术分享

sonar with maven

  1. pom.xml fragment for sonar
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sonar.host.url>http://localhost:9000</sonar.host.url>
        <sonar.exclusions>**/*.class, **/*.groovy, src/main/java/spark/*</sonar.exclusions>
    </properties>

Note: sonar uses h2 as default database
2. maven CMD for sonar
CMD: mvn sonar:sonar
3. Analyze maven project in sonar GUI
http://localhost:9000/

sonar with gradle

  1. build.gradle fragment for sonar
apply plugin: ‘java‘
apply plugin: ‘eclipse‘
apply plugin: "sonar-runner"

group = ‘com.shuai.gradle.demo‘
description = ‘hello gradle for demo‘

sourceCompatibility = 1.7
version = ‘1.0‘

jar {
    manifest {
        attributes ‘Implementation-Title‘: ‘Gradle Quickstart‘,
        ‘Implementation-Version‘: version
    }
}

repositories { maven { url "http://scm0.access.nsn.com/nexus/content/groups/unify/" } }

dependencies {
    compile group: ‘commons-io‘, name: ‘commons-io‘, version: ‘2.+‘
    compile group: ‘org.apache.commons‘, name: ‘commons-lang3‘, version: ‘3.+‘
    compile group: ‘commons-collections‘, name: ‘commons-collections‘, version: ‘3.+‘
    testCompile group: ‘junit‘, name: ‘junit‘, version: ‘4.+‘
}

sonarRunner {
    sonarProperties {
        property "sonar.host.url", "http://localhost:9000"

        property "sonar.jdbc.url", "jdbc:h2:tcp://localhost:9092/sonar"
        property "sonar.jdbc.driverClassName", "org.h2.Driver"
        property "sonar.jdbc.username", "sonar"
        property "sonar.jdbc.password", "sonar"
    }
}

test { systemProperties ‘property‘: ‘value‘ }

uploadArchives {
    repositories {  flatDir { dirs ‘repos‘ }  }
}
  1. gradle CMD for sonar
    CMD:
    gradle build cleanEclipse -x test
    gradle sonarRunner
  2. log into sonar
    http://localhost:9000/

analyze codes via sonar in eclipse

  1. associate with sonarQube
    技术分享
  2. analyze codes via sonar
    技术分享

技术分享

maven + sonar, gradle + sonar

标签:

原文地址:http://www.cnblogs.com/hrhguanli/p/5094262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!