Skip to content

Commit

Permalink
Pull PMD and FindBugs out into separate projects.
Browse files Browse the repository at this point in the history
This saves ~10-20s so down to around ~2min build.
  • Loading branch information
sjudd committed Jan 7, 2018
1 parent eabe5fb commit 3af80f4
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 75 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ subprojects { project ->
}

project.afterEvaluate {
if (project.hasProperty("android")) {
if (project.hasProperty("android")
&& project.name != 'pmd'
&& project.name != 'findbugs') {
android {
lintOptions {
warningsAsErrors true
Expand Down
78 changes: 4 additions & 74 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'findbugs'
apply plugin: 'pmd'

if (!hasProperty('DISABLE_ERROR_PRONE')) {
apply plugin: "net.ltgt.errorprone"
Expand Down Expand Up @@ -61,79 +59,11 @@ android {
}
}

afterEvaluate {
if (tasks.findByName("assembleDebug") == null) {
return
}

findbugs {
toolVersion FINDBUGS_VERSION
}

tasks.create('findbugs', FindBugs) {
dependsOn tasks.compileDebugJavaWithJavac

description 'Run findbugs'
group 'verification'

classes = fileTree(tasks.compileDebugJavaWithJavac.destinationDir)
source android.sourceSets.main.java.srcDirs
classpath = files()
doFirst {
classpath += classPathForQuality()
}
effort = 'max'
excludeFilter = file("findbugs-exclude.xml")

// Failures are caught and printed by the violations plugin.
ignoreFailures = true

reports {
xml.enabled = true
html.enabled = false
}
}

check.dependsOn('findbugs')

pmd {
toolVersion PMD_VERSION
}

tasks.create('pmd', Pmd) {
dependsOn tasks.compileDebugJavaWithJavac
targetJdk = TargetJdk.VERSION_1_7

description 'Run pmd'
group 'verification'

// If ruleSets is not empty, it seems to contain some
// defaults which override rules in the ruleset file...
ruleSets = []
ruleSetFiles = files('pmd-ruleset.xml')
source android.sourceSets.main.java.srcDirs
classpath = files()
classpath += files(tasks.compileDebugJavaWithJavac.destinationDir)
doFirst {
classpath += classPathForQuality()
}

//TODO enable this once new Gradle containing this flag is out
//see https://github.com/gradle/gradle/pull/3125#issuecomment-352442432
//incrementalAnalysis = true

// Failures are caught and printed by the violations plugin.
ignoreFailures = true

reports {
xml.enabled = true
html.enabled = false
}
}

check.dependsOn('pmd')
}
check.dependsOn(':library:findbugs:findbugs')
check.dependsOn(':library:pmd:pmd')

// Used in pmd and findbugs subprojects.
@SuppressWarnings("GroovyUnusedDeclaration")
def classPathForQuality() {
return files(
android.bootClasspath,
Expand Down
31 changes: 31 additions & 0 deletions library/findbugs/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'findbugs'

findbugs {
toolVersion FINDBUGS_VERSION
}

def library = project(':library')

tasks.create('findbugs', FindBugs) {
dependsOn library.tasks.compileDebugJavaWithJavac

description 'Run findbugs'
group 'verification'

classes = fileTree(library.tasks.compileDebugJavaWithJavac.destinationDir)
source library.android.sourceSets.main.java.srcDirs
classpath = files()
doFirst {
classpath += library.classPathForQuality()
}
effort = 'max'
excludeFilter = file("${library.projectDir}/findbugs-exclude.xml")

// Failures are caught and printed by the violations plugin.
ignoreFailures = true

reports {
xml.enabled = true
html.enabled = false
}
}
39 changes: 39 additions & 0 deletions library/pmd/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apply plugin: 'pmd'

def library = project(':library')

pmd {
toolVersion PMD_VERSION
}

tasks.create('pmd', Pmd) {
dependsOn library.tasks.compileDebugJavaWithJavac
targetJdk = TargetJdk.VERSION_1_7

description 'Run pmd'
group 'verification'

// If ruleSets is not empty, it seems to contain some
// defaults which override rules in the ruleset file...
ruleSets = []
ruleSetFiles = files("${library.projectDir}/pmd-ruleset.xml")
source library.android.sourceSets.main.java.srcDirs
classpath = files()
classpath += files(library.tasks.compileDebugJavaWithJavac.destinationDir)
doFirst {
classpath += library.classPathForQuality()
}

//TODO enable this once new Gradle containing this flag is out
//see https://github.com/gradle/gradle/pull/3125#issuecomment-352442432
//incrementalAnalysis = true

// Failures are caught and printed by the violations plugin.
ignoreFailures = true

reports {
xml.enabled = true
html.enabled = false
}
}

2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ exec {
commandLine "git", "submodule", "update", "--init", "--recursive"
}
include ':library'
include ':library:pmd'
include ':library:findbugs'
include ':instrumentation'
include ':annotation'
include ':annotation:compiler'
Expand Down

0 comments on commit 3af80f4

Please sign in to comment.