private static Jar openJar( final File file ) throws MojoExecutionException { try { return new Jar( file ); } catch ( final IOException e ) { throw new MojoExecutionException( "An error occurred while opening JAR directory: " + file, e ); } }
/** * @see aQute.bnd.service.diff.Differ#tree(aQute.bnd.osgi.Jar) */ public Tree tree(File newer) throws Exception { try (Jar jnewer = new Jar(newer)) { return tree(jnewer); } }
/** * Set the JAR file we are going to work in. This will read the JAR in * memory. * * @param file * @throws IOException */ public Jar setJar(File file) throws IOException { Jar jar = new Jar(file); setJar(jar); return jar; }
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(); } }
/** * Set the JAR file we are going to work in. This will read the JAR in * memory. * * @param file * @throws IOException */ public Jar setJar(File file) throws IOException { Jar jar = new Jar(file); setJar(jar); return jar; }
private Jar toJar(Processor context, String path) throws Exception { if (path == null) return null; File f = context.getFile(path); if (f.exists()) return new Jar(f); return null; }
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(); } }
@SuppressWarnings("resource") public static Jar fromResource(String name, Resource resource) throws Exception { if (resource instanceof JarResource) { return ((JarResource) resource).getJar(); } else if (resource instanceof FileResource) { return new Jar(name, ((FileResource) resource).getFile()); } return new Jar(name).buildFromResource(resource); }
@SuppressWarnings("resource") public static Jar fromResource(String name, Resource resource) throws Exception { if (resource instanceof JarResource) { return ((JarResource) resource).getJar(); } else if (resource instanceof FileResource) { return new Jar(name, ((FileResource) resource).getFile()); } return new Jar(name).buildFromResource(resource); }
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: %s", cp); Jar jar = new Jar(cp); addClasspath(jar); }
public void addClasspath(File cp) throws IOException { if (!cp.exists()) warning("File on classpath that does not exist: %s", cp); Jar jar = new Jar(cp); addClasspath(jar); }
/** * 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. * * @throws Exception */ public Jar getValidJar(File f) throws Exception { Jar jar = new Jar(f); return getValidJar(jar, IO.absolutePath(f)); }
/** * 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. * * @throws Exception */ public Jar getValidJar(File f) throws Exception { Jar jar = new Jar(f); return getValidJar(jar, IO.absolutePath(f)); }
public void addClasspath(Container c) throws IOException { File file = c.getFile(); if ((c.getType() == TYPE.PROJECT) && !file.exists()) { return; } Jar jar = new Jar(file); super.addClasspath(jar); project.unreferencedClasspathEntries.put(jar.getName(), c); }
public Jar getLastRevision() throws Exception { RepositoryPlugin releaseRepo = getReleaseRepo(); SortedSet<Version> versions = releaseRepo.versions(getBsn()); if (versions.isEmpty()) return null; Jar jar = new Jar(releaseRepo.get(getBsn(), versions.last(), null)); addClose(jar); return jar; }
public Jar getLastRevision() throws Exception { RepositoryPlugin releaseRepo = getReleaseRepo(); SortedSet<Version> versions = releaseRepo.versions(getBsn()); if (versions.isEmpty()) return null; Jar jar = new Jar(releaseRepo.get(getBsn(), versions.last(), null)); addClose(jar); return jar; }
@Override public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception { project.prepare(); Collection<Container> runbundles = project.getRunbundles(); Jar jar = new Jar(project.getName()); jar.setDoNotTouchManifest(); for (Container container : runbundles) { File source = container.getFile(); String path = nonCollidingPath(jar, source.getName()); jar.putResource(path, new FileResource(source)); } return new SimpleEntry<>(jar.getName(), new JarResource(jar, true)); }