Skip to content

Commit

Permalink
Drop support for Gradle older than 7.1 - Simplify LintPluginTaskConfi…
Browse files Browse the repository at this point in the history
…gurer
  • Loading branch information
rpalcolea committed Sep 20, 2024
1 parent 52d02e7 commit d3f8ef3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 Netflix, Inc.
* Copyright 2015-2024 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,11 +16,9 @@
package com.netflix.nebula.lint.plugin

import com.netflix.nebula.interop.GradleKt
import org.gradle.BuildAdapter
import org.gradle.api.BuildCancelledException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.execution.TaskExecutionGraphListener

class GradleLintPlugin implements Plugin<Project> {
@Override
Expand All @@ -31,14 +29,9 @@ class GradleLintPlugin implements Plugin<Project> {
}

LintRuleRegistry.classLoader = getClass().classLoader

// TODO: we need to retire this once we have folks in Gradle 7.1+
if (GradleKt.versionCompareTo(project.gradle, '7.1') >= 0) {
new GradleSevenOneAndHigherLintPluginTaskConfigurer().configure(project)
} else if (GradleKt.versionCompareTo(project.gradle, '7.0') >= 0) {
new GradleSevenZeroLintPluginTaskConfigurer().configure(project)
if (GradleKt.versionLessThan(project.gradle, '7.1')) {
throw new BuildCancelledException("Gradle Lint Plugin requires Gradle 7.1 or newer.")
}
new GradleLintPluginTaskConfigurer().configure(project)
}

protected static abstract class LintListener extends BuildAdapter implements TaskExecutionGraphListener {}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2015-2024 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.nebula.lint.plugin

import org.gradle.api.Action
Expand All @@ -9,8 +24,25 @@ import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.TaskState
import org.gradle.api.tasks.compile.AbstractCompile

abstract class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConfigurer {
abstract Action<GradleLintReportTask> configureReportAction(Project project, GradleLintExtension extension)
class GradleLintPluginTaskConfigurer extends AbstractLintPluginTaskConfigurer {
@Override
Action<GradleLintReportTask> configureReportAction(Project project, GradleLintExtension extension) {
new Action<GradleLintReportTask>() {
@Override
void execute(GradleLintReportTask gradleLintReportTask) {
gradleLintReportTask.reportOnlyFixableViolations = getReportOnlyFixableViolations(project, extension)
gradleLintReportTask.notCompatibleWithConfigurationCache("Gradle Lint Plugin is not compatible with configuration cache because it requires project model")

gradleLintReportTask.reports.all { report ->
def fileSuffix = report.name == 'text' ? 'txt' : report.name
report.conventionMapping.with {
required.set(report.name == getReportFormat(project, extension))
outputLocation.set(project.layout.buildDirectory.file("reports/gradleLint/${project.name}.$fileSuffix"))
}
}
}
}
}

@Override
void createTasks(Project project, GradleLintExtension lintExt) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit d3f8ef3

Please sign in to comment.