aQute.lib.osgi.Jar.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中aQute.lib.osgi.Jar.<init>()方法的一些代码示例,展示了Jar.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.<init>()方法的具体详情如下:
包路径:aQute.lib.osgi.Jar
类名称:Jar
方法名:<init>

Jar.<init>介绍

暂无

代码示例

代码示例来源:origin: biz.aQute/bnd

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();
  }
}

代码示例来源:origin: biz.aQute/bnd

/**
 * 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());
}

代码示例来源:origin: biz.aQute/aQute.bnd

void add(File jar) throws Exception {
  add(new Jar(jar));
}

代码示例来源: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/bnd

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);
}

代码示例来源:origin: biz.aQute/aQute.bnd

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);
}

代码示例来源:origin: biz.aQute/bnd

/**
 * @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;
}

代码示例来源:origin: biz.aQute/bnd

/**
 * @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;
}

代码示例来源:origin: biz.aQute/bnd

/**
 * 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());
  }
}

代码示例来源:origin: biz.aQute/aQute.bnd

/**
 * 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());
  }
}

代码示例来源:origin: biz.aQute/bnd

/**
 * 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);
}

代码示例来源:origin: biz.aQute/aQute.bnd

/**
 * 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);
}

代码示例来源: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: org.fusesource.fabric.fab/fab-core

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;
}

代码示例来源:origin: org.fusesource.fabric.fab/fabric-fab-core

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;
}

代码示例来源:origin: io.fabric8.fab/fab-core

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;
}

代码示例来源:origin: biz.aQute/aQute.bnd

/**
 * 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();
  }
}

代码示例来源:origin: biz.aQute/bnd

/**
 * @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");
}

代码示例来源:origin: biz.aQute/bnd

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;
}

代码示例来源:origin: biz.aQute/bnd

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;
}

相关文章