Search in sources :

Example 11 with Project

use of org.apache.tools.ant.Project in project tomcat by apache.

the class AntCompiler method getProject.

// ------------------------------------------------------------ Constructor
// Lazy eval - if we don't need to compile we probably don't need the project
protected Project getProject() {
    if (project != null)
        return project;
    // Initializing project
    project = new Project();
    logger = new JasperAntLogger();
    logger.setOutputPrintStream(System.out);
    logger.setErrorPrintStream(System.err);
    logger.setMessageOutputLevel(Project.MSG_INFO);
    project.addBuildListener(logger);
    if (System.getProperty(Constants.CATALINA_HOME_PROP) != null) {
        project.setBasedir(System.getProperty(Constants.CATALINA_HOME_PROP));
    }
    if (options.getCompiler() != null) {
        if (log.isDebugEnabled())
            log.debug("Compiler " + options.getCompiler());
        project.setProperty("build.compiler", options.getCompiler());
    }
    project.init();
    return project;
}
Also used : Project(org.apache.tools.ant.Project)

Example 12 with Project

use of org.apache.tools.ant.Project in project hudson-2.x by hudson.

the class Util method makeWritable.

/**
     * Makes the given file writable by any means possible.
     */
@IgnoreJRERequirement
private static void makeWritable(File f) {
    // try chmod. this becomes no-op if this is not Unix.
    try {
        Chmod chmod = new Chmod();
        chmod.setProject(new Project());
        chmod.setFile(f);
        chmod.setPerm("u+w");
        chmod.execute();
    } catch (BuildException e) {
        LOGGER.log(Level.INFO, "Failed to chmod " + f, e);
    }
    // also try JDK6-way of doing it.
    try {
        f.setWritable(true);
    } catch (NoSuchMethodError e) {
    // not JDK6
    }
    try {
        // try libc chmod
        POSIX posix = PosixAPI.get();
        String path = f.getAbsolutePath();
        FileStat stat = posix.stat(path);
        // u+w
        posix.chmod(path, stat.mode() | 0200);
    } catch (Throwable t) {
        LOGGER.log(Level.FINE, "Failed to chmod(2) " + f, t);
    }
}
Also used : Project(org.apache.tools.ant.Project) FileStat(org.jruby.ext.posix.FileStat) BuildException(org.apache.tools.ant.BuildException) Chmod(org.apache.tools.ant.taskdefs.Chmod) POSIX(org.jruby.ext.posix.POSIX) IgnoreJRERequirement(org.jvnet.animal_sniffer.IgnoreJRERequirement)

Example 13 with Project

use of org.apache.tools.ant.Project in project hudson-2.x by hudson.

the class FilePath method _chmodAnt.

private static void _chmodAnt(File f, int mask) {
    if (!CHMOD_WARNED) {
        // only warn this once to avoid flooding the log
        CHMOD_WARNED = true;
        LOGGER.warning("GNU C Library not available: Using Ant's chmod task instead.");
    }
    Chmod chmodTask = new Chmod();
    chmodTask.setProject(new Project());
    chmodTask.setFile(f);
    chmodTask.setPerm(Integer.toOctalString(mask));
    chmodTask.execute();
}
Also used : Project(org.apache.tools.ant.Project) AbstractProject(hudson.model.AbstractProject) Chmod(org.apache.tools.ant.taskdefs.Chmod)

Example 14 with Project

use of org.apache.tools.ant.Project in project hudson-2.x by hudson.

the class FilePath method glob.

/**
     * Runs Ant glob expansion.
     *
     * @return
     *      A set of relative file names from the base directory.
     */
private static String[] glob(File dir, String includes) throws IOException {
    if (isAbsolute(includes))
        throw new IOException("Expecting Ant GLOB pattern, but saw '" + includes + "'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
    FileSet fs = Util.createFileSet(dir, includes);
    DirectoryScanner ds = fs.getDirectoryScanner(new Project());
    String[] files = ds.getIncludedFiles();
    return files;
}
Also used : Project(org.apache.tools.ant.Project) AbstractProject(hudson.model.AbstractProject) FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) IOException(java.io.IOException)

Example 15 with Project

use of org.apache.tools.ant.Project in project hudson-2.x by hudson.

the class ClassicPluginStrategy method explode.

/**
     * Explodes the plugin into a directory, if necessary.
     */
private static void explode(File archive, File destDir) throws IOException {
    if (!destDir.exists())
        destDir.mkdirs();
    // timestamp check
    File explodeTime = new File(destDir, ".timestamp");
    if (explodeTime.exists() && explodeTime.lastModified() == archive.lastModified())
        // no need to expand
        return;
    // delete the contents so that old files won't interfere with new files
    Util.deleteContentsRecursive(destDir);
    try {
        Expand e = new Expand();
        e.setProject(new Project());
        e.setTaskType("unzip");
        e.setSrc(archive);
        e.setDest(destDir);
        e.execute();
    } catch (BuildException x) {
        throw new IOException2("Failed to expand " + archive, x);
    }
    try {
        new FilePath(explodeTime).touch(archive.lastModified());
    } catch (InterruptedException e) {
        // impossible
        throw new AssertionError(e);
    }
}
Also used : Project(org.apache.tools.ant.Project) Expand(org.apache.tools.ant.taskdefs.Expand) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) IOException2(hudson.util.IOException2)

Aggregations

Project (org.apache.tools.ant.Project)80 File (java.io.File)35 BuildException (org.apache.tools.ant.BuildException)23 IOException (java.io.IOException)17 Test (org.junit.Test)13 FileSet (org.apache.tools.ant.types.FileSet)11 ZipFile (java.util.zip.ZipFile)10 IgniteDeploymentGarAntTask (org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask)8 Path (org.apache.tools.ant.types.Path)6 DefaultLogger (org.apache.tools.ant.DefaultLogger)5 ProjectHelper (org.apache.tools.ant.ProjectHelper)5 MissingMethodException (groovy.lang.MissingMethodException)4 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)4 Task (org.apache.tools.ant.Task)4 AbstractProject (hudson.model.AbstractProject)3 Target (org.apache.tools.ant.Target)3 Zip (org.apache.tools.ant.taskdefs.Zip)3 CompilationFailedException (org.codehaus.groovy.control.CompilationFailedException)3 Binding (groovy.lang.Binding)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)2