Skip to content

Commit

Permalink
[MCOMPILER-494] - Add a useModulePath switch to the testCompile m…
Browse files Browse the repository at this point in the history
…ojo (#119)

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
  • Loading branch information
dmlloyd and gnodet committed Feb 13, 2023
1 parent f4a8a54 commit 4022bd0
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ public class TestCompilerMojo extends AbstractCompilerMojo {
@Parameter(defaultValue = "${project.build.directory}/generated-test-sources/test-annotations")
private File generatedTestSourcesDirectory;

/**
* <p>
* When {@code true}, uses the module path when compiling with a release or target of 9+ and
* <em>module-info.java</em> or <em>module-info.class</em> is present.
* When {@code false}, always uses the class path.
* </p>
*
* @since 3.11
*/
@Parameter(defaultValue = "true")
private boolean useModulePath;

@Parameter(defaultValue = "${project.testClasspathElements}", readonly = true)
private List<String> testPath;

Expand Down Expand Up @@ -288,6 +300,12 @@ protected void preparePaths(Set<File> sourceFiles) {
testModuleDescriptor = result.getMainModuleDescriptor();
}

if (!useModulePath) {
pathElements = Collections.emptyMap();
modulepathElements = Collections.emptyList();
classpathElements = testPath;
return;
}
if (StringUtils.isNotEmpty(getRelease())) {
if (Integer.parseInt(getRelease()) < 9) {
pathElements = Collections.emptyMap();
Expand Down

0 comments on commit 4022bd0

Please sign in to comment.