Tabnine Logo
FileResource.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
aQute.bnd.osgi.FileResource
constructor

Best Java code snippets using aQute.bnd.osgi.FileResource.<init> (Showing top 20 results out of 315)

origin: biz.aQute.bnd/biz.aQute.repository

private Resource createPomFromFile(File file) throws Exception {
  if (!file.isFile())
    return null;
  return new FileResource(file);
}
origin: biz.aQute.bnd/biz.aQute.bnd

private Resource createPomFromFile(File file) throws Exception {
  if (!file.isFile())
    return null;
  return new FileResource(file);
}
origin: biz.aQute/bndlib

static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) {
  if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches())
    return;
  jar.updateModified(directory.lastModified(), "Dir change");
  File files[] = directory.listFiles();
  for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory())
      traverse(jar, rootlength, files[i], doNotCopy);
    else {
      String path = files[i].getAbsolutePath().substring(rootlength + 1);
      if (File.separatorChar != '/')
        path = path.replace(File.separatorChar, '/');
      jar.putResource(path, new FileResource(files[i]), true);
    }
  }
}
origin: biz.aQute.bnd/bndlib

static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) {
  if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches())
    return;
  jar.updateModified(directory.lastModified(), "Dir change " + directory);
  File files[] = directory.listFiles();
  for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory())
      traverse(jar, rootlength, files[i], doNotCopy);
    else {
      String path = files[i].getAbsolutePath().substring(rootlength + 1);
      if (File.separatorChar != '/')
        path = path.replace(File.separatorChar, '/');
      jar.putResource(path, new FileResource(files[i]), true);
    }
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

  @Override
  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    String relativePath = IO.normalizePath(baseDir.relativize(file));
    putResource(relativePath, new FileResource(file, attrs), true);
    return FileVisitResult.CONTINUE;
  }
});
origin: biz.aQute.bnd/biz.aQute.bnd

  @Override
  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    String relativePath = IO.normalizePath(baseDir.relativize(file));
    putResource(relativePath, new FileResource(file, attrs), true);
    return FileVisitResult.CONTINUE;
  }
});
origin: biz.aQute.bnd/bnd

static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) {
  if (doNotCopy != null && doNotCopy.matcher(directory.getName()).matches())
    return;
  jar.updateModified(directory.lastModified(), "Dir change " + directory);
  File files[] = directory.listFiles();
  for (int i = 0; i < files.length; i++) {
    if (files[i].isDirectory())
      traverse(jar, rootlength, files[i], doNotCopy);
    else {
      String path = files[i].getAbsolutePath().substring(rootlength + 1);
      if (File.separatorChar != '/')
        path = path.replace(File.separatorChar, '/');
      jar.putResource(path, new FileResource(files[i]), true);
    }
  }
}
origin: biz.aQute.bnd/bnd

public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
  String type = argumentsOnMake.get("type");
  if (!type.equals("copy"))
    return null;
  String from = argumentsOnMake.get("from");
  if (from == null) {
    String content = argumentsOnMake.get("content");
    if (content == null)
      throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
    return new EmbeddedResource(content.getBytes("UTF-8"), 0);
  }
  File f = builder.getFile(from);
  if (f.isFile())
    return new FileResource(f);
  try {
    URL url = new URL(from);
    return new URLResource(url);
  }
  catch (MalformedURLException mfue) {
    // We ignore this
  }
  throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
      + destination);
}
origin: org.apache.felix/maven-bundle-plugin

/**
 * @param jar
 * @throws IOException
 */
private void doMavenMetadata( MavenProject currentProject, Jar jar ) throws IOException
{
  String path = "META-INF/maven/" + currentProject.getGroupId() + "/" + currentProject.getArtifactId();
  File pomFile = currentProject.getFile();
  if ( pomFile == null || !pomFile.exists() )
  {
    pomFile = new File( currentProject.getBasedir(), "pom.xml" );
  }
  if ( pomFile.exists() )
  {
    jar.putResource( path + "/pom.xml", new FileResource( pomFile ) );
  }
  Properties p = new Properties();
  p.put( "version", currentProject.getVersion() );
  p.put( "groupId", currentProject.getGroupId() );
  p.put( "artifactId", currentProject.getArtifactId() );
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  p.store( out, "Generated by org.apache.felix.bundleplugin" );
  jar.putResource( path + "/pom.properties", new EmbeddedResource( out.toByteArray(), System.currentTimeMillis() ) );
}
origin: biz.aQute/bndlib

