use of org.apache.tools.ant.BuildException in project mkgmap by openstreetmap.
the class MKGMapTask method execute.
public void execute() {
List<String> args = new ArrayList<String>();
try {
CommandArgsReader argsReader = new CommandArgsReader(new Main());
if (configFile != null)
args.add("--read-config=" + configFile);
for (Path path : paths) {
String[] includedFiles = path.list();
for (String filename : includedFiles) {
log("processing " + filename);
args.add("--input-file=" + filename);
}
}
argsReader.readArgs(args.toArray(new String[args.size()]));
} catch (Exception ex) {
// log(ex, 1);
throw new BuildException(ex);
}
}
use of org.apache.tools.ant.BuildException in project JikesRVM by JikesRVM.
the class TruncateTask method execute.
public void execute() throws BuildException {
if (null == file)
throw new BuildException("file not set.");
if (0 >= size)
throw new BuildException("size not set to a value greater than 0.");
if (file.length() < size) {
return;
}
try {
final RandomAccessFile random = new RandomAccessFile(file, "rw");
random.setLength(size);
random.close();
} catch (IOException e) {
throw new BuildException("Error truncating file " + file, e);
}
}
use of org.apache.tools.ant.BuildException in project JikesRVM by JikesRVM.
the class GenerateBootImageSizeSummary method computeTotalImageSizes.
private SortedMap<String, String> computeTotalImageSizes() {
SortedMap<String, String> imageNameToTotalImageSize = new TreeMap<String, String>();
File[] subDirectories = imageDir.listFiles();
if (subDirectories == null) {
throw new BuildException("Image directory " + imageDir + " doesn't exist!");
}
for (File dir : subDirectories) {
if (!dir.isDirectory()) {
continue;
} else {
log("Found (potential) boot image directory: " + dir.getAbsolutePath(), VERBOSE);
long totalSize = 0;
for (File imageFile : dir.listFiles(IMAGE_NAMES_FILTER)) {
log("Found image file: " + imageFile.getAbsolutePath(), VERBOSE);
totalSize += imageFile.length();
}
if (totalSize > 0) {
imageNameToTotalImageSize.put(dir.getName(), Long.toString(totalSize));
log("Total image size for " + dir + " was: " + totalSize, VERBOSE);
} else {
log("Directory " + dir + " didn't contain valid image files.", VERBOSE);
}
}
}
return imageNameToTotalImageSize;
}
use of org.apache.tools.ant.BuildException in project JikesRVM by JikesRVM.
the class GenerateBootImageSizeSummary method verifyTaskAttributes.
private void verifyTaskAttributes() {
if (summaryFile == null) {
throw new BuildException("summaryFile not set. " + "It must be set to the name of a not yet existing file.");
} else if (summaryFile.isDirectory()) {
throw new BuildException("Expected summaryFile (" + summaryFile + ") to be a file but it's a directory.");
}
log("Summary file set to " + summaryFile, VERBOSE);
if (imageDir == null) {
throw new BuildException("imageDir not set. " + "It must be set to the directory containing the boot image directories " + "(e.g. dist by default).");
} else if (imageDir.isFile()) {
throw new BuildException("Expected imageDir (" + imageDir + ") to be a directory but it's a file.");
}
log("Image directory set to " + imageDir, VERBOSE);
}
use of org.apache.tools.ant.BuildException in project JikesRVM by JikesRVM.
the class SelectRegexTask method matchFile.
private String matchFile() {
BufferedReader input = null;
try {
final Regexp regexp = this.pattern.getRegexp(getProject());
input = new BufferedReader(new FileReader(file));
String[] lines = new String[patternLines];
String sep = System.getProperty("line.separator");
for (int i = 0; i < lines.length; i++) {
lines[i] = "";
}
int nextLine = 0;
while ((lines[nextLine] = input.readLine()) != null) {
StringBuilder sb = new StringBuilder();
for (int i = nextLine + 1; i <= nextLine + lines.length; i++) {
String line = lines[i % lines.length];
sb.append(line);
sb.append(sep);
}
String result = performMatching(sb.toString());
if (result != null) {
return result;
}
nextLine = (nextLine + 1) % lines.length;
}
return null;
} catch (IOException ioe) {
throw new BuildException("Error loading file " + file, ioe, getLocation());
} finally {
if (input != null) {
try {
input.close();
} catch (final IOException ioe) {
// ignore
}
}
}
}
Aggregations