From 999fa6eb2162cbaac29a423f502e39d83ff4b06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 8 Oct 2015 16:50:07 +0200 Subject: [PATCH] Add checkstyle with a small config It doesn't include all of the Android style checks as found in Android Studio, but it's a start. Bump Gradle to 2.7 because the checkstyle plugin in earlier versions is just not good enough. --- .gitlab-ci.yml | 4 +- F-Droid/build.gradle | 9 ++++ build.gradle | 4 ++ config/checkstyle/checkstyle.xml | 80 ++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 config/checkstyle/checkstyle.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 023d6140c..8b5e086d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,9 +19,9 @@ before_script: - echo " == Installing Android emulator images" - echo y | android -s update sdk --no-ui -a -t android-10 - echo " == Installing Gradle" - - wget -q -O gradle.zip https://services.gradle.org/distributions/gradle-2.4-bin.zip + - wget -q -O gradle.zip https://services.gradle.org/distributions/gradle-2.7-bin.zip - unzip -q gradle.zip - - export PATH="$PWD/gradle-2.4/bin:$PATH" + - export PATH="$PWD/gradle-2.7/bin:$PATH" test: script: diff --git a/F-Droid/build.gradle b/F-Droid/build.gradle index 18ba6334c..4916f4c71 100644 --- a/F-Droid/build.gradle +++ b/F-Droid/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.application' apply plugin: 'witness' +apply plugin: 'checkstyle' if (!hasProperty('sourceDeps')) { repositories { @@ -182,6 +183,14 @@ android { } } +task checkstyle(type: Checkstyle) { + configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") + source 'src' + include '**/*.java' + exclude '**/gen/**' + + classpath = files() +} // This person took the example code below from another blogpost online, however // I lost the reference to it: // http://stackoverflow.com/questions/23297562/gradle-javadoc-and-android-documentation diff --git a/build.gradle b/build.gradle index 583db1576..6c9018bc1 100644 --- a/build.gradle +++ b/build.gradle @@ -7,3 +7,7 @@ buildscript { classpath files('libs/gradle-witness.jar') } } + +task wrapper(type: Wrapper) { + gradleVersion = '2.7' +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 000000000..8fb1856b6 --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +