Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Gradle older than 7.1 - Simplify LintPluginTaskConfigurer #408

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading