Skip to content

Commit 8dc971e

Browse files
author
jossonsmith
committed
Merge with /trunk for *.j2x support over cross project references
1 parent bc2e49c commit 8dc971e

File tree

6 files changed

+48
-12
lines changed

6 files changed

+48
-12
lines changed

src/net/sf/j2s/ui/classpath/CompositeResources.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sf.j2s.ui.classpath;
22

33
import java.io.File;
4+
import java.io.FileFilter;
45
import java.io.FileInputStream;
56
import java.io.FileNotFoundException;
67
import java.io.IOException;
@@ -257,6 +258,25 @@ public String toJ2XString() {
257258
if (resources == null) {
258259
this.load();
259260
}
261+
if (this instanceof ProjectResources) {
262+
ProjectResources pr = (ProjectResources) this;
263+
File binFolder = new File(pr.getAbsoluteFolder(), this.binRelativePath);
264+
File[] files = binFolder.listFiles(new FileFilter() {
265+
public boolean accept(File pathname) {
266+
if (pathname.isFile() && pathname.getName().endsWith(".j2x")) {
267+
return true;
268+
}
269+
return false;
270+
}
271+
});
272+
if (files != null && files.length != 0) {
273+
for (int i = 0; i < files.length; i++) {
274+
buf.append(files[i].getAbsolutePath());
275+
buf.append(',');
276+
}
277+
return buf.toString();
278+
}
279+
}
260280
for (Iterator iter = resources.iterator(); iter.hasNext();) {
261281
Resource res = (Resource) iter.next();
262282
if (!J2SCyclicProjectUtils.visit(res)) {
@@ -290,6 +310,33 @@ public String existedClassesString() {
290310
if (resources == null) {
291311
this.load();
292312
}
313+
if (this instanceof ProjectResources) {
314+
ProjectResources pr = (ProjectResources) this;
315+
File binFolder = new File(pr.getAbsoluteFolder(), this.binRelativePath);
316+
File[] files = binFolder.listFiles(new FileFilter() {
317+
public boolean accept(File pathname) {
318+
if (pathname.isFile() && pathname.getName().endsWith(".j2x")) {
319+
return true;
320+
}
321+
return false;
322+
}
323+
});
324+
if (files != null && files.length != 0) { // should always one *.j2x file
325+
Properties prop = new Properties();
326+
try {
327+
prop.load(new FileInputStream(files[0]));
328+
} catch (FileNotFoundException e) {
329+
e.printStackTrace();
330+
} catch (IOException e) {
331+
e.printStackTrace();
332+
}
333+
String pkg = prop.getProperty("package.prefix");
334+
File pkgFile = new File(files[0].getParentFile(), pkg.replace('.', '/') + "/package.js");
335+
if (pkgFile.exists()) {
336+
return buf.toString();
337+
}
338+
}
339+
}
293340
buf.append('[');
294341
try {
295342
buf.append(new File(getAbsoluteFolder(), binRelativePath).getCanonicalPath());

src/net/sf/j2s/ui/classpath/IRuntimeClasspathEntry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
import org.eclipse.core.resources.IResource;
15-
import org.eclipse.core.runtime.CoreException;
1615
import org.eclipse.core.runtime.IPath;
1716
import org.eclipse.jdt.core.IClasspathEntry;
1817
import org.eclipse.jdt.core.IJavaProject;

src/net/sf/j2s/ui/classpath/ProjectResources.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.sf.j2s.ui.classpath;
22

33
import java.io.File;
4-
import java.util.Iterator;
54

65

76
public class ProjectResources extends CompositeResources {

src/net/sf/j2s/ui/classpath/Resource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.eclipse.jdt.core.IJavaModel;
1212
import org.eclipse.jdt.core.IJavaProject;
1313
import org.eclipse.jdt.core.JavaCore;
14-
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
1514

1615
public class Resource implements IRuntimeClasspathEntry {
1716
private Resource parent;

src/net/sf/j2s/ui/launching/J2SLaunchingUtil.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,18 +623,12 @@ private static String generateHTML(ILaunchConfiguration configuration,
623623
buf.append(j2sLibPath);
624624
buf.append("\", true);\r\n");
625625
}
626-
if (j2xStr.indexOf("\"junit\"") == -1) {
627-
buf.append("ClazzLoader.packageClasspath (\"junit\", \"");
628-
buf.append(j2sLibPath);
629-
buf.append("\", true);\r\n");
630-
}
631626
buf.append(j2xStr);
632627

633628
buf.append("ClazzLoader.setPrimaryFolder (\"");
634629
buf.append(relativePath);
635630
buf.append("\");\r\n");
636631

637-
638632
J2SCyclicProjectUtils.emptyTracks();
639633
buf.append(generateClasspathIgnoredClasses(configuration, mainType, workingDir));
640634

src/net/sf/j2s/ui/launching/J2SUnitLaunchingUtil.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ private static String generateHTML(ILaunchConfiguration configuration,
627627
buf.append("\", true);\r\n");
628628
}
629629
buf.append(j2xStr);
630-
630+
631631
buf.append("ClazzLoader.setPrimaryFolder (\"");
632632
buf.append(relativePath);
633633
buf.append("\");\r\n");
@@ -638,8 +638,6 @@ private static String generateHTML(ILaunchConfiguration configuration,
638638
J2SCyclicProjectUtils.emptyTracks();
639639
buf.append(generateClasspathExistedClasses(configuration, mainType, workingDir));
640640

641-
//String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
642-
643641
//String args = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
644642
buf.append("ClazzLoader.loadClass (\"junit.textui.TestRunner\", function () {\r\n");
645643
buf.append("ClazzLoader.loadClass (\"" + mainType + "\", function () {\r\n");

0 commit comments

Comments
 (0)