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

Fix "module not found" error when using -J--release=11 option #199

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -55,6 +55,8 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import org.xml.sax.ext.Locator2Impl;
Expand All @@ -69,6 +71,11 @@
public class WsgenTool {
private final PrintStream out;
private final WsgenOptions options = new WsgenOptions();
private static final String RELEASE_MARK = "releaseMark";
private static final String JAVA_VERSION_MARK = "javaVersion";
private static final Pattern RELEASE_VERSION_PATTERN =
Pattern.compile("(?<" + RELEASE_MARK + ">--release=)(?<" + JAVA_VERSION_MARK + ">[0-9]+)");
private static final int JAVA_MODULE_VERSION = 9;


public WsgenTool(OutputStream out, Container container) {
Expand Down Expand Up @@ -138,8 +145,24 @@ public boolean buildModel(String endpoint, Listener listener) throws BadCommandL

args.add("-d");
args.add(options.destDir.getAbsolutePath());
args.add("-classpath");

int javaVersion = 0;
if (options.javacOptions != null){
for (String option: options.javacOptions){
final Matcher matcher = RELEASE_VERSION_PATTERN.matcher(option);
if (matcher.find()){
javaVersion = Integer.parseInt(matcher.group(JAVA_VERSION_MARK));
break;
}
}
}
if (javaVersion < JAVA_MODULE_VERSION) {
args.add("-classpath");
} else {
args.add("--module-path");
}
args.add(options.classpath);

args.add("-s");
args.add(options.sourceDir.getAbsolutePath());
if (options.nocompile) {
Expand Down