-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from greenhub-project/dev
Release v1.1.0
- Loading branch information
Showing
10 changed files
with
41 additions
and
372 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,24 @@ | ||
/** | ||
* Checkstyle tasks | ||
* Usage: | ||
* - place this file under root dir of your project | ||
* - apply script from your gradle file: | ||
* apply from : "{rootDir}/checkstyle.gradle" | ||
* | ||
* To configure checkstyle use configs at: | ||
* "{rootDir}/checkstyle.xml" - for main projects | ||
* "{rootDir}/checkstyle-test.xml" - for tests | ||
* "{rootDir}/suppresions.xml" - for style suppressions | ||
* | ||
* Config files must be in the root directory in order to Codacy to find them | ||
* | ||
* Xml and HTML reports are stored: | ||
* "{project.buildDir}/reports/checkstyle/" | ||
* HTML styling is done by XSLT stylesheet: | ||
* "{rootDir}/config/checkstyle/checkstyle-html.xsl" | ||
*/ | ||
|
||
apply plugin: 'checkstyle' | ||
|
||
task checkstyleMain (type: Checkstyle) { | ||
ignoreFailures = false | ||
showViolations = false | ||
source 'src/main', 'src/release' | ||
source 'src/main' | ||
include '**/*.java' | ||
exclude '**/gen/**' | ||
exclude '**/R.java' | ||
exclude '**/BuildConfig.java' | ||
reports { | ||
xml.destination "$project.buildDir/reports/checkstyle/main.xml" | ||
} | ||
classpath = files() | ||
configFile = file("${rootProject.rootDir}/checkstyle.xml") | ||
} | ||
|
||
task checkstyleTest (type: Checkstyle){ | ||
ignoreFailures = false | ||
showViolations = false | ||
source 'src/androidTest' | ||
include '**/*.java' | ||
exclude '**/gen/**' | ||
exclude '**/R.java' | ||
exclude '**/BuildConfig.java' | ||
reports { | ||
xml.destination "$project.buildDir/reports/checkstyle/test.xml" | ||
} | ||
classpath = files() | ||
configFile = file("${rootProject.rootDir}/checkstyle-test.xml") | ||
} | ||
|
||
|
||
task checkstyleReport { | ||
doLast { | ||
checkType = project.ext.get("checkType") | ||
if (file("$buildDir/reports/checkstyle/${checkType}.xml").exists()) { | ||
ant.xslt(in: "$project.buildDir/reports/checkstyle/${checkType}.xml", | ||
style:"${rootProject.rootDir}/config/checkstyle/checkstyle-html.xsl", | ||
out:"$project.buildDir/reports/checkstyle/checkstyle_${checkType}.html" | ||
) | ||
} | ||
} | ||
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml") | ||
} | ||
|
||
task checkstyle(dependsOn:['checkstyleMain']){ | ||
description 'Runs Checkstyle inspection against Android sourcesets.' | ||
group = 'Code Quality' | ||
} | ||
|
||
gradle.taskGraph.afterTask {Task task, TaskState state -> | ||
if(state.failure) { | ||
if (task.name in ['checkstyleMain', 'checkstyleTest']) { | ||
checkstyleReport { | ||
def matcher = task.name =~ /^checkstyle(.*)$/ | ||
if (matcher.matches()) { | ||
project.ext.set("checkType", matcher.group(1).toLowerCase()) | ||
} | ||
} | ||
checkstyleReport.execute() | ||
} | ||
tasks.withType(Checkstyle) { | ||
reports { | ||
xml.enabled false | ||
html.enabled true | ||
html.stylesheet resources.text.fromFile('config/xsl/checkstyle-html.xsl') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.