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

versions plugin requires gradle 7 #1965

Merged
merged 2 commits into from
Nov 8, 2021
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
7 changes: 7 additions & 0 deletions changelog/@unreleased/pr-1965.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: fix
fix:
description: The `com.palantir.baseline-java-versions` plugin requires gradle 7
and fails eagerly on older versions. Previously it would cause non-obvious failures
later depending on task execution.
links:
- https://github.com/palantir/gradle-baseline/pull/1965
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,24 @@
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.ivy.IvyPublication;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.util.GradleVersion;

public final class BaselineJavaVersions implements Plugin<Project> {

public static final String EXTENSION_NAME = "javaVersions";

public static final GradleVersion MIN_GRADLE_VERSION = GradleVersion.version("7.0");

@Override
public void apply(Project project) {
if (!Objects.equals(project, project.getRootProject())) {
throw new GradleException("BaselineJavaVersions may only be applied to the root project");
}
GradleVersion currentGradleVersion = GradleVersion.current();
if (currentGradleVersion.compareTo(MIN_GRADLE_VERSION) < 0) {
throw new GradleException(String.format(
"BaselineJavaVersions requires %s. %s is not supported", MIN_GRADLE_VERSION, currentGradleVersion));
}
BaselineJavaVersionsExtension rootExtension =
project.getExtensions().create(EXTENSION_NAME, BaselineJavaVersionsExtension.class, project);
project.allprojects(proj -> proj.getPluginManager().withPlugin("java", unused -> {
Expand Down