public File getFile(String file) { return getFile(base, file); }
public File getFile(String file) { return getFile(base, file); }
public void setProperties(Map<String, String> map) { File home = new File(""); String root = map.get("root"); if (root == null) { home = new File( System.getProperty("user.home") ); this.root = Processor.getFile(home , ".m2/repository").getAbsoluteFile(); } else this.root = Processor.getFile(home, root).getAbsoluteFile(); if (!this.root.isDirectory()) { reporter.error("Maven repository did not get a proper URL to the repository %s", root); } name = (String) map.get(NAME); }
public String _osfile(String args[]) { verifyCommand(args, _fileHelp, null, 3, 3); File base = new File(args[1]); File f = Processor.getFile(base, args[2]); return f.getAbsolutePath(); }
private File write(File base, Resource r, String fileName) throws Exception { File f = Processor.getFile(base, fileName); OutputStream out = new FileOutputStream(f); try { r.write(out); } finally { out.close(); } return f; }
private File write(File base, Resource r, String fileName) throws Exception { File f = Processor.getFile(base, fileName); OutputStream out = new FileOutputStream(f); try { r.write(out); } finally { out.close(); } return f; }
public void setProperties(Map<String, String> map) { String root = map.get("root"); if (root == null) { String home = System.getProperty("user.home"); root = home + "/.m2/repository"; } this.root = Processor.getFile(new File(""), root).getAbsoluteFile(); if (!this.root.isDirectory()) { reporter .error( "Maven repository did not get a proper URL to the repository %s", root); } name = (String) map.get(NAME); }
public String _dir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${dir;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = domain.getFile(args[i]); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getParentFile().getAbsolutePath()); del = ","; } } return sb.toString(); } }
public String _basename(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${basename;...}"); return null; } else { String del = ""; StringBuffer sb = new StringBuffer(); for (int i = 1; i < args.length; i++) { File f = domain.getFile(args[i]); if (f.exists() && f.getParentFile().exists()) { sb.append(del); sb.append(f.getName()); del = ","; } } return sb.toString(); } }
void find(List<String> bsns, Pattern pattern, File base, String name) { if (base.isDirectory()) { String list[] = base.list(); boolean found = false; for (String entry : list) { char c = entry.charAt(0); if (c >= '0' && c <= '9') { if (pattern.matcher(name).matches()) found = true; } else { String nextName = entry; if (name.length() != 0) nextName = name + "." + entry; File next = Processor.getFile(base, entry); find(bsns, pattern, next, nextName); } } if (found) bsns.add(name); } }
void find(List<String> bsns, Pattern pattern, File base, String name) { if (base.isDirectory()) { String list[] = base.list(); boolean found = false; for (String entry : list) { char c = entry.charAt(0); if (c >= '0' && c <= '9') { if (pattern.matcher(name).matches()) found = true; } else { String nextName = entry; if (name.length() != 0) nextName = name + "." + entry; File next = Processor.getFile(base, entry); find(bsns, pattern, next, nextName); } } if (found) bsns.add(name); } }
void unzip(InputStream in, File dir) throws Exception { try { JarInputStream jin = new JarInputStream(in); JarEntry jentry = jin.getNextJarEntry(); while (jentry != null) { if (!jentry.isDirectory()) { File dest = Processor.getFile(dir, jentry.getName()); if (!dest.isFile() || dest.lastModified() < jentry.getTime() || jentry.getTime() == 0) { dest.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(dest); try { copy(jin, out); } finally { out.close(); } } } jentry = jin.getNextJarEntry(); } } finally { in.close(); } } }
/** * Get the contents of a file. * * @param in * @return * @throws IOException */ public String _cat(String args[]) throws IOException { verifyCommand(args, "${cat;<in>}, get the content of a file", null, 2, 2); File f = domain.getFile(args[1]); if (f.isFile()) { InputStream in = new FileInputStream(f); return getString(in); } else if (f.isDirectory()) { return Arrays.toString(f.list()); } else { try { URL url = new URL(args[1]); InputStream in = url.openStream(); return getString(in); } catch (MalformedURLException mfue) { // Ignore here } return null; } }
File[] find(String groupId, String artifactId, VersionRange range) { String path = groupId.replace(".", "/"); File vsdir = Processor.getFile(root, path); if (!vsdir.isDirectory()) return null; vsdir = Processor.getFile(vsdir, artifactId); Version vvv = new Version(vv); if (range.includes(vvv)) { File file = Processor.getFile(vsdir, v + "/" + artifactId + "-" + v + ".jar"); if (file.isFile())
/** * Get the contents of a file. * * @param in * @return * @throws IOException */ public String _cat(String args[]) throws IOException { verifyCommand(args, "${cat;<in>}, get the content of a file", null, 2, 2); File f = domain.getFile(args[1]); if (f.isFile()) { return IO.collect(f); } else if (f.isDirectory()) { return Arrays.toString(f.list()); } else { try { URL url = new URL(args[1]); return IO.collect(url, "UTF-8"); } catch (MalformedURLException mfue) { // Ignore here } return null; } }
File[] find(String groupId, String artifactId, VersionRange range) { String path = groupId.replace(".", "/"); File vsdir = Processor.getFile(root, path); if (!vsdir.isDirectory()) return null; vsdir = Processor.getFile(vsdir, artifactId); Version vvv = new Version(vv); if (range.includes(vvv)) { File file = Processor.getFile(vsdir, v + "/" + artifactId + "-" + v + ".jar"); if (file.isFile())
public List<Version> versions(String bsn) { String path = bsn.replace('.', '/'); File base = Processor.getFile(root, path); if (!base.isDirectory()) { reporter.warning("Expected a directory %s", base); return null; } List<Version> result = new ArrayList<Version>(); String[] versions = base.list(); for (String v : versions) { v = Analyzer.cleanupVersion(v); if (Verifier.VERSION.matcher(v).matches()) { result.add(new Version(v)); } else { if (reporter.isPedantic()) { reporter .warning( "Invalid version in maven base directory: %s", base); } } } return result; }
File file = getFile(ubase, value).getAbsoluteFile(); if (!file.isFile() && fileMustExist) { error("Included file " + file
String parts[] = path.split("\\s*,\\s*"); for (String p : parts) { File f = getFile(p).getAbsoluteFile(); loader.add(f.toURI().toURL());
File tmp = Processor.getFile(target, repository); tmp.mkdirs();