<NME> README.md
<BEF> # gradle-code-quality-tools-plugin

[![Build Status](https://travis-ci.org/vanniktech/gradle-code-quality-tools-plugin.svg?branch=master)](https://travis-ci.org/vanniktech/gradle-code-quality-tools-plugin?branch=master)
[![Codecov](https://codecov.io/github/vanniktech/gradle-code-quality-tools-plugin/coverage.svg?branch=master)](https://codecov.io/github/vanniktech/gradle-code-quality-tools-plugin?branch=master)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
![Java 7 required](https://img.shields.io/badge/java-7-brightgreen.svg)

Gradle plugin that generates [ErrorProne](http://errorprone.info/), [Findbugs](http://findbugs.sourceforge.net/), [Checkstyle](http://checkstyle.sourceforge.net/), [PMD](https://pmd.github.io/), [CPD](https://pmd.github.io/pmd-5.8.0/usage/cpd-usage.html), [Lint](https://developer.android.com/studio/write/lint.html), [Detekt](https://github.com/arturbosch/detekt) & [Ktlint](https://github.com/shyiko/ktlint) Tasks for every subproject. In Android projects Lint will also be configured. All of the taks will also automatically hook into the build lifecycle.

Works with the latest Gradle Android Tools version 2.3.3. This plugin is compiled using Java 7 hence you also need Java 7 in order to use it.

# Set up

```groovy
buildscript {
  repositories {
    classpath "com.vanniktech:gradle-code-quality-tools-plugin:0.22.0"
  }
}

apply plugin: "com.vanniktech.code.quality.tools"
```

### Snapshot

```gradle
buildscript {
  repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  }
  dependencies {
    classpath "com.vanniktech:gradle-code-quality-tools-plugin:0.23.0-SNAPSHOT"
  }
}

apply plugin: "com.vanniktech.code.quality.tools"
```

## Configuration

The philosophy of this plugin is to fail early. This means having zero warnings / errors reported from any tools. If you're just getting started with this in a large code base you might not be able to achieve this right away in which case you might want to set `failEarly` to `false` and then apply at a finer more granular scope how each tool should behave e.g. `checkstyle { ignoreFailures = false }`.

Those are all the available configurations - shown with default values and their types. More information can be found in the [Kotlin Documentation of the Extension](src/main/kotlin/com/vanniktech/code/quality/tools/CodeQualityToolsPluginExtension.kt) and the respective extensions for designated integrations.

```groovy
codeQualityTools {
  boolean failEarly = true
  boolean xmlReports = true
  boolean htmlReports = false
  boolean textReports = false
  String[] ignoreProjects = []

  checkstyle {
    boolean enabled = true
    String toolVersion = '8.6'
    String configFile = 'code_quality_tools/checkstyle.xml'
    Boolean ignoreFailures = null
    Boolean showViolations = null
    String source = 'src'
    List<String> include = ['**/*.java']
    List<String> exclude = ['**/gen/**']
  }
  pmd {
    boolean enabled = true
    String toolVersion = '6.0.0'
    String ruleSetFile = 'code_quality_tools/pmd.xml'
    Boolean ignoreFailures = null
    String source = 'src'
    List<String> include = ['**/*.java']
    List<String> exclude = ['**/gen/**']
  }
  lint {
    boolean enabled = true
    Boolean textReport = true
    String textOutput = 'stdout'
    Boolean abortOnError = null
    Boolean warningsAsErrors = null
    Boolean checkAllWarnings = null
    String baselineFileName = null
    Boolean absolutePaths = null
    File lintConfig = null
    Boolean checkReleaseBuilds = false
    Boolean checkTestSources = null
    Boolean checkDependencies = null
  }
  ktlint {
    boolean enabled = true
    String toolVersion = '0.32.0'
    boolean experimental = false
  }
  detekt {
    boolean enabled = true
    String toolVersion = '1.0.0'
    String config = 'code_quality_tools/detekt.yml'
    String baselineFileName = null
    boolean failFast = true
  }
  cpd {
    boolean enabled = true
    String source = 'src'
    String language = 'java'
    Boolean ignoreFailures = null
    int minimumTokenCount = 50
  }
  kotlin {
    boolean allWarningsAsErrors = true
  }
}
```

## Tools

Here I'll give a bit more information about how each of the tools will be applied. If there's a Gradle task that this plugin will generate it will also be hooked up into the `check` Gradle task. This means that when you execute `check` all of the rools will be running for you.

### Checkstyle

It'll apply the [Checkstyle Plugin](https://docs.gradle.org/current/userguide/checkstyle_plugin.html) and generate the `checkstyle` task that will execute checkstyle. The configuration properties of `codeQualityTools -> checkstyle` mirror the [properties from the plugin](https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.CheckstyleExtension.html).

### PMD

It'll apply the [PMD Plugin](https://docs.gradle.org/current/userguide/pmd_plugin.html) and generate the `pmd` task that will execute pmd. The configuration properties of `codeQualityTools -> pmd` mirror the [properties from the plugin](https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.PmdExtension.html).

### CPD

It'll apply the [CPD Plugin](https://github.com/aaschmid/gradle-cpd-plugin) and generate the `cpdCheck` task that will execute cpd. The configuration properties of `codeQualityTools -> cpd` mirror the [properties from the plugin](https://github.com/aaschmid/gradle-cpd-plugin#options).

### Lint

This will only work when one of the Android Plugins (`com.android.application`, `com.android.library`, etc.) are applied. The configuration properties of `codeQualityTools -> lint` mirror the [properties from the lintOptions](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.LintOptions.html).

### Detekt

It'll use the specified detekt version and generate the `detektCheck` task which will run detekt on your code base.

### Ktlint

It'll use the specified ktlint version and then generate two tasks. `ktlint` which will run ktlint over your code and flag issues. `ktlintFormat` will reformat your code.

**Note:** There might be some configuration properties that are not mirrored in which case feel free to open a PR. Personally, I don't have the need for all of them.

# License

Copyright (C) 2016 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0

<MSG> Slight README modifications. (#100)


<DFF> @@ -3,14 +3,15 @@
 [![Build Status](https://travis-ci.org/vanniktech/gradle-code-quality-tools-plugin.svg?branch=master)](https://travis-ci.org/vanniktech/gradle-code-quality-tools-plugin?branch=master)
 [![Codecov](https://codecov.io/github/vanniktech/gradle-code-quality-tools-plugin/coverage.svg?branch=master)](https://codecov.io/github/vanniktech/gradle-code-quality-tools-plugin?branch=master)
 [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
-![Java 7 required](https://img.shields.io/badge/java-7-brightgreen.svg)
 
-Gradle plugin that generates [ErrorProne](http://errorprone.info/), [Findbugs](http://findbugs.sourceforge.net/), [Checkstyle](http://checkstyle.sourceforge.net/), [PMD](https://pmd.github.io/), [CPD](https://pmd.github.io/pmd-5.8.0/usage/cpd-usage.html), [Lint](https://developer.android.com/studio/write/lint.html), [Detekt](https://github.com/arturbosch/detekt) & [Ktlint](https://github.com/shyiko/ktlint) Tasks for every subproject. In Android projects Lint will also be configured. All of the taks will also automatically hook into the build lifecycle.
+Gradle plugin that generates configures [ErrorProne](http://errorprone.info/), [Findbugs](http://findbugs.sourceforge.net/), [Checkstyle](http://checkstyle.sourceforge.net/), [PMD](https://pmd.github.io/), [CPD](https://pmd.github.io/pmd-5.8.0/usage/cpd-usage.html), [Lint](https://developer.android.com/studio/write/lint.html), [Detekt](https://github.com/arturbosch/detekt) & [Ktlint](https://github.com/shyiko/ktlint). All of these tools are also automatically hooked into the `check` gradle task.
 
-Works with the latest Gradle Android Tools version 2.3.3. This plugin is compiled using Java 7 hence you also need Java 7 in order to use it.
+Works with the latest Gradle Android Tools version 3.0.1.
 
 # Set up
 
+**root/build.gradle**
+
 ```groovy
 buildscript {
   repositories {

{'addition_count': 4, 'commit_subject': 'Slight README modifications. (#100)', 'deletion_count': 3, 'file_extension': '.md', 'lang': 'md', 'license': 'apache-2.0', 'repo_name': 'vanniktech/gradle-code-quality-tools-plugin'}