Reputation: 16855
with maven I disabled checkstyle for tests, how can I disable the checkstyleTest
task in gradle?
I've tried variations o these separately
checkstyle {
toolVersion = '6.10.1'
exclude '**/*Test.java'
}
checkstyleTest {
sourceSets = []
}
it all ends up in errors
Upvotes: 9
Views: 28916
Reputation: 41
You can directly use the below command :
./gradle build -x checkstyleMain
Upvotes: 2
Reputation: 155
In staticAnalysis block set checkstyleEnabled to false
staticAnalysis {
checkstyleEnabled = false
}
Upvotes: 0
Reputation: 1
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/app/checkstyle.xml")
source 'src'
include '**/*.java'
exclude '**/androidTest/**'
classpath = files()
}
Upvotes: 0
Reputation: 975
As i have already said in another post link
Simply try this one
tasks.withType(Checkstyle) {
ignoreFailures true
exclude '**/**'
}
Upvotes: -2
Reputation: 17494
The cleanest way is to tell Gradle to execute only the Checkstyle tasks that you need, by specifying them like so:
checkstyle {
toolVersion = '6.10.1'
sourceSets = [project.sourceSets.main]
}
Just disabling the unneeded tasks would also work, but I think the above is cleaner.
In the above example, the checkstyleTest
task will remain in the task list, even though it is not executed. I prefer a clean task list, so you can remove the unused task via
project.tasks.remove(project.tasks['checkstyleTest']);
Upvotes: 8
Reputation: 16855
Apparently you can set the undocumented (maybe underdocumented? maybe it's inherited or something ) enabled
property on checkstyleTest
(and to access that in the closure is in no way obvious by the documentation) to false
.
checkstyle {
toolVersion = '6.10.1'
checkstyleTest.enabled = false
}
Upvotes: 10
Reputation: 120
You can set sourceSets to empty array (or [] ) to skip the task. https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.CheckstyleExtension.html#org.gradle.api.plugins.quality.CheckstyleExtension:sourceSets
Also you can use '-x checkstyleTest' to exclude the task via command line.
Upvotes: -3