diff --git a/java/java.mx.project/build.xml b/java/java.mx.project/build.xml
index bbd780a0f10f..5f642f0a9742 100644
--- a/java/java.mx.project/build.xml
+++ b/java/java.mx.project/build.xml
@@ -31,7 +31,7 @@
-
+
@@ -41,7 +41,7 @@
-
+
diff --git a/java/java.mx.project/src/org/netbeans/modules/java/mx/project/suitepy/Parse.java b/java/java.mx.project/src/org/netbeans/modules/java/mx/project/suitepy/Parse.java
index ca6a5edcfcc5..dbc623046b82 100644
--- a/java/java.mx.project/src/org/netbeans/modules/java/mx/project/suitepy/Parse.java
+++ b/java/java.mx.project/src/org/netbeans/modules/java/mx/project/suitepy/Parse.java
@@ -63,13 +63,15 @@ private MxSuite parseImpl(URL u) throws IOException {
if (line == null) {
break;
}
- sb.append(jsonify(line)).append("\n");
+ line = line.replaceAll("(\\s*)#.*", "$1");
+ sb.append(line).append("\n");
}
}
+ String text = jsonify(sb.toString());
Object value;
try {
final JSONParser p = new JSONParser();
- value = p.parse(sb.toString());
+ value = p.parse(text);
} catch (ParseException ex) {
throw new IOException("Cannot parse " + u, ex);
}
@@ -78,9 +80,8 @@ private MxSuite parseImpl(URL u) throws IOException {
}
private static String jsonify(String content) {
- String text = content.replaceFirst("^suite *= *\\{", "{");
+ String text = content.replaceFirst("\\s*suite *= *\\{", "{");
text = text.replace("True", "true").replace("False", "false");
- text = text.replaceAll("(\\s*)#.*", "$1");
text = text.replaceAll(",\\s*(\\]|\\})", "$1");
text = replaceQuotes("\"\"\"", text);
text = replaceQuotes("'''", text);
diff --git a/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/SdkSuiteTest.java b/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/SdkSuiteTest.java
index df4bfd254afb..1bff3c513a3f 100644
--- a/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/SdkSuiteTest.java
+++ b/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/SdkSuiteTest.java
@@ -20,14 +20,21 @@
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
+import org.netbeans.api.java.queries.BinaryForSourceQuery;
import org.netbeans.api.java.queries.SourceForBinaryQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.api.project.SourceGroup;
+import org.netbeans.api.project.Sources;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -50,31 +57,26 @@ public void testRootsForAnSdkJar() throws Exception {
FileObject fo = FileUtil.toFileObject(sdkSibling);
assertNotNull("project directory found", fo);
- FileObject graalSdkJar = FileUtil.createData(fo, "mxbuild/dists/jdk1.8/graal-sdk.jar");
- assertNotNull(graalSdkJar);
-
Project p = ProjectManager.getDefault().findProject(fo);
assertNotNull("project found", p);
assertEquals("It is suite project: " + p, "SuiteProject", p.getClass().getSimpleName());
+ Sources src = ProjectUtils.getSources(p);
+ List resultRoots = new ArrayList<>();
+ for (SourceGroup sourceGroup : src.getSourceGroups("java")) {
+ BinaryForSourceQuery.Result binaryResult = BinaryForSourceQuery.findBinaryRoots(sourceGroup.getRootFolder().toURL());
+ for (URL r : binaryResult.getRoots()) {
+ SourceForBinaryQuery.Result2 result2 = SourceForBinaryQuery.findSourceRoots2(r);
+ final FileObject[] rr = result2.getRoots();
+ resultRoots.addAll(Arrays.asList(rr));
+ }
+ }
- final URL archiveURL = new URL("jar:" + graalSdkJar.toURL() + "!/");
-
- SourceForBinaryQuery.Result2 result2 = SourceForBinaryQuery.findSourceRoots2(archiveURL);
- final FileObject[] resultRoots = result2.getRoots();
- assertTrue("There should be some roots", resultRoots.length > 0);
+ assertTrue("There should be some roots", !resultRoots.isEmpty());
Set expected = new HashSet<>();
for (FileObject ch : fo.getFileObject("src").getChildren()) {
- if (ch.getNameExt().endsWith(".test")) {
- // tests are not in graal-sdk.jar
- continue;
- }
- if (ch.getNameExt().endsWith(".tck")) {
- // TCK is not in graal-sdk.jar
- continue;
- }
- if (ch.getNameExt().contains("org.graalvm.launcher")) {
- // launcher is not in graal-sdk.jar
+ if (ch.getNameExt().equals("org.graalvm.launcher.native")) {
+ // Not a Java code
continue;
}
expected.add(ch);