Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCOMPILER-494] - Add a useModulePath switch to the testCompile mojo #119

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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