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

Make checkJavaVersions task more amenable to gradle8 configuration cache #2739

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-2739.v2.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -218,6 +219,7 @@ public static class CheckJavaVersionsTask extends DefaultTask {

private final Property<ChosenJavaVersion> targetVersion;
private final Property<ChosenJavaVersion> runtimeVersion;
private final Property<String> projectDisplayName;

@Inject
public CheckJavaVersionsTask() {
Expand All @@ -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
Expand All @@ -238,14 +241,19 @@ public Property<ChosenJavaVersion> getRuntimeVersion() {
return runtimeVersion;
}

@Input
Property<String> getProjectDisplayName() {
return projectDisplayName;
}

@TaskAction
public final void checkJavaVersions() {
ChosenJavaVersion target = getTargetVersion().get();
ChosenJavaVersion runtime = getRuntimeVersion().get();
getLogger()
.debug(
"BaselineJavaVersion configured project {} with target version {} and runtime version {}",
getProject(),
projectDisplayName,
target,
runtime);

Expand Down