Skip to content

Commit

Permalink
set inferModulePath to false for the run and test tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed May 26, 2021
1 parent 2f2edf6 commit 941e82d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Task>() {
@Override
Expand Down

0 comments on commit 941e82d

Please sign in to comment.