public Jar getValidJar(URL url) throws Exception { InputStream in = url.openStream(); try { Jar jar = new Jar(url.getFile().replace('/', '.'), in, System.currentTimeMillis()); return getValidJar(jar, url.toString()); } finally { in.close(); } }
/** * This methods attempts to turn any jar into a valid jar. If this is a * bundle with manifest, a manifest is added based on defaults. If it is a * bundle, but not r4, we try to add the r4 headers. * * @param descriptor * @param in * @return * @throws Exception */ public Jar getValidJar(File f) throws Exception { Jar jar = new Jar(f); return getValidJar(jar, f.getAbsolutePath()); }
void add(File jar) throws Exception { add(new Jar(jar)); }
/** * Sets the executable class name in the given jar */ protected void setMainClass(ProcessConfig config, File installDir, File jarFile, int id, String mainClass) throws Exception { File tmpFile = File.createTempFile("fuse-process-" + id, ".jar"); Files.copy(jarFile, tmpFile); Jar jar = new Jar(tmpFile); Attributes attributes = jar.getManifest().getMainAttributes(); attributes.putValue("Main-Class", mainClass); jar.write(jarFile); }
public void addClasspath(File cp) throws IOException { if (!cp.exists()) warning("File on classpath that does not exist: " + cp); Jar jar = new Jar(cp); addClose(jar); classpath.add(jar); }
public void addClasspath(File cp) throws IOException { if (!cp.exists()) warning("File on classpath that does not exist: " + cp); Jar jar = new Jar(cp); addClose(jar); classpath.add(jar); }
/** * @return * @throws IOException * @throws MalformedURLException */ protected Jar getJarFromFileOrURL(String spec) throws IOException, MalformedURLException { Jar jar; File jarFile = getFile(spec); if (jarFile.exists()) { jar = new Jar(jarFile); } else { URL url = new URL(spec); InputStream in = url.openStream(); try { jar = new Jar(url.getFile(), in); } finally { in.close(); } } addClose(jar); return jar; }
/** * @return * @throws IOException * @throws MalformedURLException */ protected Jar getJarFromFileOrURL(String spec) throws IOException, MalformedURLException { Jar jar; File jarFile = getFile(spec); if (jarFile.exists()) { jar = new Jar(jarFile); } else { URL url = new URL(spec); InputStream in = url.openStream(); try { jar = new Jar(url.getFile(), in); } finally { in.close(); } } addClose(jar); return jar; }
/** * Set the classpath for this analyzer by file. * * @param classpath * @throws IOException */ public void setClasspath(File[] classpath) throws IOException { List<Jar> list = new ArrayList<Jar>(); for (int i = 0; i < classpath.length; i++) { if (classpath[i].exists()) { Jar current = new Jar(classpath[i]); list.add(current); } else { error("Missing file on classpath: %s", classpath[i]); } } for (Iterator<Jar> i = list.iterator(); i.hasNext();) { addClasspath(i.next()); } }
/** * Set the classpath for this analyzer by file. * * @param classpath * @throws IOException */ public void setClasspath(File[] classpath) throws IOException { List<Jar> list = new ArrayList<Jar>(); for (int i = 0; i < classpath.length; i++) { if (classpath[i].exists()) { Jar current = new Jar(classpath[i]); list.add(current); } else { error("Missing file on classpath: " + classpath[i]); } } for (Iterator<Jar> i = list.iterator(); i.hasNext();) { addClasspath(i.next()); } }
/** * Set the JAR file we are going to work in. This will read the JAR in * memory. * * @param jar * @return * @throws IOException */ public Jar setJar(File jar) throws IOException { Jar jarx = new Jar(jar); addClose(jarx); return setJar(jarx); }
/** * Set the JAR file we are going to work in. This will read the JAR in * memory. * * @param jar * @return * @throws IOException */ public Jar setJar(File jar) throws IOException { Jar jarx = new Jar(jar); addClose(jarx); return setJar(jarx); }
private Map<String, Map<String, String>> buildIndex(File[] plugins) { Map<String, Map<String, String>> map = Create.map(); for (File plugin : plugins) { try { Jar jar = new Jar(plugin); Manifest manifest = jar.getManifest(); String bsn = manifest.getMainAttributes().getValue( Constants.BUNDLE_SYMBOLICNAME); String version = manifest.getMainAttributes().getValue( Constants.BUNDLE_VERSION); if (bsn != null) { if (version == null) version = "0"; Map<String, String> instance = map.get(bsn); if (instance == null) { instance = Create.map(); } instance.put(version, plugin.getAbsolutePath()); } } catch (Exception e) { // Ignore exceptions in the plugins dir. } } return map; }
public Set<String> getPackages() throws IOException { if (packages == null) { if (getExtension().equals("jar") || getExtension().equals("zip")) { aQute.lib.osgi.Jar jar = new aQute.lib.osgi.Jar(getJarFile()); try { packages = new HashSet<String>(jar.getPackages()); } finally { jar.close(); } } else { return Collections.emptySet(); } } return packages; }
public Set<String> getPackages() throws IOException { if( packages==null ) { if( getExtension().equals("jar") || getExtension().equals("zip") ) { aQute.lib.osgi.Jar jar = new aQute.lib.osgi.Jar(getJarFile()); try { packages = new HashSet<String>(jar.getPackages()); } finally { jar.close(); } } else { return Collections.emptySet(); } } return packages; }
public Set<String> getPackages() throws IOException { if (packages == null) { if (getExtension().equals("jar") || getExtension().equals("zip")) { aQute.lib.osgi.Jar jar = new aQute.lib.osgi.Jar(getJarFile()); try { packages = new HashSet<String>(jar.getPackages()); } finally { jar.close(); } } else { return Collections.emptySet(); } } return packages; }
/** * Release * * @param name * The respository name * @param test * Run testcases * @throws Exception */ public void release(String name, boolean test) throws Exception { File[] jars = build(test); // If build fails jars will be null if (jars == null) { return; } for (File jar : jars) { Jar j = new Jar(jar); release(name, j); j.close(); } }
/** * @param out * @param file * @throws IOException * @throws Exception */ void doSingleFileLib(File file, Appendable out) throws IOException, Exception { Jar jar = new Jar(file); String bsn = jar.getBsn(); System.out.println(bsn); String version = jar.getVersion(); jar.close(); if (bsn == null) { error("No valid bsn for %s", file); bsn = "not set"; } if (version == null) version = "0"; Version v = new Version(version); v = new Version(v.getMajor(), v.getMinor(), v.getMicro()); out.append(bsn); out.append(";version=" + v + "\n"); // '[" + v + "," + v + "]'\n"); }
private Jar javadoc(File tmp, Project b, Set<String> exports) throws Exception { Command command = new Command(); command.add(b.getProperty("javadoc", "javadoc")); command.add("-d"); command.add(tmp.getAbsolutePath()); command.add("-sourcepath"); command.add( Processor.join(b.getSourcePath(),File.pathSeparator)); for (String packageName : exports) { command.add(packageName); } StringBuffer out = new StringBuffer(); StringBuffer err = new StringBuffer(); Command c = new Command(); c.setTrace(); int result = c.execute(out, err); if (result == 0) { Jar jar = new Jar(tmp); b.addClose(jar); return jar; } b.error("Error during execution of javadoc command: %s / %s", out, err); return null; }
private Jar javadoc(File tmp, Project b, Set<String> exports) throws Exception { Command command = new Command(); command.add(b.getProperty("javadoc", "javadoc")); command.add("-d"); command.add(tmp.getAbsolutePath()); command.add("-sourcepath"); command.add(Processor.join(b.getSourcePath(), File.pathSeparator)); for (String packageName : exports) { command.add(packageName); } StringBuffer out = new StringBuffer(); StringBuffer err = new StringBuffer(); Command c = new Command(); c.setTrace(); int result = c.execute(out, err); if (result == 0) { Jar jar = new Jar(tmp); b.addClose(jar); return jar; } b.error("Error during execution of javadoc command: %s / %s", out, err); return null; }