/** * Extra the paths for the directories and files that are used in the * Include-Resource header. * * @return */ private Collection<String> getIncludedResourcePrefixes() { List<String> prefixes = new ArrayList<String>(); Parameters includeResource = getIncludeResource(); for (Entry<String,Attrs> p : includeResource.entrySet()) { if (p.getValue().containsKey("literal")) continue; Matcher m = IR_PATTERN.matcher(p.getKey()); if (m.matches()) { File f = getFile(m.group(1)); prefixes.add(f.getAbsolutePath()); } } return prefixes; }
/** * Extra the paths for the directories and files that are used in the * Include-Resource header. * * @return */ private Collection<String> getIncludedResourcePrefixes() { List<String> prefixes = new ArrayList<String>(); Parameters includeResource = getIncludeResource(); for (Entry<String,Attrs> p : includeResource.entrySet()) { if (p.getValue().containsKey("literal")) continue; Matcher m = IR_PATTERN.matcher(p.getKey()); if (m.matches()) { File f = getFile(m.group(1)); prefixes.add(f.getAbsolutePath()); } } return prefixes; }
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); }
/** * Extra the paths for the directories and files that are used in the * Include-Resource header. * * @return */ private Collection<String> getIncludedResourcePrefixes() { List<String> prefixes = new ArrayList<String>(); Parameters includeResource = getIncludeResource(); for (Entry<String,Attrs> p : includeResource.entrySet()) { if (p.getValue().containsKey("literal")) continue; Matcher m = IR_PATTERN.matcher(p.getKey()); if (m.matches()) { File f = getFile(m.group(1)); prefixes.add(f.getAbsolutePath()); } } return prefixes; }
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); }
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); }
@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); }
@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); }
/** * 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(); File fp = f.getParentFile(); if (!fp.exists() && !fp.mkdirs()) { throw new IOException("Could not create directory " + fp); } OutputStream out = new FileOutputStream(f); try { Jar.writeManifest(dot.getManifest(), out); } finally { out.close(); } changedFile(f); }
/** * 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(); File fp = f.getParentFile(); if (!fp.exists() && !fp.mkdirs()) { throw new IOException("Could not create directory " + fp); } OutputStream out = new FileOutputStream(f); try { Jar.writeManifest(dot.getManifest(), out); } finally { out.close(); } changedFile(f); }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = getProperty(SOURCEPATH); if (sp != null) { Parameters map = parseHeader(sp); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: " + f); } else { sourcePath.add(f); } } } } } return sourcePath; }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = getProperty(SOURCEPATH); if (sp != null) { Parameters map = parseHeader(sp); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: " + f); } else { sourcePath.add(f); } } } } } return sourcePath; }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = getProperty(SOURCEPATH); if (sp != null) { Parameters map = parseHeader(sp); for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: " + f); } else { sourcePath.add(f); } } } } } return sourcePath; }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = mergeProperties(SOURCEPATH); if (sp != null) { Parameters map = parseHeader(sp); for (Iterator<String> i = map.keySet() .iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: %s", f).header(SOURCEPATH) .context(file); } else { sourcePath.add(f); } } } } } return sourcePath; }
public Collection<File> getSourcePath() { if (firstUse) { firstUse = false; String sp = mergeProperties(SOURCEPATH); if (sp != null) { Parameters map = parseHeader(sp); for (Iterator<String> i = map.keySet() .iterator(); i.hasNext();) { String file = i.next(); if (!isDuplicate(file)) { File f = getFile(file); if (!f.isDirectory()) { error("Adding a sourcepath that is not a directory: %s", f).header(SOURCEPATH) .context(file); } else { sourcePath.add(f); } } } } } return sourcePath; }
/** * Turn this normal bundle in a web and add any resources. * * @throws Exception */ private Jar doWab(Jar dot) throws Exception { String wab = getProperty(WAB); String wablib = getProperty(WABLIB); if (wab == null && wablib == null) return dot; logger.debug("wab {} {}", wab, wablib); setBundleClasspath(append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH))); Set<String> paths = new HashSet<>(dot.getResources() .keySet()); for (String path : paths) { if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) { logger.debug("wab: moving: {}", path); dot.rename(path, "WEB-INF/classes/" + path); } } Parameters clauses = parseHeader(getProperty(WABLIB)); for (Map.Entry<String, Attrs> entry : clauses.entrySet()) { File f = getFile(entry.getKey()); addWabLib(dot, f, entry.getKey(), entry.getValue()); } doIncludeResource(dot, wab); return dot; }
/** * 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"); } if (!f.exists() || f.lastModified() < dot.lastModified()) { IO.delete(f); File fp = f.getParentFile(); IO.mkdirs(fp); try (OutputStream out = IO.outputStream(f)) { Jar.writeManifest(dot.getManifest(), out); } changedFile(f); } }
/** * 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"); } if (!f.exists() || f.lastModified() < dot.lastModified()) { IO.delete(f); File fp = f.getParentFile(); IO.mkdirs(fp); try (OutputStream out = IO.outputStream(f)) { Jar.writeManifest(dot.getManifest(), out); } changedFile(f); } }
Collection<String> parts = split(cp, ","); for (String part : parts) { File sub = getFile(f.getParentFile(), part); if (!sub.exists() || !sub.getParentFile().equals(f.getParentFile())) { warning("Invalid Class-Path entry %s in %s, must exist and must reside in same directory", sub,
/** * Turn this normal bundle in a web and add any resources. * * @throws Exception */ private Jar doWab(Jar dot) throws Exception { String wab = getProperty(WAB); String wablib = getProperty(WABLIB); if (wab == null && wablib == null) return dot; trace("wab %s %s", wab, wablib); setBundleClasspath(append("WEB-INF/classes", getProperty(BUNDLE_CLASSPATH))); Set<String> paths = new HashSet<String>(dot.getResources().keySet()); for (String path : paths) { if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) { trace("wab: moving: %s", path); dot.rename(path, "WEB-INF/classes/" + path); } } Parameters clauses = parseHeader(getProperty(WABLIB)); for (String key : clauses.keySet()) { File f = getFile(key); addWabLib(dot, f); } doIncludeResource(dot, wab); return dot; }