private void verifyDependencies(String title, Collection<Container> path) throws Exception { List<String> msgs = new ArrayList<String>(); for (Container c : new ArrayList<Container>(path)) { for (Container cc : c.getMembers()) { if (cc.getError() != null) msgs.add(cc + " - " + cc.getError()); else if (!cc.getFile().isFile() && !cc.getFile().equals(cc.getProject().getOutput()) && !cc.getFile().equals(cc.getProject().getTestOutput())) msgs.add(cc + " file does not exists: " + cc.getFile()); } } if (msgs.isEmpty()) return; error("%s: has errors: %s", title, Strings.join(msgs)); }
/** * @param bsn * @param range * @param attrs * @param result * @return */ protected Container toContainer(String bsn, String range, Map<String, String> attrs, File result) { if (result == null) { System.out.println("Huh?"); } if (result.getName().endsWith("lib")) return new Container(this, bsn, range, Container.TYPE.LIBRARY, result, null, attrs); else return new Container(this, bsn, range, Container.TYPE.REPO, result, null, attrs); }
/** * Iterate over the entries and place the projects on the projects list and * all the files of the entries on the resultpath. * * @param resultpath * The list that gets all the files * @param projects * The list that gets any projects that are entries * @param entries * The input list of classpath entries */ private void doPath(Collection<Container> resultpath, Collection<Project> projects, Collection<Container> entries, Collection<Container> bootclasspath) { for (Container cpe : entries) { if (cpe.getError() != null) error(cpe.getError()); else { if (cpe.getType() == Container.TYPE.PROJECT) { projects.add(cpe.getProject()); } if (bootclasspath != null && (cpe.getBundleSymbolicName().startsWith("ee.") || cpe.getAttributes().containsKey("boot"))) bootclasspath.add(cpe); else resultpath.add(cpe); } } }
/** * Flatten a container in the output list. (e.g. expand any libraries). * * @param container the container to flatten * @param list the result list */ public static void flatten(Container container, List<Container> list) throws Exception { if (container.getType() == TYPE.LIBRARY) { flatten(container.getMembers(), list); } else list.add(container); }
public String getColumnText(Object element, int columnIndex) { Container c = (Container) element; switch (columnIndex) { case 0: return c.getBundleSymbolicName(); case 1: return c.getVersion(); case 2: return c.getError(); case 3: return c.getFile() + " (" + (c.getFile()!=null && c.getFile().exists() ? "exists" : "?") + ")"; } return null; }
private void add(List<String> paths, Container container) throws Exception { if (container.getType() == Container.TYPE.LIBRARY) { List<Container> members = container.getMembers(); for (Container sub : members) { add(paths, sub); } } else { if (container.getError() == null) paths.add(container.getFile().getAbsolutePath()); else { paths.add("<<${repo} = " + container.getBundleSymbolicName() + "-" + container.getVersion() + " : " + container.getError() + ">>"); if (isPedantic()) { warning("Could not expand repo path request: %s ", container); } } } }
IPath sourceAttachment = null; if (c.getError() == null) { File file = c.getFile(); assert file.isAbsolute(); if ( c.getType()==Container.TYPE.PROJECT ) { File sourceDir = c.getProject().getSrc(); if (sourceDir.isDirectory() ) sourceAttachment = Central.toPath(c.getProject(), sourceDir );
Manifest manifest = c.getManifest(); Class<?> clz = getClass(launcher, c.getFile()); if (clz != null) { if (!target.isAssignableFrom(clz)) {
String prefix = "cnf/repo/"; switch (c.getType()) { case ERROR: error("Dependencies include %s", c.getError()); return; String name = getName(skip, prefix, c, ".jar"); if (name != null) output.putResource(name, new FileResource(c.getFile())); trace("storing %s in %s", c, name); break; String name = getName(skip, prefix, c, ".lib"); if (name != null) { output.putResource(name, new FileResource(c.getFile())); trace("store library %s", name); for (Container child : c.getMembers()) { trace("store member %s", child); addContainer(skip, output, child);
private void deliverables(String[] args, int i) throws Exception { Project project = getProject(); long start = System.currentTimeMillis(); Collection<Project> projects = project.getWorkspace().getAllProjects(); List<Container> containers = new ArrayList<Container>(); for (Project p : projects) { containers.addAll(p.getDeliverables()); } long duration = System.currentTimeMillis() - start; System.out.println("Took " + duration + " ms"); for (Container c : containers) { Version v = new Version(c.getVersion()); System.out.printf("%-40s %d.%d.%d %s\n", c.getBundleSymbolicName(), v.getMajor(), v.getMinor(), v.getMicro(), c.getFile()); } }
case EXTERNAL : case REPO : files.add(getFile()); return true; List<Container> containers = getMembers(); for (Container container : containers) { if (!container.contributeFiles(files, reporter)) return false;
private List<File> getBundles(Collection<Container> containers, Processor reporter) throws Exception { List<File> files = new ArrayList<>(); for (Container container : containers) { switch (container.getType()) { case ERROR : // skip, already reported break; case PROJECT : case EXTERNAL : case REPO : files.add(container.getFile()); break; case LIBRARY : container.contributeFiles(files, reporter); break; } } return files; }
if (bce == null) { return bundleClasspathExpansion = new File[] { getFile() }; File file = getFile(); Manifest m = getManifest(); String bundleClassPath; if (m == null || (bundleClassPath = m.getMainAttributes() files.add(file); } else { File member = new File(bundleClasspathDirectory, n + "-" + toName(entry.getKey())); if (!isCurrent(file, member)) {
List<Container> libs = found.getMembers(); for (Container cc : libs) { Container existing = pkgResolvedBundles.get(cc.file); String importUses = cc.getAttributes().get("import-uses"); if (importUses != null) queue.addAll(0, parseHeader(importUses).entrySet()); Container x = new Container(this, "X", versionRange, Container.TYPE.ERROR, null, "package " + pkgName + ";version=" + versionRange + " not found", attrs); resolvedBundles.add(x);
static void addToPackageList(Container container, String newPackageNames) { Set<String> merged = new HashSet<>(); String packageListStr = container.getAttributes() .get("packages"); if (packageListStr != null) mergeNames(packageListStr, merged); if (newPackageNames != null) mergeNames(newPackageNames, merged); container.putAttribute("packages", flatten(merged)); }
Container found = null; for (Container c : testpath) { if (c.getAttributes().containsKey("framework")) { if (found != null) { warning("Specifying multiple framework classes on the " + Constants.RUNPATH + "\n" + "Previous found: " + found.getProject() + " " + found.getAttributes() + "\n" + "Now found : " + c.getProject() + " " + c.getAttributes()); programArguments.add(c.getAttributes().get("framework")); found = c; if (c.getAttributes().containsKey("factory")) { if (found != null) { warning("Specifying multiple framework factories on the " + Constants.RUNPATH + "\n" + "Previous found: " + found.getProject() + " " + found.getAttributes() + "\n" + "Now found : " + c.getProject() + " " + c.getAttributes()); programArguments.add(c.getAttributes().get("factory")); found = c; String exports = c.getAttributes().get("export"); if (exports != null) { String parts[] = exports.split("\\s*,\\s*");
/** * Add a path to the system resource. This is done by the bnd launcher for * -runpath and it is also used for -distro. */ @Override public void loadPath(ResourceBuilder system, String path, String what) throws Exception { if (project != null) { List<Container> containers = Container.flatten(project.getBundles(Strategy.HIGHEST, path, what)); for (Container c : containers) { Manifest manifest = c.getManifest(); if (manifest != null) { ResourceBuilder rb = new ResourceBuilder(); rb.addManifest(Domain.domain(manifest)); addSystemResource(system, rb.build()); } } } else { super.loadPath(system, path, what); } }