diff --git a/changelog/@unreleased/pr-2739.v2.yml b/changelog/@unreleased/pr-2739.v2.yml new file mode 100644 index 000000000..1c31ba333 --- /dev/null +++ b/changelog/@unreleased/pr-2739.v2.yml @@ -0,0 +1,6 @@ +type: fix +fix: + description: Make checkJavaVersions task more amenable to gradle8 configuration + cache + links: + - https://github.com/palantir/gradle-baseline/pull/2739 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/BaselineJavaVersion.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/BaselineJavaVersion.java index 673ea397b..cfdaf2fa4 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/BaselineJavaVersion.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/javaversions/BaselineJavaVersion.java @@ -84,6 +84,7 @@ public void execute(JavaToolchainSpec javaToolchainSpec) { public void execute(CheckJavaVersionsTask task) { task.getTargetVersion().set(extension.target()); task.getRuntimeVersion().set(extension.runtime()); + task.getProjectDisplayName().set(project.getDisplayName()); } }); project.getTasks().named("check").configure(check -> check.dependsOn(checkJavaVersions)); @@ -218,6 +219,7 @@ public static class CheckJavaVersionsTask extends DefaultTask { private final Property targetVersion; private final Property runtimeVersion; + private final Property projectDisplayName; @Inject public CheckJavaVersionsTask() { @@ -226,6 +228,7 @@ public CheckJavaVersionsTask() { + "The runtime version must be greater than or equal to the target version."); targetVersion = getProject().getObjects().property(ChosenJavaVersion.class); runtimeVersion = getProject().getObjects().property(ChosenJavaVersion.class); + projectDisplayName = getProject().getObjects().property(String.class); } @Input @@ -238,6 +241,11 @@ public Property getRuntimeVersion() { return runtimeVersion; } + @Input + Property getProjectDisplayName() { + return projectDisplayName; + } + @TaskAction public final void checkJavaVersions() { ChosenJavaVersion target = getTargetVersion().get(); @@ -245,7 +253,7 @@ public final void checkJavaVersions() { getLogger() .debug( "BaselineJavaVersion configured project {} with target version {} and runtime version {}", - getProject(), + projectDisplayName, target, runtime);