Skip to content

Commit

Permalink
GradleLintPluginTaskConfigurer: criticalLintGradle should depend on A…
Browse files Browse the repository at this point in the history
…bstractCompile tasks, similar to other lint tasks
  • Loading branch information
rpalcolea committed Oct 28, 2024
1 parent 5718c61 commit 4d51fbb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConfigurer {
fixLintGradleTask.dependsOn(project.tasks.withType(AbstractCompile))
}
})
project.rootProject.tasks.named(CRITICAL_LINT_GRADLE).configure(new Action<Task>() {
@Override
void execute(Task criticalLintGradle) {
criticalLintGradle.dependsOn(project.tasks.withType(AbstractCompile))
}
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
repositories {
mavenCentral()
}
gradleLint.rules = ['dependency-parentheses']
gradleLint.criticalRules = ['dependency-tuple']
Expand All @@ -370,6 +374,45 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
console.every { ! it.contains('dependency-parentheses') }
}


def 'critical lint depends on compilation tasks'() {
given:
buildFile << """
plugins {
id 'nebula.lint'
id 'java'
}
repositories {
mavenCentral()
}
gradleLint.rules = ['dependency-parentheses']
gradleLint.criticalRules = ['dependency-tuple']
dependencies {
implementation('com.google.guava:guava:18.0')
testImplementation group: 'junit',
name: 'junit',
version: '4.11'
}
"""
disableConfigurationCache()
writeHelloWorld()

when:
def results = runTasksAndFail('criticalLintGradle')

then:
def console = results.output.readLines()
console.findAll { it.startsWith('error') }.size() == 1
console.any { it.contains('dependency-tuple') }
console.every { ! it.contains('dependency-parentheses') }

and:
results.task(':classes').outcome in [TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE, TaskOutcome.FROM_CACHE]
}

@Unroll
def 'auto correct all violations on a single module project with task #taskName'() {
when:
Expand Down

0 comments on commit 4d51fbb

Please sign in to comment.