AndroidCodeQualityConfig icon indicating copy to clipboard operation
AndroidCodeQualityConfig copied to clipboard

Error:Android tasks have already been created. This happens when calling android.applicationVariants, android.libraryVariants or android.testVariants. Once these methods are called, it is not possible to continue configuring the model.

Open TheReprator opened this issue 8 years ago • 2 comments

Error:Android tasks have already been created. This happens when calling android.applicationVariants, android.libraryVariants or android.testVariants. Once these methods are called, it is not possible to continue configuring the model.

TheReprator avatar Mar 03 '17 07:03 TheReprator

This is my final quality.gradle

apply plugin: 'checkstyle' apply plugin: 'findbugs' apply plugin: 'pmd'

def isJava = plugins.hasPlugin('java') // Add checkstyle, findbugs, pmd and lint to the check task. // Comment it if already set in root project's build.gradle. check.dependsOn 'checkstyle', 'findbugs', 'pmd' if (!isJava) { check.dependsOn 'lint' }

checkstyle { toolVersion '7.4'

configFile file("${project.rootDir}/AndroidCodeQualityConfig/quality/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionFilterPath = file(
        "${project.rootDir}/AndroidCodeQualityConfig/quality/checkstyle/suppressions.xml")
        .absolutePath

}

task checkstyle(type: Checkstyle, group: 'verification') { source 'src' include '/*.java' exclude '/gen/' exclude '/test/' exclude '/androidTest/' exclude '/R.java' exclude '**/BuildConfig.java' classpath = files() }

findbugs { toolVersion = "3.0.1" ignoreFailures = false effort = "max" reportLevel = "high" excludeFilter = new File("${project.rootDir}/AndroidCodeQualityConfig/quality/findbugs/findbugs-filter.xml") }

task findbugs(type: FindBugs, dependsOn: "assemble", group: 'verification') { if (isJava) { classes = files("$projectDir.absolutePath/build/classes") } else { classes = files("$projectDir.absolutePath/build/intermediates/classes") } source 'src' include '/*.java' exclude '/gen/**'

reports {
    xml.enabled = false
    html.enabled = true
    xml {
        destination "$projectDir.absolutePath/build/reports/findbugs/findbugs.xml"
    }
    html {
        destination "$projectDir.absolutePath/build/reports/findbugs/findbugs.html"
    }
}

classpath = files()

}

pmd { toolVersion = '5.5.2' ignoreFailures = false ruleSetFiles = files("${project.rootDir}/AndroidCodeQualityConfig/quality/pmd/pmd-ruleset.xml") ruleSets = [] }

task pmd(type: Pmd, group: 'verification') { source 'src' include '/*.java' exclude('/gen/', '/debug/**')

reports {
    xml.enabled = true
    html.enabled = true
    xml {
        destination "$projectDir.absolutePath/build/reports/pmd/pmd.xml"
    }
    html {
        destination "$projectDir.absolutePath/build/reports/pmd/pmd.html"
    }
}

}

if (!isJava) { android { lintOptions { disable 'NewApi' // gradle build will compile code use Objects.requireNonNull() for lambda abortOnError true xmlReport true xmlOutput project.file('build/reports/lint/lint-report.xml') htmlReport true htmlOutput project.file('build/reports/lint/lint-report.html') lintConfig file("${project.rootDir}/AndroidCodeQualityConfig/quality/lint/lint.xml") }

    testOptions.unitTests.all {
        testLogging {
            events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
            outputs.upToDateWhen { false }
            showStandardStreams = true
        }
        jvmArgs '-noverify'
    }
}

}

afterEvaluate { android { lintOptions { abortOnError true xmlReport true htmlReport true lintConfig file("${project.rootDir}/AndroidCodeQualityConfig/quality/lint/lint.xml") } } }

TheReprator avatar Mar 03 '17 07:03 TheReprator

Sorry that I can't tell what has been modified, could you please create a reproduce project?

Piasy avatar Mar 03 '17 23:03 Piasy