Skip to content

Commit

Permalink
asconfigc: fix resolution of mainClass if asconfig.json is not in roo…
Browse files Browse the repository at this point in the history
…t of workspace (closes #718)
  • Loading branch information
joshtynjala committed Dec 11, 2023
1 parent e9b9e04 commit dcdcb70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ private void parseConfig(JsonNode json) throws ASConfigCException {
// if set already, clear it because we're going to replace it
boolean hadMainFile = mainFile != null;
String mainClass = json.get(TopLevelFields.MAIN_CLASS).asText();
mainFile = ConfigUtils.resolveMainClass(mainClass, sourcePaths);
mainFile = ConfigUtils.resolveMainClass(mainClass, sourcePaths, System.getProperty("user.dir"));
if (mainFile == null) {
throw new ASConfigCException("Main class not found in source paths: " + mainClass);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ public static String resolveMainClass(String mainClass, List<String> sourcePaths
}
// as a final fallback, try in the current working directory
Path mainClassPathAS = Paths.get(mainClassBasePath + FILE_EXTENSION_AS);
if (!mainClassPathAS.isAbsolute() && rootWorkspacePath != null) {
mainClassPathAS = Paths.get(rootWorkspacePath).resolve(mainClassPathAS);
}
if (mainClassPathAS.toFile().exists()) {
return mainClassPathAS.toString();
}
Path mainClassPathMXML = Paths.get(mainClassBasePath + FILE_EXTENSION_MXML);
if (!mainClassPathMXML.isAbsolute() && rootWorkspacePath != null) {
mainClassPathMXML = Paths.get(rootWorkspacePath).resolve(mainClassPathMXML);
}
if (mainClassPathMXML.toFile().exists()) {
return mainClassPathMXML.toString();
}
Expand Down

0 comments on commit dcdcb70

Please sign in to comment.