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;
}
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);
}
}
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();
}
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;
}
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);
}
}
Aggregations