public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
  String type = argumentsOnMake.get("type");
  if (!type.equals("copy"))
    return null;
  String from = argumentsOnMake.get("from");
  if (from == null) {
    String content = argumentsOnMake.get("content");
    if (content == null)
      throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
    return new EmbeddedResource(content.getBytes("UTF-8"), 0);
  }
  File f = builder.getFile(from);
  if (f.isFile())
    return new FileResource(f);
  try {
    URL url = new URL(from);
    return new URLResource(url);
  }
  catch (MalformedURLException mfue) {
    // We ignore this
  }
  throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
      + destination);
}
origin: biz.aQute.bnd/biz.aQute.bndlib

  static Resource fromURL(URL url, HttpClient client) throws IOException {
    if (url.getProtocol()
      .equalsIgnoreCase("file")) {
      URI uri = URI.create(url.toExternalForm());
      Path path = new File(uri.getSchemeSpecificPart()).toPath()
        .toAbsolutePath();
      return new FileResource(path);
    }
    if (url.getProtocol()
      .equals("jar")) {
      JarURLUtil util = new JarURLUtil(url);
      URL jarFileURL = util.getJarFileURL();
      if (jarFileURL.getProtocol()
        .equalsIgnoreCase("file")) {
        URI uri = URI.create(jarFileURL.toExternalForm());
        Path path = new File(uri.getSchemeSpecificPart()).toPath()
          .toAbsolutePath();
        String entryName = util.getEntryName();
        if (entryName == null) {
          return new FileResource(path);
        }
        return new ZipResource(path, entryName);
      }
    }
    return new URLResource(url, client);
  }
}
origin: biz.aQute.bnd/bndlib

public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
  String type = argumentsOnMake.get("type");
  if (!type.equals("copy"))
    return null;
  String from = argumentsOnMake.get("from");
  if (from == null) {
    String content = argumentsOnMake.get("content");
    if (content == null)
      throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
    return new EmbeddedResource(content.getBytes("UTF-8"), 0);
  }
  File f = builder.getFile(from);
  if (f.isFile())
    return new FileResource(f);
  try {
    URL url = new URL(from);
    return new URLResource(url);
  }
  catch (MalformedURLException mfue) {
    // We ignore this
  }
  throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
      + destination);
}
origin: biz.aQute.bnd/biz.aQute.bnd

  static Resource fromURL(URL url, HttpClient client) throws IOException {
    if (url.getProtocol()
      .equalsIgnoreCase("file")) {
      URI uri = URI.create(url.toExternalForm());
      Path path = new File(uri.getSchemeSpecificPart()).toPath()
        .toAbsolutePath();
      return new FileResource(path);
    }
    if (url.getProtocol()
      .equals("jar")) {
      JarURLUtil util = new JarURLUtil(url);
      URL jarFileURL = util.getJarFileURL();
      if (jarFileURL.getProtocol()
        .equalsIgnoreCase("file")) {
        URI uri = URI.create(jarFileURL.toExternalForm());
        Path path = new File(uri.getSchemeSpecificPart()).toPath()
          .toAbsolutePath();
        String entryName = util.getEntryName();
        if (entryName == null) {
          return new FileResource(path);
        }
        return new ZipResource(path, entryName);
      }
    }
    return new URLResource(url, client);
  }
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception {
  String type = argumentsOnMake.get("type");
  if (!type.equals("copy"))
    return null;
  String from = argumentsOnMake.get("from");
  if (from == null) {
    String content = argumentsOnMake.get("content");
    if (content == null)
      throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
    return new EmbeddedResource(content, 0L);
  }
  File f = builder.getFile(from);
  if (f.isFile())
    return new FileResource(f);
  try {
    URL url = new URL(from);
    return Resource.fromURL(url, builder.getPlugin(HttpClient.class));
  } catch (MalformedURLException mfue) {
    // We ignore this
  }
  throw new IllegalArgumentException("Copy source does not exist " + from + " for destination " + destination);
}
origin: biz.aQute.bnd/biz.aQute.bnd

