Skip to content

Commit 221218a

Browse files
authored
GradleLintPluginTaskConfigurer: criticalLintGradle should depend on AbstractCompile tasks, similar to other lint tasks (#411)
1 parent 5718c61 commit 221218a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/main/groovy/com/netflix/nebula/lint/plugin/GradleLintPluginTaskConfigurer.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConfigurer {
115115
fixLintGradleTask.dependsOn(project.tasks.withType(AbstractCompile))
116116
}
117117
})
118+
project.rootProject.tasks.named(CRITICAL_LINT_GRADLE).configure(new Action<Task>() {
119+
@Override
120+
void execute(Task criticalLintGradle) {
121+
criticalLintGradle.dependsOn(project.tasks.withType(AbstractCompile))
122+
}
123+
})
118124
}
119125
}
120126

src/test/groovy/com/netflix/nebula/lint/plugin/GradleLintPluginSpec.groovy

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
347347
id 'java'
348348
}
349349
350+
repositories {
351+
mavenCentral()
352+
}
353+
350354
gradleLint.rules = ['dependency-parentheses']
351355
gradleLint.criticalRules = ['dependency-tuple']
352356
@@ -370,6 +374,45 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
370374
console.every { ! it.contains('dependency-parentheses') }
371375
}
372376

377+
378+
def 'critical lint depends on compilation tasks'() {
379+
given:
380+
buildFile << """
381+
plugins {
382+
id 'nebula.lint'
383+
id 'java'
384+
}
385+
386+
repositories {
387+
mavenCentral()
388+
}
389+
390+
gradleLint.rules = ['dependency-parentheses']
391+
gradleLint.criticalRules = ['dependency-tuple']
392+
393+
dependencies {
394+
implementation('com.google.guava:guava:18.0')
395+
testImplementation group: 'junit',
396+
name: 'junit',
397+
version: '4.11'
398+
}
399+
"""
400+
disableConfigurationCache()
401+
writeHelloWorld()
402+
403+
when:
404+
def results = runTasksAndFail('criticalLintGradle')
405+
406+
then:
407+
def console = results.output.readLines()
408+
console.findAll { it.startsWith('error') }.size() == 1
409+
console.any { it.contains('dependency-tuple') }
410+
console.every { ! it.contains('dependency-parentheses') }
411+
412+
and:
413+
results.task(':classes').outcome in [TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE, TaskOutcome.FROM_CACHE]
414+
}
415+
373416
@Unroll
374417
def 'auto correct all violations on a single module project with task #taskName'() {
375418
when:

0 commit comments

Comments
 (0)