public Jar(String name, File dirOrFile) throws ZipException, IOException { this(name); source = dirOrFile; if (dirOrFile.isDirectory()) FileResource.build(this, dirOrFile, Analyzer.doNotCopy); else { zipFile = ZipResource.build(this, dirOrFile); } }
public void write(OutputStream out) throws Exception { FileResource.copy(this, out); }
public static void build(Jar jar, File directory, Pattern doNotCopy) { traverse( jar, directory.getAbsolutePath().length(), directory, doNotCopy); }
protected static Resource toResource(Object value) { if (value instanceof File) { return new FileResource((File) value); } else if (value instanceof URL) { return new URLResource((URL) value); } else { throw new IllegalArgumentException("Cannot convert value " + value + " into a Resource. Expected File or URL"); } }
static void traverse(Jar jar, int rootlength, File directory, Pattern doNotCopy) { if (doNotCopy.matcher(directory.getName()).matches()) return; 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); } } }
protected static Resource toResource(Object value) { if (value instanceof File) { return new FileResource((File) value); } else if (value instanceof URL) { return new URLResource((URL) value); } else { throw new IllegalArgumentException("Cannot convert value " + value + " into a Resource. Expected File or URL"); } }
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); } } }
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); } else { File f = builder.getFile(from); if (f.isFile()) return new FileResource(f); else { 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); } } }
public void write(OutputStream out) throws IOException { copy(this, out); }
public Jar(String name, File dirOrFile, Pattern doNotCopy) throws ZipException, IOException { this(name); source = dirOrFile; if (dirOrFile.isDirectory()) FileResource.build(this, dirOrFile, doNotCopy); else if (dirOrFile.isFile()) { zipFile = ZipResource.build(this, dirOrFile); } else { throw new IllegalArgumentException("A Jar can only accept a valid file or directory: " + dirOrFile); } }
public static void build(Jar jar, File directory, Pattern doNotCopy) { traverse( jar, directory.getAbsolutePath().length(), directory, doNotCopy); }
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); } else { File f = builder.getFile(from); if (f.isFile()) return new FileResource(f); else { 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); } } }
public void write(OutputStream out) throws Exception { FileResource.copy(this, out); }
private void copy(Jar jar, String path, File from, boolean preprocess, Map<String, String> extra) throws Exception { if (doNotCopy.matcher(from.getName()).matches()) 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); } else { error("Input file does not exist: " + from); } } }
public void write(OutputStream out) throws IOException { FileResource.copy(this, out); }
public static ComponentDef getComponentDef(File f) throws Exception { Resource r = new FileResource(f); Clazz c = new Clazz("", r); AnnotationReader car = new AnnotationReader(c); return car.getComponent(); }
public void write(OutputStream out) throws IOException { FileResource.copy(this, out); }
if (ff.isFile()) { dot.putResource("OSGI-OPT/src/" + pack + fixed[j], new FileResource(ff)); new FileResource(f));
public void write(OutputStream out) throws Exception { copy(this, out); }
String name = "OSGI-OPT/src/" + pack + fixed[j]; dot.putResource(name, new FileResource(ff)); dot.putResource("OSGI-OPT/src/" + path, new FileResource(f));