public void run() { try { jar.write( pout ); } catch( Exception e ) { LOG.warn( "Bundle cannot be generated" ); } finally { try { jar.close(); pout.close(); } catch( IOException ignore ) { // if we get here something is very wrong LOG.error( "Bundle cannot be generated", ignore ); } } } }.start();
public void run() { try { jar.write( pout ); } catch( Exception e ) { LOG.warn( "Bundle cannot be generated" ); } finally { try { jar.close(); pout.close(); } catch( IOException ignore ) { // if we get here something is very wrong LOG.error( "Bundle cannot be generated", ignore ); } } } }.start();
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; }
void applyPatch(String old, String patch, String newer) throws Exception { Jar a = new Jar(new File(old)); Jar b = new Jar(new File(patch)); Manifest bm = b.getManifest(); String patchDelete = bm.getMainAttributes().getValue("Patch-Delete"); String patchVersion = bm.getMainAttributes().getValue("Patch-Version"); if (patchVersion == null) { error("To patch, you must provide a patch bundle.\nThe given " + patch + " bundle does not contain the Patch-Version header"); return; } Collection<String> delete = split(patchDelete); Set<String> paths = new HashSet<String>(a.getResources().keySet()); paths.removeAll(delete); for (String path : paths) { Resource br = b.getResource(path); if (br == null) b.putResource(path, a.getResource(path)); } bm.getMainAttributes().putValue("Bundle-Version", patchVersion); b.write(new File(newer)); a.close(); b.close(); }
void applyPatch(String old, String patch, String newer) throws Exception { Jar a = new Jar(new File(old)); Jar b = new Jar(new File(patch)); Manifest bm = b.getManifest(); String patchDelete = bm.getMainAttributes().getValue("Patch-Delete"); String patchVersion = bm.getMainAttributes().getValue("Patch-Version"); if (patchVersion == null) { error("To patch, you must provide a patch bundle.\nThe given " + patch + " bundle does not contain the Patch-Version header"); return; } Collection<String> delete = split(patchDelete); Set<String> paths = new HashSet<String>(a.getResources().keySet()); paths.removeAll(delete); for (String path : paths) { Resource br = b.getResource(path); if (br == null) b.putResource(path, a.getResource(path)); } bm.getMainAttributes().putValue("Bundle-Version", patchVersion); b.write(new File(newer)); a.close(); b.close(); }
public File saveBuild(Jar jar) throws Exception { try { String bsn = jar.getName(); File f = getOutputFile(bsn); String msg = ""; if (!f.exists() || f.lastModified() < jar.lastModified()) { reportNewer(f.lastModified(), jar); f.delete(); if (!f.getParentFile().isDirectory()) f.getParentFile().mkdirs(); jar.write(f); getWorkspace().changedFile(f); } else { msg = "(not modified since " + new Date(f.lastModified()) + ")"; } trace(jar.getName() + " (" + f.getName() + ") " + jar.getResources().size() + " " + msg); return f; } finally { jar.close(); } }
void createPatch(String old, String newer, String patch) throws Exception { Jar a = new Jar(new File(old)); Manifest am = a.getManifest(); Jar b = new Jar(new File(newer)); Manifest bm = b.getManifest(); Set<String> delete = newSet(); for (String path : a.getResources().keySet()) { Resource br = b.getResource(path); if (br == null) { trace("DELETE %s", path); delete.add(path); } else { Resource ar = a.getResource(path); if (isEqual(ar, br)) { trace("UNCHANGED %s", path); b.remove(path); } else trace("UPDATE %s", path); } } bm.getMainAttributes().putValue("Patch-Delete", join(delete, ", ")); bm.getMainAttributes().putValue("Patch-Version", am.getMainAttributes().getValue("Bundle-Version")); b.write(new File(patch)); a.close(); a.close(); }
void createPatch(String old, String newer, String patch) throws Exception { Jar a = new Jar(new File(old)); Manifest am = a.getManifest(); Jar b = new Jar(new File(newer)); Manifest bm = b.getManifest(); Set<String> delete = newSet(); for (String path : a.getResources().keySet()) { Resource br = b.getResource(path); if (br == null) { trace("DELETE %s", path); delete.add(path); } else { Resource ar = a.getResource(path); if (isEqual(ar, br)) { trace("UNCHANGED %s", path); b.remove(path); } else trace("UPDATE %s", path); } } bm.getMainAttributes().putValue("Patch-Delete", join(delete, ", ")); bm.getMainAttributes().putValue("Patch-Version", am.getMainAttributes().getValue("Bundle-Version")); b.write(new File(patch)); a.close(); a.close(); }
/** * 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"); }
/** * Release * * @param name * The respository name * @param test * Run testcases * @throws Exception */ public void release(String name, boolean test) throws Exception { trace("release"); File[] jars = build(test); // If build fails jars will be null if (jars == null) { trace("no jars being build"); return; } trace("build ", Arrays.toString(jars)); for (File jar : jars) { Jar j = new Jar(jar); try { release(name, j); } finally { j.close(); } } }
private void doExpand(Jar jar) throws IOException { if (getClasspath().size() == 0 && (getProperty(EXPORT_PACKAGE) != null || getProperty(PRIVATE_PACKAGE) != null)) warning("Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one"); Map<Instruction, Map<String, String>> privateMap = replaceWitInstruction( getHeader(PRIVATE_PACKAGE), PRIVATE_PACKAGE); Map<Instruction, Map<String, String>> exportMap = replaceWitInstruction( getHeader(EXPORT_PACKAGE), EXPORT_PACKAGE); if (isTrue(getProperty(Constants.UNDERTEST))) { privateMap.putAll(replaceWitInstruction(parseHeader(getProperty( Constants.TESTPACKAGES, "test;presence:=optional")), TESTPACKAGES)); } if (!privateMap.isEmpty()) doExpand(jar, "Private-Package, or -testpackages", privateMap, true); if (!exportMap.isEmpty()) { Jar exports = new Jar("exports"); doExpand(exports, "Export-Package", exportMap, true); jar.addAll(exports); exports.close(); } if (privateMap.isEmpty() && exportMap.isEmpty() && !isResourceOnly()) { warning("Neither Export-Package, Private-Package, -testpackages is set, therefore no packages will be included"); } }
jar.close(); verifier.close();
jar.close(); verifier.close();
/** * Deploy the current project to a repository * * @throws Exception */ public void deploy() throws Exception { Map<String, Map<String, String>> deploy = parseHeader(getProperty(DEPLOY)); if (deploy.isEmpty()) { warning("Deploying but %s is not set to any repo", DEPLOY); return; } File[] outputs = getBuildFiles(); for (File output : outputs) { Jar jar = new Jar(output); try { for (Deploy d : getPlugins(Deploy.class)) { trace("Deploying %s to: %s", jar, d); try { if (d.deploy(this, jar)) trace("deployed %s successfully to %s", output, d); } catch (Exception e) { error("Error while deploying %s, %s", this, e); e.printStackTrace(); } } } finally { jar.close(); } } }
private void doExpand(Jar jar) throws IOException { if (getClasspath().size() == 0 && (getProperty(EXPORT_PACKAGE) != null || getProperty(EXPORT_PACKAGE) != null || getProperty(PRIVATE_PACKAGE) != null)) warning("Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one"); Map<Instruction, Map<String, String>> privateMap = Instruction .replaceWithInstruction(getHeader(PRIVATE_PACKAGE)); Map<Instruction, Map<String, String>> exportMap = Instruction .replaceWithInstruction(getHeader(EXPORT_PACKAGE)); if (isTrue(getProperty(Constants.UNDERTEST))) { privateMap.putAll(Instruction.replaceWithInstruction(parseHeader(getProperty( Constants.TESTPACKAGES, "test;presence:=optional")))); } if (!privateMap.isEmpty()) doExpand(jar, "Private-Package, or -testpackages", privateMap, true); if (!exportMap.isEmpty()) { Jar exports = new Jar("exports"); doExpand(exports, EXPORT_PACKAGE, exportMap, true); jar.addAll(exports); exports.close(); } if (!isNoBundle()) { if (privateMap.isEmpty() && exportMap.isEmpty() && !isResourceOnly() && getProperty(EXPORT_CONTENTS) == null) { warning("None of Export-Package, Provide-Package, Private-Package, -testpackages, or -exportcontents is set, therefore no packages will be included"); } } }