From 941e82db76cb13e958e593d5dc214ac6d7a12d6b Mon Sep 17 00:00:00 2001 From: Serban Iordache Date: Wed, 26 May 2021 16:38:52 +0200 Subject: [PATCH] set inferModulePath to false for the run and test tasks --- .../org/javamodularity/moduleplugin/tasks/RunTask.java | 7 ++++++- .../org/javamodularity/moduleplugin/tasks/TestTask.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/javamodularity/moduleplugin/tasks/RunTask.java b/src/main/java/org/javamodularity/moduleplugin/tasks/RunTask.java index 6ec4285..d1609e4 100644 --- a/src/main/java/org/javamodularity/moduleplugin/tasks/RunTask.java +++ b/src/main/java/org/javamodularity/moduleplugin/tasks/RunTask.java @@ -3,6 +3,7 @@ import org.gradle.api.Project; import org.gradle.api.plugins.ApplicationPlugin; import org.gradle.api.tasks.JavaExec; +import org.gradle.util.GradleVersion; public class RunTask extends AbstractModulePluginTask { @@ -18,7 +19,11 @@ private void doConfigureRun() { if(helper().shouldFixEffectiveArguments()) { project.getTasks().replace(ApplicationPlugin.TASK_RUN_NAME, ModularJavaExec.class); } - var mutator = new RunTaskMutator(getRunTask(), project); + JavaExec runTask = getRunTask(); + if(GradleVersion.current().compareTo(GradleVersion.version("6.4")) >= 0) { + runTask.getModularity().getInferModulePath().set(false); + } + var mutator = new RunTaskMutator(runTask, project); mutator.configureRun(); project.afterEvaluate(p -> configureStartScripts()); } diff --git a/src/main/java/org/javamodularity/moduleplugin/tasks/TestTask.java b/src/main/java/org/javamodularity/moduleplugin/tasks/TestTask.java index e6667cd..fa2cebd 100644 --- a/src/main/java/org/javamodularity/moduleplugin/tasks/TestTask.java +++ b/src/main/java/org/javamodularity/moduleplugin/tasks/TestTask.java @@ -11,6 +11,7 @@ import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.testing.Test; +import org.gradle.util.GradleVersion; import org.javamodularity.moduleplugin.TestEngine; import org.javamodularity.moduleplugin.extensions.TestModuleOptions; import org.javamodularity.moduleplugin.extensions.PatchModuleContainer; @@ -42,6 +43,9 @@ public void configureTestJava() { private void configureTestJava(Test testJava) { var testModuleOptions = testJava.getExtensions().create("moduleOptions", TestModuleOptions.class, project); + if(GradleVersion.current().compareTo(GradleVersion.version("6.4")) >= 0) { + testJava.getModularity().getInferModulePath().set(false); + } // don't convert to lambda: https://github.com/java9-modularity/gradle-modules-plugin/issues/54 testJava.doFirst(new Action() { @Override