Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 23

Download

How do I get the source location of a wrapped jar?

Q: I am looking for a way to get the source location for a wrapped jar that has source specified. The Sources/SourceGroup code does not find sources attached to wrapped jars.

A: The source can be obtained by SourceForBinaryQuery.

  Set<URL> roots = new HashSet<>();
  Set<FileObject> sourceRoots = new HashSet<>();
  cps.each((cp)->{cp.entries().stream().each((e)->roots.add(e.getURL();});
  for (root : roots) {
    Collections.addAll(sourceRoots, SourceForBinaryQuery.findSourceRoots(root).getRoots());
  }

 — provided by Tomas Zezula