Skip to content

Commit

Permalink
Avoid using the same name as the top-level javaVersion in Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
big-guy committed Jul 15, 2024
1 parent 3bba820 commit 8613cff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ javaApplication {

testing {
// test on 21
javaVersion = 21
testJavaVersion = 21

dependencies {
implementation("org.junit.jupiter:junit-jupiter:5.10.2")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.gradle.api.experimental.jvm.extensions.testing;

import org.gradle.api.Action;
import org.gradle.api.experimental.jvm.HasJavaTarget;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Nested;
import org.gradle.declarative.dsl.model.annotations.Configuring;
import org.gradle.declarative.dsl.model.annotations.Restricted;

@Restricted
public interface Testing extends HasJavaTarget {
public interface Testing {
@Restricted
Property<Integer> getTestJavaVersion();

@Nested
TestDependencies getDependencies();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static SourceSet createTargetSourceSet(Project project,

public static void linkTestJavaVersion(Project project, JavaToolchainService toolchains, Testing testing) {
project.getTasks().withType(Test.class).named("test").configure(task -> {
task.getJavaLauncher().set(toolchains.launcherFor(spec -> spec.getLanguageVersion().set(testing.getJavaVersion().map(JavaLanguageVersion::of))));
task.getJavaLauncher().set(toolchains.launcherFor(spec -> spec.getLanguageVersion().set(testing.getTestJavaVersion().map(JavaLanguageVersion::of))));
});
}
}

0 comments on commit 8613cff

Please sign in to comment.