File precedence = new File("path-precedence"); if (precedence.exists()) {
Configuration.parseFile(precedence, patterns);
} else { // Put ./out at the bottom by default.
patterns.add(Pattern.compile("^(?!out/)"));
}
// Everything not matched by the user's precedence spec.
patterns.add(Pattern.compile(".*"));
List<Bucket> buckets = new ArrayList<Bucket>(patterns.size()); for (Pattern pattern : patterns) {
buckets.add(new Bucket(pattern));
}
// Put source roots in respective buckets.
OUTER: for (File sourceRoot : c.sourceRoots) { // Trim preceding "./" from path.
String path = sourceRoot.getPath().substring(2);
for (Bucket bucket : buckets) { if (bucket.matches(path)) {
bucket.sourceRoots.add(sourceRoot); continue OUTER;
}
}
}
// Output source roots to configuration file. for (Bucket bucket : buckets) { for (File sourceRoot : bucket.sourceRoots) {
classpath.append(" <classpathentry kind=\"src\"");
CharSequence excluding = constructExcluding(sourceRoot, c); if (excluding.length() > 0) {
classpath.append(" excluding=\"")
.append(excluding).append("\"");
}
classpath.append(" path=\"")
.append(trimmed(sourceRoot)).append("\"/>\n");
}
}
// Output .jar entries. for (File jar : c.jarFiles) {
classpath.append(" <classpathentry kind=\"lib\" path=\"")
.append(trimmed(jar)).append("\"/>\n");
}
Files.toFile(classpath.toString(), new File(".classpath"));
}
/** *Constructsthe"excluding"argumentforagivensourceroot.
*/ privatestatic CharSequence constructExcluding(File sourceRoot,
Configuration c) {
StringBuilder classpath = new StringBuilder();
String path = sourceRoot.getPath();
// Exclude nested source roots.
SortedSet<File> nextRoots = c.sourceRoots.tailSet(sourceRoot); int count = 0; for (File nextRoot : nextRoots) { // The first root is this root. if (count == 0) {
count++; continue;
}
String nextPath = nextRoot.getPath(); if (!nextPath.startsWith(path)) { break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.