From 160fa6fcfa1ccded5cc402e0c312212d5c18ed5d Mon Sep 17 00:00:00 2001 From: Adam Kobus Date: Mon, 11 Jul 2016 13:26:17 +0200 Subject: [PATCH] ST-142 QA Tools are now optional --- README.md | 10 ++++++++-- .../toolkit/ToolkitConfiguration.groovy | 4 +++- .../variant/ConfigureCheckstyleForVariant.groovy | 14 +++++++++++--- .../variant/ConfigureFindbugsInVariant.groovy | 6 ++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f0a1a3f..4d14010 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ buildscript { } } dependencies { - classpath 'com.infullmobile:toolkit:0.3.12' + classpath 'com.infullmobile:toolkit:0.3.14' } } ``` @@ -195,7 +195,7 @@ If set to false, Java 1.7 will be used. Right now FindBugs won't be executed for Java 1.8 projects #### appendVersionNameToAPK -Default: `true` +Default: `false` If set to true, APK output file names will be modified by appending `versionName` to them. @@ -421,6 +421,11 @@ Where: - `key.store.password` - password for your keystore file - `key.alias.password` - password to your alias +#### runQAToolsInTests +Default: `false` + +If true, FindBugs and Checkstyle will be executed for test source sets / variants. + ### Example toolkit.properties file content ``` @@ -455,6 +460,7 @@ appendVersionNameToAPK=false configureMisc=true configureCustomFunctions=true +runQAToolsInTests=true ``` ## Planned work diff --git a/src/main/groovy/com/infullmobile/toolkit/ToolkitConfiguration.groovy b/src/main/groovy/com/infullmobile/toolkit/ToolkitConfiguration.groovy index dbf05f6..a702e06 100644 --- a/src/main/groovy/com/infullmobile/toolkit/ToolkitConfiguration.groovy +++ b/src/main/groovy/com/infullmobile/toolkit/ToolkitConfiguration.groovy @@ -21,7 +21,7 @@ class ToolkitConfiguration { def boolean configureFabric = true; def boolean configureCoverage = false def boolean useJava8 = false; - def boolean appendVersionNameToAPK = true; + def boolean appendVersionNameToAPK = false; def boolean configureTests = true; def boolean configureCheckstyle = true; @@ -41,6 +41,8 @@ class ToolkitConfiguration { def boolean configureMisc = true; def boolean configureCustomFunctions = true; + boolean runQAToolsInTests = false; + // tools version settings def Integer compileSdkVersion; def String buildToolsVersion; diff --git a/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureCheckstyleForVariant.groovy b/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureCheckstyleForVariant.groovy index f95b571..93bdb42 100644 --- a/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureCheckstyleForVariant.groovy +++ b/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureCheckstyleForVariant.groovy @@ -46,6 +46,12 @@ class ConfigureCheckstyleForVariant extends IVariantConfigCommand { variantConfigurator.config.checkstyleConfig.addTaskDependencies(this, it) variantWrapper.baseTask.dependsOn it } + if (variantConfigurator.config.runQAToolsInTests) { + addCheckstyleToTestVariants(checkstyleConfig, variantConfigurator) + } + } + + protected addCheckstyleToTestVariants(File checkstyleConfig, VariantConfigurator variantConfigurator) { variantWrapper.testVariants.each { testVariant -> configuredProject.task("checkstyle${variantWrapper.fullName.capitalize()}${testVariant.typeName.capitalize()}", type: Checkstyle) { @@ -63,14 +69,16 @@ class ConfigureCheckstyleForVariant extends IVariantConfigCommand { ignoreFailures variantConfigurator.config.ignoreCheckstyleFailures reports.xml.enabled true - reports.xml.destination "${variantConfigurator.config.checkstyleReportDir}/${variantWrapper.fullName}-${testVariant.typeName}.xml" + reports.xml.destination "${variantConfigurator.config.checkstyleReportDir}/" + + "${variantWrapper.fullName}-${testVariant.typeName}.xml" reports.html.enabled true - reports.html.destination "${variantConfigurator.config.checkstyleReportDir}/${variantWrapper.fullName}-${testVariant.typeName}.html" - + reports.html.destination "${variantConfigurator.config.checkstyleReportDir}/" + + "${variantWrapper.fullName}-${testVariant.typeName}.html" logging.setLevel(LogLevel.LIFECYCLE) variantConfigurator.config.checkstyleConfig.addTaskDependencies(this, it) variantWrapper.baseTask.dependsOn it } } + } } diff --git a/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureFindbugsInVariant.groovy b/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureFindbugsInVariant.groovy index 97a6007..a169c89 100644 --- a/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureFindbugsInVariant.groovy +++ b/src/main/groovy/com/infullmobile/toolkit/impl/android/commands/variant/ConfigureFindbugsInVariant.groovy @@ -33,6 +33,12 @@ class ConfigureFindbugsInVariant extends IVariantConfigCommand { configureFindbugsTask(it, variantConfigurator); } + if(config.runQAToolsInTests) { + configureTestVariants(variantConfigurator); + } + } + + def configureTestVariants(VariantConfigurator variantConfigurator) { variantConfigurator.variantWrapper.testVariants.each { TestVariantWrapper testVariant -> configuredProject.task("findbugs${variantWrapper.fullName.capitalize()}${testVariant.typeName.capitalize()}", type: FindBugs,