Skip to content

Commit

Permalink
issue #190: Module classpath should filter invalid items in run task
Browse files Browse the repository at this point in the history
  • Loading branch information
siordache committed May 26, 2021
1 parent b868214 commit 2f2edf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.javamodularity.moduleplugin.extensions.PatchModuleContainer;
import org.javamodularity.moduleplugin.internal.MutatorHelper;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class RunTaskMutator extends AbstractExecutionMutator {
private static final Logger LOGGER = Logging.getLogger(RunTaskMutator.class);
Expand Down Expand Up @@ -46,11 +47,14 @@ private List<String> buildJavaExecJvmArgs() {
moduleOptions.mutateArgs(jvmArgs);

FileCollection classpath = mergeClassesHelper().getMergeAdjustedClasspath(execTask.getClasspath());
FileCollection filteredClasspath = project.files(classpath.getFiles().stream()
.filter(f -> f.isDirectory() || f.getName().endsWith(".jar") || f.getName().endsWith(".jmod"))
.collect(Collectors.toList()).toArray());
var patchModuleContainer = PatchModuleContainer.copyOf(
helper().modularityExtension().optionContainer().getPatchModuleContainer());
patchModuleContainer.addDir(moduleName, helper().mainSourceSet().getOutput().getResourcesDir().getAbsolutePath());
patchModuleContainer.buildModulePathOption(classpath).ifPresent(option -> option.mutateArgs(jvmArgs));
patchModuleContainer.mutator(classpath).mutateArgs(jvmArgs);
patchModuleContainer.buildModulePathOption(filteredClasspath).ifPresent(option -> option.mutateArgs(jvmArgs));
patchModuleContainer.mutator(filteredClasspath).mutateArgs(jvmArgs);

jvmArgs.addAll(execTask.getJvmArgs());

Expand Down

0 comments on commit 2f2edf6

Please sign in to comment.