执行gradle sonarqube,按照要求位置填写 plugins 仍然报位置不对的解决方案

本文介绍如何在Android项目中集成SonarQube进行代码质量扫描。通过修改build.gradle文件并添加必要的依赖,可以实现与SonarQube的无缝对接。

1.使用sonarqube 扫 安卓代码,使用命令:gradle sonarqube

2.修改 build.gradle(其中只要加入三行:

maven {url "https://plugins.gradle.org/m2/"}

classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"

apply plugin: 'org.sonarqube')位置如下图

完全不需要在buidlscript下方添加:

plugins { id "org.sonarqube" version "2.6-rc1" }

添加这句就报:only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed

最后按照下图配置,执行成功。

gradle:6.5.1

sonarqube是docker环境下的:sonarqube

// Top-level build file where you can add configuration options common to all sub-projects/modules.

apply from: "config.gradle"
buildscript {
    repositories {
        maven {url "https://plugins.gradle.org/m2/"}

    }
    dependencies {
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
    }
}
apply plugin: 'org.sonarqube'
allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://maven.google.com'
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值