Summary: | Heuristic to differ between internal JAR and external JAR. | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Aeschlimann <martinae> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | renaud+eclipse |
Version: | 2.0 | ||
Target Milestone: | 2.1 M2 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Martin Aeschlimann
2002-10-01 03:32:45 EDT
I've implemented the aforementioned heuristic with the following code, but I'm not positive it is truly the best solution: // entry path is relative to workspace dir if (!entry.getPath().toFile().isAbsolute()) { entry = makeAbsolute(entry, project); } private static IClasspathEntry makeAbsolute(IClasspathEntry entry, IJavaProject project) { IPath projectDir = project.getProject().getLocation(); IPath entryFullPath = projectDir.append(entry.getPath().removeFirstSegments (1)); return new ClasspathEntry( entry.getContentKind(), entry.getEntryKind(), entryFullPath, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.isExported()); } As Martin said, we'd much rather leverage something in JCore that returns the true absolute path. JDT/Core always gives precedence to resource over external file. The heuristic is implemented in: JavaModel.getTarget(IContainer container,IPath path, boolean checkResourceExistence) We may indeed surface it on IJavaModel... however don't you already have the corresponding root in your hand ? If so, you should simply ask it whether it is external or not (IPackageFragmentRoot#isExternal). Ok to close? I just saw that IJavaProject.findPackageFragmentRoot is the method that implements the heuristic. Ok to close. Great. Thanks guys! Closing Closing |