aQute.bnd.osgi.Builder类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(215)

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

Builder介绍

[英]Include-Resource: ( [name '=' ] file )+ Private-Package: package-decl ( ',' package-decl )* Export-Package: package-decl ( ',' package-decl ) Import-Package: package-decl ( ',' package-decl )* @version $Revision: 1.27 $
[中]包括资源:([name'=']文件)+私有包:包decl(','Package decl)导出包:包decl(','Package decl)导入包:包decl(','Package decl)@version$Revision:1.27$

代码示例

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

public Jar getValidJar(Jar jar, String id) throws Exception {
  Manifest manifest = jar.getManifest();
  if (manifest == null) {
    trace("Wrapping with all defaults");
    Builder b = new Builder(this);
    b.addClasspath(jar);
    b.setProperty("Bnd-Message", "Wrapped from " + id + "because lacked manifest");
    b.setProperty(Constants.EXPORT_PACKAGE, "*");
    b.setProperty(Constants.IMPORT_PACKAGE, "*;resolution:=optional");
    jar = b.build();
  } else if (manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) == null) {
    trace("Not a release 4 bundle, wrapping with manifest as source");
    Builder b = new Builder(this);
    b.addClasspath(jar);
    b.setProperty(Constants.PRIVATE_PACKAGE, "*");
    b.mergeManifest(manifest);
    String imprts = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE);
    if (imprts == null)
      imprts = "";
    else
      imprts += ",";
    imprts += "*;resolution=optional";
    b.setProperty(Constants.IMPORT_PACKAGE, imprts);
    b.setProperty("Bnd-Message", "Wrapped from " + id + "because had incomplete manifest");
    jar = b.build();
  }
  return jar;
}

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

builder.error("No recipe specified on a make instruction for %s", destination);
  return null;
