Search in sources :

Example 36 with BuildException

use of org.apache.tools.ant.BuildException in project processdash by dtuma.

the class SVGToImage method execute.

public void execute() {
    if (verbose)
        log("Building SVG images");
    for (Iterator it = filesets.iterator(); it.hasNext(); ) {
        FileSet fs = (FileSet) it.next();
        FileScanner scanner = fs.getDirectoryScanner(getProject());
        String[] files = scanner.getIncludedFiles();
        try {
            File basedir = scanner.getBasedir();
            if (verbose)
                log("Scanning " + basedir);
            for (int i = 0; i < files.length; i++) {
                translate(basedir, files[i]);
            }
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Iterator(java.util.Iterator) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileScanner(org.apache.tools.ant.FileScanner)

Example 37 with BuildException

use of org.apache.tools.ant.BuildException in project processdash by dtuma.

the class AddTranslations method getExternalFileLocations.

private Map<String, String> getExternalFileLocations() {
    Map<String, String> result = new HashMap();
    if (externalDirs == null)
        return result;
    for (String oneDirName : externalDirs.split(",")) {
        oneDirName = oneDirName.trim();
        File oneDir = calcPossiblyRelativeFile(oneDirName);
        try {
            oneDir = oneDir.getCanonicalFile();
        } catch (IOException e) {
            throw new BuildException(e);
        }
        oneDir = new File(oneDir, "Templates/resources");
        if (!oneDir.isDirectory()) {
            System.out.println("Directory '" + oneDir + "' does not exist - skipping.");
            continue;
        }
        for (String oneFile : oneDir.list()) {
            if (oneFile.endsWith(".properties") && oneFile.indexOf('_') == -1) {
                String baseName = oneFile.substring(0, oneFile.length() - 11);
                result.put(baseName, oneDir.getPath() + File.separatorChar);
            }
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Example 38 with BuildException

use of org.apache.tools.ant.BuildException in project processdash by dtuma.

the class CVSZip method execute.

public void execute() throws BuildException {
    validate();
    try {
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(destFile));
        writeFiles(out);
        out.close();
    } catch (IOException ioe) {
        throw new BuildException("could not write to \"" + destFile + "\"");
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException)

Example 39 with BuildException

use of org.apache.tools.ant.BuildException in project processdash by dtuma.

the class MaybeSign method propagateProperty.

protected void propagateProperty(String propName) {
    String fullPropName = prefix + "." + propName;
    String propValue = getProject().getProperty(fullPropName);
    if (!hasValue(propValue))
        return;
    try {
        String setterMethodName = "set" + propName.substring(0, 1).toUpperCase() + propName.substring(1);
        Method m = getClass().getMethod(setterMethodName, String.class);
        m.invoke(this, propValue);
    } catch (Exception e) {
        throw new BuildException("Unexpected internal error", e);
    }
}
Also used : Method(java.lang.reflect.Method) BuildException(org.apache.tools.ant.BuildException) BuildException(org.apache.tools.ant.BuildException)

Example 40 with BuildException

use of org.apache.tools.ant.BuildException in project processdash by dtuma.

the class MergeJars method validate.

private void validate() throws BuildException {
    if (outputFile == null)
        throw new BuildException("dest must be specified.");
    if (outputFile.exists() && !outputFile.canWrite())
        throw new BuildException("cannot write to file '" + outputFile + "'.");
    if (jarFiles.isEmpty())
        throw new BuildException("no input jar files were specified.");
    openedJarFiles = new LinkedList();
    for (Iterator i = jarFiles.iterator(); i.hasNext(); ) {
        File f = (File) i.next();
        if (!f.exists())
            throw new BuildException("input jarfile '" + f + "' does not exist.");
        if (!f.canRead())
            throw new BuildException("input jarfile '" + f + "' can not be read.");
        try {
            JarFile jf = new JarFile(f);
            openedJarFiles.add(jf);
        } catch (IOException ioe) {
            throw new BuildException("the input file '" + f + "' does not appear to be a valid jarfile.");
        }
    }
    if (openedJarFiles.size() < 2)
        mergeManifests = false;
}
Also used : Iterator(java.util.Iterator) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

BuildException (org.apache.tools.ant.BuildException)930 IOException (java.io.IOException)390 File (java.io.File)365 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)75 ArrayList (java.util.ArrayList)65 InputStream (java.io.InputStream)62 Project (org.apache.tools.ant.Project)61 Resource (org.apache.tools.ant.types.Resource)58 FileSet (org.apache.tools.ant.types.FileSet)52 Path (org.apache.tools.ant.types.Path)52 Commandline (org.apache.tools.ant.types.Commandline)51 Properties (java.util.Properties)50 OutputStream (java.io.OutputStream)44 FileOutputStream (java.io.FileOutputStream)42 FileResource (org.apache.tools.ant.types.resources.FileResource)42 FileInputStream (java.io.FileInputStream)41 URL (java.net.URL)40 BufferedReader (java.io.BufferedReader)37 Writer (java.io.Writer)37 MalformedURLException (java.net.MalformedURLException)37