JavaHT GetSourceLocationOfWrappedJar

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

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo