Skip to content

Commit

Permalink
Use notCompatibleWithConfigurationCache to avoid breaking builds when…
Browse files Browse the repository at this point in the history
… using gradle lint
  • Loading branch information
rpalcolea committed Nov 27, 2023
1 parent 526924c commit 4f247d1
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ abstract class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConf
group = LINT_GROUP
listeners.set(lintExt.listeners)
projectRootDir.set(project.rootDir)
notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")
}

def manualLintTask = project.tasks.register(LINT_GRADLE, LintGradleTask)
manualLintTask.configure {
group = LINT_GROUP
failOnWarning.set(true)
projectRootDir.set(project.rootDir)
notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")
}


Expand All @@ -35,17 +37,20 @@ abstract class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConf
group = LINT_GROUP
onlyCriticalRules.set(true)
projectRootDir.set(project.rootDir)
notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")
}


def fixTask = project.tasks.register(FIX_GRADLE_LINT, FixGradleLintTask)
fixTask.configure {
userDefinedListeners.set(lintExt.listeners)
notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")
}

def fixTask2 = project.tasks.register(FIX_LINT_GRADLE, FixGradleLintTask)
fixTask2.configure {
userDefinedListeners.set(lintExt.listeners)
notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")
}

List<TaskProvider> lintTasks = [fixTask, fixTask2, manualLintTask]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class GradleSevenOneAndHigherLintPluginTaskConfigurer extends GradleSevenZeroLin
@Override
void execute(GradleLintReportTask gradleLintReportTask) {
gradleLintReportTask.reportOnlyFixableViolations = getReportOnlyFixableViolations(project, extension)
gradleLintReportTask.notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because ir requires project model")

gradleLintReportTask.reports.all { report ->
def fileSuffix = report.name == 'text' ? 'txt' : report.name
report.conventionMapping.with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import nebula.test.IntegrationTestKitSpec
abstract class BaseIntegrationTestKitSpec extends IntegrationTestKitSpec {
def setup() {
// Enable configuration cache :)
//new File(projectDir, 'gradle.properties') << '''org.gradle.configuration-cache=true'''.stripIndent()
new File(projectDir, 'gradle.properties') << '''org.gradle.configuration-cache=true'''.stripIndent()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import spock.lang.Issue
import spock.lang.Unroll

class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
def setup() {
debug = true
}

def 'run multiple rules on a single module project'() {
when:
Expand All @@ -33,7 +30,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'nebula.lint'
id 'java'
}
repositories {
mavenCentral()
}
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
dependencies {
Expand Down Expand Up @@ -64,6 +63,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
repositories {
mavenCentral()
}
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
dependencies {
Expand Down Expand Up @@ -129,14 +131,17 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
subprojects {
apply plugin: 'java'
apply plugin: 'nebula.lint'
repositories {
mavenCentral()
}
}
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
"""

addSubproject('sub', """
dependencies {
implementation('a:a:1')
implementation('com.google.guava:guava:19.0')
}
""")

Expand Down Expand Up @@ -286,6 +291,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
subprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
implementation('com.google.guava:guava:18.0')
}
Expand Down Expand Up @@ -373,6 +381,10 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
repositories {
mavenCentral()
}
dependencies {
implementation('com.google.guava:guava:18.0')
}
Expand All @@ -389,6 +401,10 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple']
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.guava:guava:18.0'
}
Expand All @@ -413,6 +429,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
subprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
implementation('com.google.guava:guava:18.0')
}
Expand Down Expand Up @@ -454,9 +473,11 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
addSubproject('sub', """
apply plugin: 'java'
apply plugin: 'nebula.lint'
repositories {
mavenCentral()
}
dependencies {
implementation('a:a:1')
implementation('com.google.guava:guava:19.0')
}
""")

Expand Down Expand Up @@ -573,6 +594,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
gradleLint.rules = ['dependency-parentheses']
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand All @@ -599,6 +623,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
rules = ['dependency-parentheses']
alwaysRun = false
}
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand Down Expand Up @@ -674,6 +701,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
gradleLint.rules = ['dependency-parentheses']
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand All @@ -698,6 +728,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
gradleLint.rules = ['dependency-parentheses']
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand All @@ -717,12 +750,16 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
@Unroll
def 'lint task does not run for task #taskName'() {
when:
disableConfigurationCache() // component and model report are not config cache compatible anyway
buildFile << """
plugins {
id 'nebula.lint'
id 'java'
}
gradleLint.rules = ['dependency-parentheses']
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand Down Expand Up @@ -754,6 +791,9 @@ class GradleLintPluginSpec extends BaseIntegrationTestKitSpec {
id 'java'
}
gradleLint.rules = ['dependency-parentheses']
repositories {
mavenCentral()
}
dependencies {
implementation('commons-logging:commons-logging:latest.release')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DependencyServiceSpec extends BaseIntegrationTestKitSpec {
apply plugin: 'java'
repositories { mavenCentral() }
}
disableConfigurationCache()
}

def 'check if configuration is resolved'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import spock.lang.Subject
@Subject(DependencyService)
class FindMethodReferencesSpec extends BaseIntegrationTestKitSpec {

def setup(){
disableConfigurationCache()
}

def 'find method references no exclusion'() {
buildFile.text = """\
import com.netflix.nebula.lint.rule.dependency.*
Expand Down

0 comments on commit 4f247d1

Please sign in to comment.