Sonarqube扫描android项目插件安装

1、在android项目的build.gradle项目中添加如下代码

allprojects {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
}
//apply plugin: 'org.sonarqube'
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
    }
}
//apply plugin: "org.sonarqube"
subprojects {
    sonarqube {
        properties {
            property "sonar.host.url", "http://192.168.0.67:9000/" //我本地SonarQube平台的配置
            property "sonar.projectName", DDAndroid_project  //projectname
            property "sonar.projectKey", "admin" //projectkey
            property "sonar.language", "java"  //语言
            property "sonar.sourceEncoding", "UTF-8" //编码
            property "sonar.sources", android.sourceSets.main.java.srcDirs //源码,写这个就行
            property "sonar.projectVersion", "1.0.0"  //版本,随意

            property "sonar.language", "java"
            property "sonar.dynamicAnalysis", "reuseReports"
            //property "sonar.tests", android.sourceSets.instrumentTest.java.srcDirs
            property "sonar.java.binaries", "build/intermediates/classes"
            //property 'sonar.jacoco.reportPath', "build/jacoco/testReleaseUnitTest.exec"
            //property "sonar.jacoco.itReportPath", "$buildDir/jacoco/testReleaseUnitTest.exec"
            property "sonar.cobertura.reportPath", "app/build/reports/coverage/debug/report.xml"
            property "sonar.core.codeCoveragePlugin", "cobertura"

        }
    }
}

再次编译运行会报如下错误:

Error:FAILURE: Build failed with an exception.

* What went wrong:
Task 'assemble' not found in root project 'MyApplication'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s

解决的办法:

在根目录的build.gradle文件的首行加入:

task sonarqube{}

至此,编译运行通过

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值