Lines 47-55
Link Here
|
47 |
import java.io.File; |
47 |
import java.io.File; |
48 |
import java.net.URL; |
48 |
import java.net.URL; |
49 |
import java.util.ArrayList; |
49 |
import java.util.ArrayList; |
|
|
50 |
import java.util.Arrays; |
50 |
import java.util.HashMap; |
51 |
import java.util.HashMap; |
51 |
import java.util.HashSet; |
52 |
import java.util.HashSet; |
52 |
import java.util.LinkedList; |
|
|
53 |
import java.util.List; |
53 |
import java.util.List; |
54 |
import java.util.Map; |
54 |
import java.util.Map; |
55 |
import java.util.Set; |
55 |
import java.util.Set; |
Lines 59-64
Link Here
|
59 |
import java.util.regex.Pattern; |
59 |
import java.util.regex.Pattern; |
60 |
import org.netbeans.api.java.classpath.ClassPath; |
60 |
import org.netbeans.api.java.classpath.ClassPath; |
61 |
import org.netbeans.api.java.classpath.JavaClassPathConstants; |
61 |
import org.netbeans.api.java.classpath.JavaClassPathConstants; |
|
|
62 |
import org.netbeans.modules.apisupport.project.ManifestManager; |
62 |
import org.netbeans.spi.java.classpath.ClassPathFactory; |
63 |
import org.netbeans.spi.java.classpath.ClassPathFactory; |
63 |
import org.netbeans.spi.java.classpath.ClassPathImplementation; |
64 |
import org.netbeans.spi.java.classpath.ClassPathImplementation; |
64 |
import org.netbeans.spi.java.classpath.ClassPathProvider; |
65 |
import org.netbeans.spi.java.classpath.ClassPathProvider; |
Lines 66-72
Link Here
|
66 |
import org.netbeans.modules.apisupport.project.NbModuleProject; |
67 |
import org.netbeans.modules.apisupport.project.NbModuleProject; |
67 |
import org.netbeans.modules.apisupport.project.NbModuleProjectType; |
68 |
import org.netbeans.modules.apisupport.project.NbModuleProjectType; |
68 |
import org.netbeans.modules.apisupport.project.Util; |
69 |
import org.netbeans.modules.apisupport.project.Util; |
69 |
import org.netbeans.spi.java.classpath.FilteringPathResourceImplementation; |
70 |
import org.netbeans.modules.apisupport.project.universe.ModuleEntry; |
|
|
71 |
import org.netbeans.modules.apisupport.project.universe.ModuleList; |
70 |
import org.netbeans.spi.java.classpath.PathResourceImplementation; |
72 |
import org.netbeans.spi.java.classpath.PathResourceImplementation; |
71 |
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor; |
73 |
import org.netbeans.spi.java.classpath.support.ClassPathSupport.ResourceAcceptor; |
72 |
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; |
74 |
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport; |
Lines 264-276
Link Here
|
264 |
} |
266 |
} |
265 |
ClassPathImplementation result = ProjectClassPathSupport.createPropertyBasedClassPathImplementation( |
267 |
ClassPathImplementation result = ProjectClassPathSupport.createPropertyBasedClassPathImplementation( |
266 |
project.getProjectDirectoryFile(), project.evaluator(), new String[] {prop}, new ResourceAcceptor() { |
268 |
project.getProjectDirectoryFile(), project.evaluator(), new String[] {prop}, new ResourceAcceptor() { |
267 |
|
269 |
// XXX cache some of this for performance (need to listen to project.xml changes) |
268 |
public boolean includes(URL root, String resource) { |
270 |
public boolean includes(URL root, String resource) { |
269 |
boolean result= resource.contains("/api/") || resource.contains("/spi/"); |
271 |
File jar = FileUtil.archiveOrDirForURL(root); |
270 |
|
272 |
if (jar != null) { |
271 |
System.err.println(resource + "=" + result); |
273 |
for (ModuleEntry entry : ModuleList.getKnownEntries(jar)) { |
272 |
|
274 |
// Comes from a foreign module; check for public package status. |
273 |
return result; |
275 |
int idx = resource.lastIndexOf('/'); |
|
|
276 |
if (idx == -1) { |
277 |
// Default package never accessible. |
278 |
return false; |
279 |
} |
280 |
String pkg = resource.substring(0, idx).replace('/', '.'); |
281 |
for (ManifestManager.PackageExport export : entry.getPublicPackages()) { |
282 |
String expPkg = export.getPackage(); |
283 |
if (pkg.equals(expPkg) || export.isRecursive() && pkg.startsWith(expPkg + ".")) { |
284 |
return true; |
285 |
} |
286 |
} |
287 |
return haveImplDepOn(entry); |
288 |
} |
289 |
} |
290 |
return true; |
291 |
} |
292 |
public String algorithm(URL root) { |
293 |
File jar = FileUtil.archiveOrDirForURL(root); |
294 |
if (jar != null) { |
295 |
for (ModuleEntry entry : ModuleList.getKnownEntries(jar)) { |
296 |
return haveImplDepOn(entry) ? "impl" : Arrays.toString(entry.getPublicPackages()); // NOI18N |
297 |
} |
298 |
} |
299 |
return null; |
300 |
} |
301 |
private boolean haveImplDepOn(ModuleEntry entry) { |
302 |
Element data = project.getPrimaryConfigurationData(); |
303 |
Element moduleDependencies = Util.findElement(data, |
304 |
"module-dependencies", NbModuleProjectType.NAMESPACE_SHARED); // NOI18N |
305 |
for (Element dep : Util.findSubElements(moduleDependencies)) { |
306 |
Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N |
307 |
NbModuleProjectType.NAMESPACE_SHARED); |
308 |
String cnb = Util.findText(cnbEl); |
309 |
if (!cnb.equals(entry.getCodeNameBase())) { |
310 |
continue; |
311 |
} |
312 |
Element runDep = Util.findElement(dep, "run-dependency", // NOI18N |
313 |
NbModuleProjectType.NAMESPACE_SHARED); |
314 |
if (runDep == null) { |
315 |
return true; // ??? |
316 |
} |
317 |
if (Util.findElement(runDep, "implementation-version", |
318 |
NbModuleProjectType.NAMESPACE_SHARED) != null) { // NOI18N |
319 |
return true; |
320 |
} |
321 |
return false; |
322 |
} |
323 |
return false; // not found? |
274 |
} |
324 |
} |
275 |
}); |
325 |
}); |
276 |
|
326 |
|