本文整理了Java中aQute.lib.osgi.Jar.getManifest()
方法的一些代码示例,展示了Jar.getManifest()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.getManifest()
方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:getManifest
暂无
代码示例来源:origin: biz.aQute/bnd
/**
* Make sure we have a manifest
* @throws Exception
*/
public void ensureManifest() throws Exception {
if ( getManifest() != null)
return;
manifest = new Manifest();
}
代码示例来源:origin: biz.aQute/bnd
public String getVersion() throws Exception {
Manifest m = getManifest();
if (m == null)
return null;
String s = m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
if (s == null)
return null;
return s.trim();
}
代码示例来源:origin: biz.aQute/bnd
public String getBsn() throws Exception {
Manifest m = getManifest();
if (m == null)
return null;
String s = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
Matcher matcher = BSN.matcher(s);
if (matcher.matches()) {
return matcher.group(1);
}
return null;
}
代码示例来源:origin: biz.aQute/bnd
/**
* Cleanup the manifest for writing. Cleaning up consists of adding a space
* after any \n to prevent the manifest to see this newline as a delimiter.
*
* @param out
* Output
* @throws IOException
*/
public void writeManifest(OutputStream out) throws Exception {
writeManifest(getManifest(), out);
}
代码示例来源:origin: org.fusesource.fabric.fab/fab-osgi
@Override
public Attributes getManifest() {
try {
return getOrCreateJar().getManifest().getMainAttributes();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
代码示例来源:origin: io.fabric8.fab/fab-osgi
@Override
public Attributes getManifest() {
try {
return getOrCreateJar().getManifest().getMainAttributes();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Cleanup the manifest for writing. Cleaning up consists of adding a space
* after any \n to prevent the manifest to see this newline as a delimiter.
*
* @param out
* Output
* @throws IOException
*/
public void writeManifest(OutputStream out) throws IOException {
writeManifest(getManifest(), out);
}
代码示例来源:origin: org.fusesource.fabric/process-manager
/**
* 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);
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
* Print the components in this JAR file.
*
* @param jar
*/
private void printComponents(PrintStream out, Jar jar) throws IOException {
out.println("[COMPONENTS]");
Manifest manifest = jar.getManifest();
if (manifest == null) {
out.println("No manifest");
return;
}
String componentHeader = manifest.getMainAttributes().getValue(
Constants.SERVICE_COMPONENT);
Map<String, Map<String, String>> clauses = parseHeader(componentHeader);
for (String path : clauses.keySet()) {
// TODO
out.println(path);
}
out.println();
}
代码示例来源:origin: biz.aQute/bnd
/**
*
* @param jar
*/
void checkManifest(Jar jar) {
try {
Manifest m = jar.getManifest();
if (m != null) {
String exportHeader = m.getMainAttributes().getValue(EXPORT_PACKAGE);
if (exportHeader != null) {
Map<String, Map<String, String>> exported = parseHeader(exportHeader);
if (exported != null) {
for (Map.Entry<String, Map<String, String>> entry : exported.entrySet()) {
if (!classpathExports.containsKey(entry.getKey())) {
classpathExports.put(entry.getKey(), entry.getValue());
}
}
}
}
}
} catch (Exception e) {
warning("Erroneous Manifest for " + jar + " " + e);
}
}
代码示例来源:origin: biz.aQute/bnd
/**
* Print the metatypes in this JAR.
*
* @param jar
*/
private void printMetatype(PrintStream out, Jar jar) throws Exception {
out.println("[METATYPE]");
Manifest manifest = jar.getManifest();
if (manifest == null) {
out.println("No manifest");
return;
}
Map<String, Resource> map = jar.getDirectories().get("OSGI-INF/metatype");
if (map != null) {
for (Map.Entry<String, Resource> entry : map.entrySet()) {
out.println(entry.getKey());
IO.copy(entry.getValue().openInputStream(), out);
out.println();
}
out.println();
}
}
代码示例来源:origin: biz.aQute/aQute.bnd
private void repoPut(RepositoryPlugin writable, Project project,
String file, String bsn, String version) throws Exception {
File f = getFile(file);
if (f.isFile()) {
Jar jar = project.getValidJar(f);
Manifest manifest = jar.getManifest();
if (bsn != null)
manifest.getMainAttributes().putValue(
Constants.BUNDLE_SYMBOLICNAME, bsn);
if (version != null)
manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION,
version);
writable.put(jar);
} else
error("There is no such file: " + f.getAbsolutePath());
}
代码示例来源:origin: biz.aQute/aQute.bnd
/**
*
* @param jar
*/
void checkManifest(Jar jar) {
try {
Manifest m = jar.getManifest();
if (m != null) {
String exportHeader = m.getMainAttributes().getValue(
EXPORT_PACKAGE);
if (exportHeader != null) {
Map<String, Map<String, String>> exported = parseHeader(exportHeader);
if (exported != null)
classpathExports.putAll(exported);
}
}
} catch (Exception e) {
warning("Erroneous Manifest for " + jar + " " + e);
}
}
代码示例来源:origin: biz.aQute/bnd
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;
}
代码示例来源:origin: biz.aQute/bnd
/**
* 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);
}
代码示例来源:origin: biz.aQute/bnd
private void repoPut(RepositoryPlugin writable, Project project, String file, String bsn,
String version) throws Exception {
Jar jar = null;
int n = file.indexOf(':');
if (n > 1 && n < 10) {
jar = project.getValidJar(new URL(file));
} else {
File f = getFile(file);
if (f.isFile()) {
jar = project.getValidJar(f);
}
}
if (jar != null) {
Manifest manifest = jar.getManifest();
if (bsn != null)
manifest.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, bsn);
if (version != null)
manifest.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version);
writable.put(jar);
} else
error("There is no such file or url: " + file);
}
代码示例来源:origin: biz.aQute/bnd
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();
}
代码示例来源:origin: biz.aQute/bnd
public Verifier(Jar jar, Properties properties) throws Exception {
this.dot = jar;
this.properties = properties;
this.manifest = jar.getManifest();
if (manifest == null) {
manifest = new Manifest();
error("This file contains no manifest and is therefore not a bundle");
}
main = this.manifest.getMainAttributes();
verifyHeaders(main);
r3 = getHeader(Analyzer.BUNDLE_MANIFESTVERSION) == null;
usesRequire = getHeader(Analyzer.REQUIRE_BUNDLE) != null;
fragment = getHeader(Analyzer.FRAGMENT_HOST) != null;
bundleClasspath = getBundleClassPath();
mimports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.IMPORT_PACKAGE));
mdynimports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.DYNAMICIMPORT_PACKAGE));
mexports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.EXPORT_PACKAGE));
ignore = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.IGNORE_PACKAGE));
}
代码示例来源:origin: biz.aQute/aQute.bnd
public Verifier(Jar jar, Properties properties) throws Exception {
this.dot = jar;
this.properties = properties;
this.manifest = jar.getManifest();
if (manifest == null) {
manifest = new Manifest();
error("This file contains no manifest and is therefore not a bundle");
}
main = this.manifest.getMainAttributes();
verifyHeaders(main);
r3 = getHeader(Analyzer.BUNDLE_MANIFESTVERSION) == null;
usesRequire = getHeader(Analyzer.REQUIRE_BUNDLE) != null;
fragment = getHeader(Analyzer.FRAGMENT_HOST) != null;
bundleClasspath = getBundleClassPath();
mimports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.IMPORT_PACKAGE));
mdynimports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.DYNAMICIMPORT_PACKAGE));
mexports = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.EXPORT_PACKAGE));
ignore = parseHeader(manifest.getMainAttributes().getValue(
Analyzer.IGNORE_PACKAGE));
}
代码示例来源:origin: biz.aQute/bnd
private void copyInfo(Jar source, Jar dest, String type) throws Exception {
source.ensureManifest();
dest.ensureManifest();
copyInfoResource( source, dest, "LICENSE");
copyInfoResource( source, dest, "LICENSE.html");
copyInfoResource( source, dest, "about.html");
Manifest sm = source.getManifest();
Manifest dm = dest.getManifest();
copyInfoHeader( sm, dm, "Bundle-Description","");
copyInfoHeader( sm, dm, "Bundle-Vendor","");
copyInfoHeader( sm, dm, "Bundle-Copyright","");
copyInfoHeader( sm, dm, "Bundle-DocURL","");
copyInfoHeader( sm, dm, "Bundle-License","");
copyInfoHeader( sm, dm, "Bundle-Name", " " + type);
copyInfoHeader( sm, dm, "Bundle-SymbolicName", "." + type);
copyInfoHeader( sm, dm, "Bundle-Version", "");
}
内容来源于网络,如有侵权,请联系作者删除!