private Map<String, Map<String, String>> getHeader(String string) { if (string == null) return Collections.emptyMap(); return parseHeader(getProperty(string)); }
/** * Parse the Bundle-Includes header. Files in the bundles Include header are * included in the jar. The source can be a directory or a file. * * @throws IOException * @throws FileNotFoundException */ private void doIncludeResources(Jar jar) throws Exception { String includes = getProperty("Bundle-Includes"); if (includes == null) { includes = getProperty(INCLUDERESOURCE); if (includes == null || includes.length() == 0) includes = getProperty("Include-Resource"); } else warning("Please use -includeresource instead of Bundle-Includes"); doIncludeResource(jar, includes); }
private Map<String, Map<String, String>> getHeader(String string) { if (string == null) return Collections.emptyMap(); return parseHeader(getProperty(string)); }
public Pattern getDoNotCopy() { if (xdoNotCopy == null) { String string = null; try { string = getProperty(DONOTCOPY, DEFAULT_DO_NOT_COPY); xdoNotCopy = Pattern.compile(string); } catch (Exception e) { error("Invalid value for %s, value is %s", DONOTCOPY, string); xdoNotCopy = Pattern.compile(DEFAULT_DO_NOT_COPY); } } return xdoNotCopy; }
public boolean hasSources() { return isTrue(getProperty(SOURCES)); }
public boolean hasSources() { return isTrue(getProperty(SOURCES)); }
/** * Parse the Bundle-Includes header. Files in the bundles Include header are * included in the jar. The source can be a directory or a file. * * @throws IOException * @throws FileNotFoundException */ private void doIncludeResources(Jar jar) throws Exception { String includes = getProperty("Bundle-Includes"); if (includes == null) { includes = getProperty(INCLUDERESOURCE); if (includes == null) includes = getProperty("Include-Resource"); } else warning("Please use -includeresource instead of Bundle-Includes"); if (includes == null) return; Map<String, Map<String, String>> clauses = parseHeader(includes); for (Iterator<Map.Entry<String, Map<String, String>>> i = clauses .entrySet().iterator(); i.hasNext();) { Map.Entry<String, Map<String, String>> entry = i.next(); doIncludeResource(jar, entry.getKey(), entry.getValue()); } }
Map<Instruction, Map<String, String>> getMakeHeader() { if (make != null) return make; make = Processor.newMap(); String s = builder.getProperty(Builder.MAKE); Map<String, Map<String, String>> make = builder.parseHeader(s); for (Iterator<Map.Entry<String, Map<String, String>>> e = make .entrySet().iterator(); e.hasNext();) { Map.Entry<String, Map<String, String>> entry = e.next(); String pattern = Processor.removeDuplicateMarker(entry.getKey()); Instruction instr = Instruction.getPattern(pattern); this.make.put(instr, entry.getValue()); } return this.make; } }
Map<Instruction, Map<String, String>> getMakeHeader() { if (make != null) return make; make = Processor.newMap(); String s = builder.getProperty(Builder.MAKE); Map<String, Map<String, String>> make = builder.parseHeader(s); for (Iterator<Map.Entry<String, Map<String, String>>> e = make .entrySet().iterator(); e.hasNext();) { Map.Entry<String, Map<String, String>> entry = e.next(); String pattern = Processor.removeDuplicateMarker(entry.getKey()); Instruction instr = Instruction.getPattern(pattern); this.make.put(instr, entry.getValue()); } return this.make; } }
/** * Get the manifest and write it out separately if -savemanifest is set * * @param dot */ private void doSaveManifest(Jar dot) throws Exception { String output = getProperty(SAVEMANIFEST); if (output == null) return; File f = getFile(output); if (f.isDirectory()) { f = new File(f, "MANIFEST.MF"); } f.delete(); f.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(f); try { Jar.writeManifest(dot.getManifest(), out); } finally { out.close(); } changedFile(f); }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = getProperty(SOURCEPATH); if (sp != null) { Map<String, Map<String, String>> map = parseHeader(sp); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: " + f); } else { sourcePath.add(f); } } } } } return sourcePath; }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = getProperty(SOURCEPATH); if (sp != null) { Map<String, Map<String, String>> map = parseHeader(sp); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: " + f); } else { sourcePath.add(f); } } } } } return sourcePath; }
public void cleanupVersion(Map<String, Map<String, String>> mapOfMap, String defaultVersion) { for (Iterator<Map.Entry<String, Map<String, String>>> e = mapOfMap.entrySet().iterator(); e .hasNext();) { Map.Entry<String, Map<String, String>> entry = e.next(); Map<String, String> attributes = entry.getValue(); String v = attributes.get(Constants.VERSION_ATTRIBUTE); if (v == null && defaultVersion != null) { if (!isTrue(getProperty(Constants.NODEFAULTVERSION))) { v = defaultVersion; if (isPedantic()) warning("Used bundle version %s for exported package %s", v, entry.getKey()); } else { if (isPedantic()) warning("No export version for exported package %s", entry.getKey()); } } if (v != null) attributes.put(Constants.VERSION_ATTRIBUTE, cleanupVersion(v)); } }
/** * 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 Exception { super.analyze(); cleanupVersion(imports, null); cleanupVersion(exports, getVersion()); String version = getProperty(BUNDLE_VERSION); if (version != null) { version = cleanupVersion(version); if (version.endsWith(".SNAPSHOT")) { version = version.replaceAll("SNAPSHOT$", getProperty(SNAPSHOT, "SNAPSHOT")); } setProperty(BUNDLE_VERSION, version); } }
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"); } } }
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))); Map<String, Map<String, String>> clauses = parseHeader(getProperty(WABLIB)); for (String key : clauses.keySet()) { File f = getFile(key);
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"); } }
/** * Sign the jar file. * * -sign : <alias> [ ';' 'password:=' <password> ] [ ';' 'keystore:=' * <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )* * * @return */ void sign(Jar jar) throws Exception { String signing = getProperty("-sign"); if (signing == null) return; trace("Signing %s, with %s", getBsn(), signing); List<SignerPlugin> signers = getPlugins(SignerPlugin.class); Map<String, Map<String, String>> infos = parseHeader(signing); for (Map.Entry<String, Map<String, String>> entry : infos.entrySet()) { for (SignerPlugin signer : signers) { signer.sign(this, entry.getKey()); } } }
/** * Sign the jar file. * * -sign : <alias> [ ';' 'password:=' <password> ] [ ';' 'keystore:=' * <keystore> ] [ ';' 'sign-password:=' <pw> ] ( ',' ... )* * * @return */ void sign(Jar jar) throws Exception { String signing = getProperty("-sign"); if (signing == null) return; trace("Signing %s, with %s", getBsn(), signing); List<SignerPlugin> signers = getPlugins(SignerPlugin.class); Map<String, Map<String, String>> infos = parseHeader(signing); for (Map.Entry<String, Map<String, String>> entry : infos.entrySet()) { for (SignerPlugin signer : signers) { signer.sign(this, entry.getKey()); } } }
/** * 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)); }