-Pstrict.release build flag to disable dev tools

Keep the release build as small as possible, so it is faster.  This also
makes it less important to track all the dev tool projects for security
issues, since they are disabled on release builds.
This commit is contained in:
Hans-Christoph Steiner 2022-12-15 13:28:40 +01:00
parent 0d5d0f7da2
commit 2828bf1f9f
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
3 changed files with 47 additions and 39 deletions

View File

@ -1,6 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
// add -Pstrict.release to the gradle command line to enable
if (project.hasProperty('strict.release')) {
println "Running strict release"
} else {
apply from: '../config/checkstyle/checkstyle.gradle'
apply from: '../config/pmd/pmd.gradle'
}
/* gets the version name from the latest Git tag */
def getVersionName = { ->
@ -191,40 +197,3 @@ dependencies {
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.work:work-testing:2.7.1'
}
checkstyle {
toolVersion = '7.2'
}
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
source 'src/main/java', 'src/test/java', 'src/androidTest/java'
include '**/*.java'
classpath = files()
}
pmd {
toolVersion = '6.20.0'
consoleOutput = true
}
task pmdMain(type: Pmd) {
dependsOn 'assembleDebug'
ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-main.xml")
ruleSets = [] // otherwise defaults clash with the list in rules.xml
source 'src/main/java'
include '**/*.java'
exclude '**/vendored/**/*.java'
}
task pmdTest(type: Pmd) {
dependsOn 'assembleDebug'
ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-test.xml")
ruleSets = [] // otherwise defaults clash with the list in rules.xml
source 'src/test/java', 'src/androidTest/java'
include '**/*.java'
exclude '**/vendored/**/*.java'
}
task pmd(dependsOn: [pmdMain, pmdTest]) {}

View File

@ -0,0 +1,13 @@
apply plugin: 'checkstyle'
checkstyle {
toolVersion = '7.2'
}
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
source 'src/main/java', 'src/test/java', 'src/androidTest/java'
include '**/*.java'
classpath = files()
}

26
config/pmd/pmd.gradle Normal file
View File

@ -0,0 +1,26 @@
apply plugin: 'pmd'
pmd {
toolVersion = '6.20.0'
consoleOutput = true
}
task pmdMain(type: Pmd) {
dependsOn 'assembleDebug'
ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-main.xml")
ruleSets = [] // otherwise defaults clash with the list in rules.xml
source 'src/main/java'
include '**/*.java'
exclude '**/vendored/**/*.java'
}
task pmdTest(type: Pmd) {
dependsOn 'assembleDebug'
ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-test.xml")
ruleSets = [] // otherwise defaults clash with the list in rules.xml
source 'src/test/java', 'src/androidTest/java'
include '**/*.java'
exclude '**/vendored/**/*.java'
}
task pmd(dependsOn: [pmdMain, pmdTest]) {}