File bndfile = builder.getFile(recipe);
if (bndfile.isFile()) {
  Builder bchild = builder.getSubBuilder();
  bchild.removeBundleSpecificHeaders();
  bchild.setProperty(Constants.INCLUDE_RESOURCE, "");
  bchild.setProperty(Constants.INCLUDERESOURCE, "");
  bchild.setProperties(bndfile, builder.getBase());
  Jar jar = bchild.build();
  Jar dot = builder.getJar();
  if (builder.hasSources()) {
    for (String key : jar.getResources()
      .keySet()) {
      if (key.startsWith("OSGI-OPT/src"))
        dot.putResource(key, jar.getResource(key));
  builder.getInfo(bchild, bndfile.getName() + ": ");
  return new JarResource(jar);

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

public Jar build() throws Exception {
  trace("build");
  init();
  if (isTrue(getProperty(NOBUNDLES)))
    return null;
  if (getProperty(CONDUIT) != null)
    error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error");
  Jar dot = new Jar("dot");
  try {
    long modified = Long.parseLong(getProperty("base.modified"));
    dot.updateModified(modified, "Base modified");
  setJar(dot);
  doExpand(dot);
  doIncludeResources(dot);
  doWab(dot);
  Manifest manifest = calcManifest();
  String mf = getProperty(MANIFEST);
  if (mf != null) {
    File mff = getFile(mf);
    if (mff.isFile()) {
      try {
        error(MANIFEST + " while reading manifest file", e);

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

public Builder getSubBuilder() throws Exception {
  Builder builder = new Builder(this);
  builder.setBase(getBase());
  builder.use(this);
  for (Jar file : getClasspath()) {
    builder.addClasspath(file);
  }
  return builder;
}

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

public Builder getSubBuilder(File file) throws Exception {
  Builder builder = getSubBuilder();
  if (builder != null) {
    builder.setProperties(file);
    addClose(builder);
  }
  return builder;
}

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

/**
 * Create a report of the settings
 * @throws Exception
 */
public void report(Map<String,Object> table) throws Exception {
  build();
  super.report(table);
  table.put("Do Not Copy", getDoNotCopy());
  table.put("Git head", _githead( new String[]{"githead"}));
}

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

pw.println("Ref " + ref);
Matcher matcher = GROUP_ARTIFACT_VERSION.matcher(ref);
if (matcher.matches()) {
  String group = matcher.group(1);
  String artifact = matcher.group(2);
  String version = matcher.group(3);
  CachedPom pom = maven.getPom(group, artifact, version, urls2);
  Builder a = new Builder();
  a.setProperty("Private-Package", "*");
  Set<Pom> dependencies = pom.getDependencies(Scope.compile, urls2);
  for (Pom dep : dependencies) {
    System.err.printf("%20s %-20s %10s%n", dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
    a.addClasspath(dep.getArtifact());
  pw.println(a.getClasspath());
  a.build();
  TreeSet<PackageRef> sorted = new TreeSet<PackageRef>(a.getImports().keySet());
  for (PackageRef p : sorted) {
    pw.printf("%-40s\n", p);
  a.close();
} else
  System.err.println("Wrong, must look like group+artifact+version, is " + ref);

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

public Jar build() throws Exception {
  logger.debug("build");
  init();
  if (isTrue(getProperty(NOBUNDLES)))
    return null;
  if (getProperty(CONDUIT) != null)
    error("Specified " + CONDUIT + " but calls build() instead of builds() (might be a programmer error");
  Jar dot = getJar();
  if (dot == null) {
    dot = new Jar("dot");
    dot.setReproducible(is(REPRODUCIBLE));
    setJar(dot);
    long modified = Long.parseLong(getProperty("base.modified"));
    dot.updateModified(modified, "Base modified");
  } catch (Exception e) {
  doExpand(dot);
  doIncludeResources(dot);
  doWab(dot);
  Manifest manifest = calcManifest();
  String mf = getProperty(MANIFEST);
  if (mf != null) {
    File mff = getFile(mf);
    if (mff.isFile()) {

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

begin();
String conduit = getProperty(CONDUIT);
if (conduit != null) {
  Parameters map = parseHeader(conduit);
  Jar[] result = new Jar[map.size()];
  int n = 0;
  for (String file : map.keySet()) {
    Jar c = new Jar(getFile(file));
    addClose(c);
    String name = map.get(file).get("name");
    if (name != null)
      c.setName(name);
List<Builder> builders;
builders = getSubBuilders();
    startBuild(builder);
    Jar jar = builder.build();
    jar.setName(builder.getBsn());
    doneBuild(builder);
    error("Sub Building " + builder.getBsn(), e);
    getInfo(builder, builder.getBsn() + ": ");

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

public void sign(Builder builder, String alias) throws Exception {
  File f = builder.getFile(keystore);
  if (!f.isFile()) {
    builder.error("Invalid keystore %s", f.getAbsolutePath());
    return;
  Jar jar = builder.getJar();
  File tmp = File.createTempFile("signdjar", ".jar");
  tmp.deleteOnExit();
  jar.write(tmp);
  builder.trace("Jarsigner command: %s", command);
  command.setTimeout(20, TimeUnit.SECONDS);
  StringBuilder out = new StringBuilder();
  int exitValue = command.execute(out, err);
  if (exitValue != 0) {
    builder.error("Signing Jar out: %s\nerr: %s", out, err);
  } else {
    builder.trace("Signing Jar out: %s \nerr: %s", out, err);
  Jar signed = new Jar(tmp);
  builder.addClose(signed);
  Map<String,Resource> dir = signed.getDirectories().get("META-INF");
  for (Entry<String,Resource> entry : dir.entrySet()) {
    String path = entry.getKey();

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

builder.error("No recipe specified on a make instruction for " + destination);
  return null;
File bndfile = builder.getFile(recipe);
if (bndfile.isFile()) {
  Builder bchild = builder.getSubBuilder();
  bchild.removeBundleSpecificHeaders();
  bchild.setProperty(Analyzer.INCLUDE_RESOURCE, "");
  bchild.setProperty(Analyzer.INCLUDERESOURCE, "");
  bchild.setProperties(bndfile, builder.getBase());
  Jar jar = bchild.build();
  Jar dot = builder.getTarget();
  if (builder.hasSources()) {
    for (String key : jar.getResources().keySet()) {
      if (key.startsWith("OSGI-OPT/src"))
        dot.putResource(key, jar.getResource(key));
  builder.getInfo(bchild, bndfile.getName() + ": ");
  String debug = bchild.getProperty(DEBUG);
  if (Processor.isTrue(debug)) {
    if (builder instanceof ProjectBuilder) {
      ProjectBuilder pb = (ProjectBuilder) builder;
      File target = pb.getProject().getTarget();
      String bsn = bchild.getBsn();
      File output = new File(target, bsn + ".jar");

代码示例来源:origin: org.ops4j.pax.tinybundles/tinybundles

NullArgumentException.validateNotEmpty( symbolicName, "Jar info" );
final Jar jar = new Jar( "dot", sink( jarInputStream ) );
final Builder analyzer = new Builder();
analyzer.setJar( jar );
analyzer.setProperties( properties );
  analyzer.addBasicPlugin(plugin);
analyzer.mergeManifest( jar.getManifest() );
Manifest manifest = analyzer.calcManifest();
jar.setManifest( manifest );

代码示例来源:origin: org.apache.felix/maven-bundle-plugin

analyzer.setJar( file );
if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null
  && analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null
  && analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null && !isOutputDirectory )
  String export = calculateExportsFromContents( analyzer.getJar() );
  analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
if ( analyzer.getProperty( DependencyEmbedder.EMBED_DEPENDENCY ) != null && isOutputDirectory )
  analyzer.build();
  analyzer.mergeManifest( analyzer.getJar().getManifest() );
  analyzer.getJar().setManifest( analyzer.calcManifest() );
if ( hasErrors )
  String failok = analyzer.getProperty( "-failok" );
  if ( null == failok || "false".equalsIgnoreCase( failok ) )
Jar jar = analyzer.getJar();
  for ( Entry<String, Resource> entry : jar.getResources().entrySet() )

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

Builder builder = new Builder();
builder.setPedantic(isPedantic());
if (file.exists()) {
  builder.setProperties(file);
  Properties projectProperties = new UTF8Properties();
  projectProperties.putAll((Map< ? , ? >) getProject().getProperties());
  projectProperties.putAll(builder.getProperties());
  builder.setProperties(projectProperties);
builder.setClasspath(toFiles(classpath, "classpath"));
builder.setSourcepath(toFiles(sourcepath, "sourcepath"));
Jar jars[] = builder.builds();
  String bsn = jar.getName();
  String path = builder.getProperty("-output");
  if (!output.exists() || output.lastModified() <= jar.lastModified()) {
    jar.write(output);
  } else {
    msg = "(not modified)";
  jar.close();
builder.close();

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

super.startBuild(builder);
project.versionMap.remove(builder.getBsn());
if (!project.isNoBundles() && (builder.getJar() == null)
  && (builder.getProperty(Constants.RESOURCEONLY) == null)
  && (builder.getProperty(Constants.PRIVATE_PACKAGE) == null)
  && (builder.getProperty(Constants.EXPORT_PACKAGE) == null)
  && (builder.getProperty(Constants.INCLUDE_RESOURCE) == null)
  && (builder.getProperty(Constants.INCLUDEPACKAGE) == null)
  && (builder.getProperty(Constants.INCLUDERESOURCE) == null) && project.getOutput()
    .isDirectory()) {
  Jar outputDirJar = new Jar(project.getName(), project.getOutput());
  outputDirJar.setReproducible(is(REPRODUCIBLE));
  outputDirJar.setManifest(new Manifest());
  builder.setJar(outputDirJar);

代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-osgi

public void execute(final TransformContext context) throws PluginTransformationException {
  final Joiner joiner = Joiner.on(",").skipNulls();
  try (Builder builder = new Builder()) {
    builder.setJar(context.getPluginFile());
      if (context.getExtraImports().isEmpty()) {
        boolean modified = false;
        mf = builder.getJar().getManifest();
        for (final Entry<String, String> entry : getRequiredOsgiHeaders(context, parser.getKey()).entrySet()) {
          if (manifestDoesntHaveRequiredOsgiHeader(mf, entry)) {
        mf = builder.getJar().getManifest();
            builder.getJar().getManifest().getMainAttributes().getValue(Constants.IMPORT_PACKAGE),
            context.getExtraImports());
          properties.getProperty(Analyzer.EXPORT_PACKAGE)));
      builder.setProperties(properties);
      builder.calcManifest();
      try (Jar jar = builder.build()) {
        mf = jar.getManifest();

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

public void build(String dest, boolean force, String path) throws IOException, Exception {
  Builder b = new Builder();
  try {
    File f = getFile(path);
    if (!f.isFile()) {
      error("No such file %s", f);
      return;
    }
    b.setTrace(isTrace());
    b.setPedantic(isPedantic());
    b.setProperties(f);
    List<Builder> subs = b.getSubBuilders();
    for (Builder bb : subs) {
      trace("building %s", bb.getPropertiesFile());
      bb.build();
      File out = bb.getOutputFile(dest);
      getInfo(bb, bb.getBsn() + ": ");
      if (isOk()) {
        bb.save(out, force);
      }
      getInfo(bb, bb.getBsn() + ": "); // pickup any save errors
      if (!isOk()) {
        out.delete();
      }
    }
  }
  finally {
    b.close();
  }
}

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

if (options.classpath() != null) {
  for (String f : options.classpath()) {
    b.addClasspath(getFile(f));
    b.addSourcepath(getFile(f));
  b.setSources(true);
  b.addClasspath(ep.getClasspath());
  b.addClasspath(ep.getBootclasspath());
  b.addSourcepath(ep.getSourcepath());
Jar jar = b.build();
File outputFile = b.getOutputFile(options.output());
  Resource r = new PomFromManifest(jar.getManifest());
  jar.putResource("pom.xml", r);
  String path = outputFile.getName().replaceAll("\\.jar$", ".pom");
  if (path.equals(outputFile.getName()))
getInfo(b, b.getPropertiesFile().getName());
if (isOk()) {
  b.save(outputFile, options.force());
b.close();

代码示例来源:origin: org.apache.felix/maven-bundle-plugin

protected void mergeMavenManifest( MavenProject currentProject, DependencyNode dependencyGraph, Builder builder ) throws Exception
  Jar jar = builder.getJar();
    getLog().debug( "BND Manifest:" + NL + dumpManifest( jar.getManifest(), new StringBuilder() ) );
    mainMavenAttributes.putValue( "Created-By", "Apache Maven Bundle Plugin" );
    String[] removeHeaders = builder.getProperty( Constants.REMOVEHEADERS, "" ).split( "," );
    Properties properties = builder.getProperties();
    Manifest bundleManifest = jar.getManifest();
    if ( properties.containsKey( "Merge-Headers" ) )
      Instructions instructions = new Instructions( ExtList.from(builder.getProperty("Merge-Headers")) );
      mergeManifest( instructions, bundleManifest, mavenManifest );
      String result = Processor.printClauses( values );
      bundleManifest.getMainAttributes().putValue( "Import-Package", result );
    jar.setManifest( bundleManifest );
  builder.setJar( jar );

代码示例来源:origin: org.wisdom-framework/wisdom-maven-plugin

builder.build();
  builder.analyze();
  builder.build();
  reportErrors(builder.getWarnings(), builder.getErrors(), reporter);
  bnd = File.createTempFile("bnd-", ".jar");
  ipojo = File.createTempFile("ipojo-", ".jar");
  builder.getJar().write(bnd);
} catch (Exception e) {
  throw new IOException("Cannot build the OSGi bundle", e);
}  finally {
  if (builder != null) {
    builder.close();

相关文章

Builder类方法