diff --git a/app/build.gradle b/app/build.gradle index 52c3a67d..a3e33c2b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,8 @@ apply plugin: 'com.android.application' +apply plugin: 'findbugs' +apply plugin: 'pmd' + +def ABORT_ON_CHECK_FAILURE=false android { compileSdkVersion 21 @@ -17,13 +21,22 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + lintOptions { + abortOnError ABORT_ON_CHECK_FAILURE + lintConfig file("${project.rootDir}/config/lint/lint.xml") + +// if true, generate an HTML report (with issue explanations, sourcecode, etc) + htmlReport true +// optional path to report (default will be lint-results.html in the builddir) + htmlOutput file("$project.buildDir/reports/lint/lint.html") + } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:support-v4:21.0.3' -// compile 'com.noveogroup.android:android-logger:1.3.5' compile 'com.github.tony19:logback-android-classic:1.1.1-3' compile 'org.slf4j:slf4j-api:1.7.7' compile 'com.github.PhilJay:MPAndroidChart:2.1.0' @@ -32,3 +45,67 @@ dependencies { testCompile 'junit:junit:4.12' // testCompile "org.mockito:mockito-core:1.9.5" } + +check.dependsOn 'findbugs', 'pmd', 'lint' + +task pmd(type: Pmd) { + ruleSetFiles = files("${project.rootDir}/config/pmd/pmd-ruleset.xml") + ignoreFailures = !ABORT_ON_CHECK_FAILURE + ruleSets = [ + 'java-android', + 'java-basic', + 'java-braces', + 'java-clone', + 'java-codesize', + 'java-controversial', + 'java-coupling', + 'java-design', + 'java-empty', + 'java-finalizers', + 'java-imports', + 'java-junit', + 'java-optimizations', + 'java-strictexception', + 'java-strings', + 'java-sunsecure', + 'java-typeresolution', + 'java-unnecessary', + 'java-unusedcode' + ] + + source 'src' + include '**/*.java' + exclude '**/gen/**' + + reports { + xml.enabled = false + html.enabled = true + xml { + destination "$project.buildDir/reports/pmd/pmd.xml" + } + html { + destination "$project.buildDir/reports/pmd/pmd.html" + } + } +} + + +task findbugs(type: FindBugs) { + ignoreFailures = !ABORT_ON_CHECK_FAILURE + effort = "default" + reportLevel = "medium" + excludeFilter = new File("${project.rootDir}/config/findbugs/findbugs-filter.xml") + classes = files("${project.rootDir}/app/build/intermediates/classes") + source = fileTree('src/main/java/') + classpath = files() + reports { + xml.enabled = false + html.enabled = true + xml { + destination "$project.buildDir/reports/findbugs/findbugs-output.xml" + } + html { + destination "$project.buildDir/reports/findbugs/findbugs-output.html" + } + } +} diff --git a/config/findbugs/findbugs-filter.xml b/config/findbugs/findbugs-filter.xml new file mode 100644 index 00000000..1b3b80c4 --- /dev/null +++ b/config/findbugs/findbugs-filter.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/pmd/pmd-ruleset.xml b/config/pmd/pmd-ruleset.xml new file mode 100644 index 00000000..816f92a1 --- /dev/null +++ b/config/pmd/pmd-ruleset.xml @@ -0,0 +1,52 @@ + + + + + + Custom ruleset for Android application + + .*/R.java + .*/gen/.* + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file