org.apache.tools.ant.taskdefs.Chmod Java Examples
The following examples show how to use
org.apache.tools.ant.taskdefs.Chmod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileUtil.java From ambari-logsearch with Apache License 2.0 | 5 votes |
public static void setPermissionOnDirectory(String dirPath, String permission) { Chmod chmod = new Chmod(); chmod.setProject(new Project()); FileSet fileSet = new FileSet(); fileSet.setDir(new File(dirPath)); fileSet.setIncludes("**"); chmod.addFileset(fileSet); chmod.setPerm(permission); chmod.execute(); }
Example #2
Source File: BasicSupport.java From ci.maven with Apache License 2.0 | 4 votes |
protected void installFromFile() throws Exception { // Check if there is a different/newer archive or missing marker to trigger assembly install File installMarker = new File(installDirectory, ".installed"); if (!refresh) { if (!installMarker.exists()) { refresh = true; } else if (assemblyArchive.lastModified() > installMarker.lastModified()) { log.debug(MessageFormat.format(messages.getString("debug.detect.assembly.archive"), "")); refresh = true; } else if(!assemblyArchive.getCanonicalPath().equals(FileUtils.fileRead(installMarker))) { refresh = true; } } else { log.debug(MessageFormat.format(messages.getString("debug.request.refresh"), "")); } String userDirectoryPath = userDirectory.getCanonicalPath(); if (refresh && installDirectory.exists() && installDirectory.isDirectory()) { log.info(MessageFormat.format(messages.getString("info.uninstalling.server.home"), installDirectory)); // Delete everything in the install directory except usr directory for(File f : installDirectory.listFiles()) { if(!(f.isDirectory() && f.getCanonicalPath().equals(userDirectoryPath))) { FileUtils.forceDelete(f); } } } // Install the assembly if (!installMarker.exists()) { log.info("Installing assembly..."); FileUtils.forceMkdir(installDirectory); Expand unzip = (Expand) ant.createTask("unzip"); unzip.setSrc(assemblyArchive); unzip.setDest(assemblyInstallDirectory.getCanonicalFile()); unzip.execute(); // Make scripts executable, since Java unzip ignores perms Chmod chmod = (Chmod) ant.createTask("chmod"); chmod.setPerm("ugo+rx"); chmod.setDir(installDirectory); chmod.setIncludes("bin/*"); chmod.setExcludes("bin/*.bat"); chmod.execute(); // delete installMarker first in case it was packaged with the assembly installMarker.delete(); installMarker.createNewFile(); // Write the assembly archive path so we can determine whether to install a different assembly in future invocations FileUtils.fileWrite(installMarker, assemblyArchive.getCanonicalPath()); } else { log.info(MessageFormat.format(messages.getString("info.reuse.installed.assembly"), "")); } }
Example #3
Source File: JarBundler.java From JarBundler with Apache License 2.0 | 3 votes |
/*************************************************************************** * Private utility methods. **************************************************************************/ private void setExecutable(File f) { Chmod chmodTask = new Chmod(); chmodTask.setProject(getProject()); chmodTask.setFile(f); chmodTask.setPerm("ugo+rx"); if (mVerbose) log("Setting \"" + bundlePath(f) + "\" to executable"); chmodTask.execute(); }