@Override
public Resource make(Builder builder, String destination, Map<String, String> argumentsOnMake) throws Exception {
  String type = argumentsOnMake.get("type");
  if (!type.equals("copy"))
    return null;
  String from = argumentsOnMake.get("from");
  if (from == null) {
    String content = argumentsOnMake.get("content");
    if (content == null)
      throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
    return new EmbeddedResource(content, 0L);
  }
  File f = builder.getFile(from);
  if (f.isFile())
    return new FileResource(f);
  try {
    URL url = new URL(from);
    return Resource.fromURL(url, builder.getPlugin(HttpClient.class));
  } catch (MalformedURLException mfue) {
    // We ignore this
  }
  throw new IllegalArgumentException("Copy source does not exist " + from + " for destination " + destination);
}
origin: biz.aQute.bnd/biz.aQute.bndlib

private void copy(Jar jar, String path, File from, Instructions preprocess, Map<String, String> extra)
  throws Exception {
  if (doNotCopy(from))
    return;
  logger.debug("copy d={} s={} path={}", jar, from, path);
  if (from.isDirectory()) {
    File files[] = from.listFiles();
    for (int i = 0; i < files.length; i++) {
      copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra);
    }
  } else {
    if (from.exists()) {
      Resource resource = new FileResource(from);
      if (preprocess != null && preprocess.matches(path)) {
        resource = new PreprocessResource(this, resource);
      }
      String x = extra.get("extra");
      if (x != null)
        resource.setExtra(x);
      if (path.endsWith("/"))
        path = path + from.getName();
      copy(jar, path, resource, extra);
    } else if (from.getName()
      .equals(Constants.EMPTY_HEADER)) {
      jar.putResource(path, new EmbeddedResource(new byte[0], 0L));
    } else {
      error("Input file does not exist: %s", from).header(INCLUDERESOURCE + "|" + INCLUDE_RESOURCE);
    }
  }
}
origin: biz.aQute/bndlib

private void copy(Jar jar, String path, File from, boolean preprocess, Map<String,String> extra) throws Exception {
  if (doNotCopy(from.getName()))
    return;
  if (from.isDirectory()) {
    File files[] = from.listFiles();
    for (int i = 0; i < files.length; i++) {
      copy(jar, appendPath(path, files[i].getName()), files[i], preprocess, extra);
    }
  } else {
    if (from.exists()) {
      Resource resource = new FileResource(from);
      if (preprocess) {
        resource = new PreprocessResource(this, resource);
      }
      String x = extra.get("extra");
      if (x != null)
        resource.setExtra(x);
      if (path.endsWith("/"))
        path = path + from.getName();
      jar.putResource(path, resource);
      if (isTrue(extra.get(LIB_DIRECTIVE))) {
        setProperty(BUNDLE_CLASSPATH, append(getProperty(BUNDLE_CLASSPATH), path));
      }
    } else if (from.getName().equals(Constants.EMPTY_HEADER)) {
      jar.putResource(path, new EmbeddedResource(new byte[0], 0));
    } else {
      error("Input file does not exist: " + from);
    }
  }
}
origin: reficio/p2-maven-plugin

XmlUtils.writeXml(featureSpec, newXml);
FileResource newRes = new FileResource(newXml);
jar.putResource("feature.xml", newRes, true);
jar.write(outputFile);
origin: biz.aQute.bnd/biz.aQute.bnd

@Override
public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception {
  project.prepare();
  Collection<Container> runbundles = project.getRunbundles();
  Jar jar = new Jar(project.getName());
  jar.setDoNotTouchManifest();
  for (Container container : runbundles) {
    File source = container.getFile();
    String path = nonCollidingPath(jar, source.getName());
    jar.putResource(path, new FileResource(source));
  }
  return new SimpleEntry<>(jar.getName(), new JarResource(jar, true));
}
origin: biz.aQute.bnd/biz.aQute.bndlib

@Override
public Entry<String, Resource> export(String type, Project project, Map<String, String> options) throws Exception {
  project.prepare();
  Collection<Container> runbundles = project.getRunbundles();
  Jar jar = new Jar(project.getName());
  jar.setDoNotTouchManifest();
  for (Container container : runbundles) {
    File source = container.getFile();
    String path = nonCollidingPath(jar, source.getName());
    jar.putResource(path, new FileResource(source));
  }
  return new SimpleEntry<>(jar.getName(), new JarResource(jar, true));
}
aQute.bnd.osgiFileResource<init>

Javadoc

Turn a resource into a file so that anything in the conversion is properly caught

Popular methods of FileResource

  • deleteOnClose
  • build
  • copy
  • traverse
  • buffer
  • getFile

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • Menu (java.awt)
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now