public Jar getValidJar(Jar jar, String id) throws Exception { Manifest manifest = jar.getManifest(); if (manifest == null) { trace("Wrapping with all defaults"); Builder b = new Builder(this); b.addClasspath(jar); b.setProperty("Bnd-Message", "Wrapped from " + id + "because lacked manifest"); b.setProperty(Constants.EXPORT_PACKAGE, "*"); b.setProperty(Constants.IMPORT_PACKAGE, "*;resolution:=optional"); jar = b.build(); } else if (manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) == null) { trace("Not a release 4 bundle, wrapping with manifest as source"); Builder b = new Builder(this); b.addClasspath(jar); b.setProperty(Constants.PRIVATE_PACKAGE, "*"); b.mergeManifest(manifest); String imprts = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE); if (imprts == null) imprts = ""; else imprts += ","; imprts += "*;resolution=optional"; b.setProperty(Constants.IMPORT_PACKAGE, imprts); b.setProperty("Bnd-Message", "Wrapped from " + id + "because had incomplete manifest"); jar = b.build(); } return jar; }
String wab = getProperty(WAB); String wablib = getProperty(WABLIB); if (wab == null && wablib == null) return dot; setProperty(BUNDLE_CLASSPATH, append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH))); addClose(next); trace("wab: moving: %s", path); next.putResource("WEB-INF/classes/" + path, entry.getValue()); } else { trace("wab: not moving: %s", path); next.putResource(path, entry.getValue()); Map<String, Map<String, String>> clauses = parseHeader(getProperty(WABLIB)); for (String key : clauses.keySet()) { File f = getFile(key); addWabLib(next, f); doIncludeResource(next, wab); return next;
public void setSourcepath(File[] files) { for (int i = 0; i < files.length; i++) addSourcepath(files[i]); }
public Builder getSubBuilder() throws Exception { Builder builder = new Builder(this); builder.setBase(getBase()); for (Jar file : getClasspath()) { builder.addClasspath(file); } return builder; }
public Builder getSubBuilder(File file) throws Exception { Builder builder = getSubBuilder(); if (builder != null) { builder.setProperties(file); addClose(builder); } return builder; }
/** * Intercept the call to analyze and cleanup versions after we have analyzed * the setup. We do not want to cleanup if we are going to verify. */ public void analyze() throws IOException { super.analyze(); cleanupVersion(imports); cleanupVersion(exports); String version = getProperty(BUNDLE_VERSION); if (version != null) setProperty(BUNDLE_VERSION, cleanupVersion(version)); }
builder.error("No recipe specified on a make instruction for " + destination); return null; File bndfile = builder.getFile(recipe); if (bndfile.isFile()) { Builder bchild = builder.getSubBuilder(); bchild.removeBundleSpecificHeaders(); bchild.setProperty(Analyzer.INCLUDE_RESOURCE, ""); bchild.setProperties(bndfile, builder.getBase()); Jar jar = bchild.build(); Jar dot = builder.getTarget(); if (builder.hasSources()) { for (String key : jar.getResources().keySet()) { if (key.startsWith("OSGI-OPT/src")) builder.getInfo(bchild, bndfile.getName() +": "); String debug = bchild.getProperty(DEBUG); if (Processor.isTrue(debug)) { if ( builder instanceof ProjectBuilder ) { File target = pb.getProject().getTarget(); target.mkdirs(); String bsn = bchild.getBsn(); File output = new File(target, bsn+".jar");
begin(); String conduit = getProperty(CONDUIT); if (conduit != null) { Map<String, Map<String, String>> map = parseHeader(conduit); Jar[] result = new Jar[map.size()]; int n = 0; for (String file : map.keySet()) { Jar c = new Jar(getFile(file)); addClose(c); String name = map.get(file).get("name"); if (name != null) String sub = getProperty(SUB); if (sub == null) { Jar jar = build(); if (jar == null) return new Jar[0]; Set<Instruction> subs = replaceWitInstruction(parseHeader(sub), SUB) .keySet(); List<File> members = new ArrayList<File>(Arrays.asList(getBase() .listFiles())); getProperties().remove(SUB); if (file.equals(getPropertiesFile())) continue nextFile;
public Jar build() throws Exception { init(); if (isTrue(getProperty(NOBUNDLES))) return null; if (getProperty(CONDUIT) != null) error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error"); addClose(dot); try { long modified = Long.parseLong(getProperty("base.modified")); dot.updateModified(modified, "Base modified"); } catch (Exception e) { doExpand(dot); doIncludeResources(dot); doConditional(dot); dot = doWab(dot); Manifest manifest = calcManifest(); String mf = getProperty(MANIFEST); if (mf != null) { File mff = getFile(mf); if (mff.isFile()) { try { in.close(); } catch (Exception e) {
Builder builder = new Builder(); try { builder.setPedantic(isPedantic()); builder.setProperties(properties); String out = builder.getProperty("-output"); if (out != null) { output = getFile(properties.getParentFile(), out); String prebuild = builder.getProperty("-prebuild"); if (prebuild != null) prebuild(prebuild, properties.getParentFile(), classpath, builder.getProperties().setProperty("-sources", "true"); builder.setProperty(Analyzer.FAIL_OK, "true"); Jar jar = builder.build(); getInfo(builder); if (getErrors().size() > 0 && !failok) return; String name = builder.getBsn() + DEFAULT_JAR_EXTENSION; builder.doPom(jar); builder.close();
public Jar build() throws Exception { if (getProperty(NOPE) != null) return null; String sub = getProperty(SUB); if (sub != null && sub.trim().length() > 0) error("Specified " + SUB + " but calls build() instead of builds() (might be a programmer error)"); if (getProperty(CONDUIT) != null) error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error"); addClose(dot); try { long modified = Long.parseLong(getProperty("base.modified")); dot.updateModified(modified, "Base modified"); } catch (Exception e) { doExpand(dot); doIncludeResources(dot); doConditional(dot); Manifest manifest = calcManifest(); String mf = getProperty(MANIFEST); if (mf != null) {
Builder builder = new Builder(); Properties p = new Properties(); p.putAll((Map<?, ?>) getProject().getProperties()); builder.setProperties(p); builder.setPedantic(isPedantic()); if (file.exists()) { builder.setProperties(file); .getProperties()); projectProperties.putAll(builder.getProperties()); builder.setProperties(projectProperties); builder.setClasspath(toFiles(classpath, "classpath")); builder.setSourcepath(toFiles(sourcepath, "sourcepath")); Jar jars[] = builder.builds(); File output = this.output; String path = builder.getProperty("-output"); jar.close(); builder.close();
CachedPom pom = maven.getPom(group, artifact, version, urls2); Builder a = new Builder(); a.setProperty("Private-Package", "*"); Set<Pom> dependencies = pom.getDependencies(Scope.compile, urls2); for ( Pom dep : dependencies ) { System.out.printf( "%20s %-20s %10s\n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion()); a.addClasspath(dep.getArtifact()); pw.println(a.getClasspath()); a.build(); TreeSet<String> sorted = new TreeSet<String>( a.getImports().keySet()); for ( String p :sorted) { pw.printf("%-40s\n",p); a.close(); } else System.err.println("Wrong, must look like group+artifact+version, is " + ref);
begin(); String conduit = getProperty(CONDUIT); if (conduit != null) { Map<String, Map<String, String>> map = parseHeader(conduit); Jar[] result = new Jar[map.size()]; int n = 0; for (String file : map.keySet()) { Jar c = new Jar(getFile(file)); addClose(c); String name = map.get(file).get("name"); if (name != null) List<Builder> builders; builders = getSubBuilders(); Jar jar = builder.build(); jar.setName(builder.getBsn()); result.add(jar); } catch (Exception e) { e.printStackTrace(); error("Sub Building " + builder.getBsn(), e); getInfo(builder, builder.getBsn() + ": ");
File target; builder.build(); String name = builder.getBsn() + ".jar"; Jar jar = builder.getJar(); String path = builder.getProperty("-output"); if (path == null) { target = new File(cwd, name); if (builder.getErrors().size() > 0) { activator.error(builder.getErrors()); } else { jar.write(target); jar.write(copy); if (builder.getWarnings().size() > 0) { activator.warning(builder.getWarnings()); } else { if (activator.getReportDone()) { builder.close();
void doDot(String args[], int i) throws Exception { File out = getFile("graph.gv"); Builder b = new Builder(); error("Unknown option for dot: %s", args[i]); else b.addClasspath(getFile(args[i])); b.setProperty(EXPORT_PACKAGE, "*"); b.setPedantic(isPedantic()); b.build(); FileWriter os = new FileWriter(out); PrintWriter pw = new PrintWriter(os); pw.println(" size=\"6,6\";"); pw.println("node [color=lightblue2, style=filled,shape=box];"); for (Map.Entry<String, Set<String>> uses : b.getUses().entrySet()) { for (String p : uses.getValue()) { if (!p.startsWith("java."))
Jar jar = new Jar(f); jar.setDoNotTouchManifest(); addClose(jar); String path = "WEB-INF/lib/" + f.getName(); dot.putResource(path, new JarResource(jar)); setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path)); Collection<String> parts = split(cp, ","); for (String part : parts) { File sub = getFile(f.getParentFile(), part); if (!sub.exists() || !sub.getParentFile().equals(f.getParentFile())) { warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory", sub, f); } else { addWabLib(dot, sub); error("WAB lib does not exist %s", f);
private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra) throws Exception { if (doNotCopy(from.getName())) return; if (from.isDirectory()) { File files[] = from.listFiles(); for (int i = 0; i < files.length; i++) { copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra); } } else { if (from.exists()) { Resource resource = new FileResource(from); if (preprocess) { resource = new PreprocessResource(this, resource); } String x = extra.get("extra"); if (x != null) resource.setExtra(x); if (path.endsWith("/")) path = path + from.getName(); jar.putResource(path, resource); if (isTrue(extra.get(LIB_DIRECTIVE))) { setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path)); } } else { error("Input file does not exist: " + from); } } }
static public Builder setBuilder(Activator activator, IProject project, File mf) throws Exception, IOException, FileNotFoundException { Builder builder = new Builder(); builder.setPedantic(activator.isPedantic() || activator.isDebugging()); // TODO of course we should get the classpath from // inside API ... File p = project.getLocation().toFile(); // TODO for now we ignore the workspace and use the // project parent directory EclipseClasspath ecp = new EclipseClasspath(builder, p.getParentFile(), p); builder.setClasspath((File[]) ecp.getClasspath().toArray(new File[0])); builder .setSourcepath((File[]) ecp.getSourcepath() .toArray(new File[0])); builder.setProperties(mf); return builder; }
void checkBnd(IResource resource) { if (resource instanceof IFile && resource.getName().endsWith(".bnd")) { IFile file = (IFile) resource; deleteMarkers(file); try { Builder builder = MakeBundle.setBuilder(Activator.getDefault(), resource.getProject(), file.getLocation().toFile()); try { builder.build(); builder.close(); } catch (Exception e1) { addMarker(file, "Unexpected exception: " + e1, 1, Status.ERROR); } for (Iterator<String> i = builder.getErrors().iterator(); i.hasNext();) { addMarker(file, i.next(), 1, Status.ERROR); } for (Iterator<String> i = builder.getWarnings().iterator(); i.hasNext();) { addMarker(file, i.next(), 1, Status.WARNING); } } catch (Exception e) { addMarker(file, "Really bad exception: " + e, 1, Status.ERROR); } } }