org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod Java Examples
The following examples show how to use
org.apache.tools.ant.taskdefs.Untar.UntarCompressionMethod.
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: NativeUntar.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void execute() throws BuildException { try { Utils.setProject(getProject()); log("trying native untar"); Utils.nativeUntar(source, dest); } catch (IOException e) { log("native untar failed, falling back to java implementation"); Utils.delete(dest); UntarCompressionMethod compression = new UntarCompressionMethod(); if(source.getName().endsWith(".tar.gz") || source.getName().endsWith(".tgz")) { compression.setValue("gzip"); } else if(source.getName().endsWith(".tar.bz2") || source.getName().endsWith(".tar.bzip2")) { compression.setValue("bzip2"); } else { compression.setValue("none"); } setCompression(compression); super.execute(); } }
Example #2
Source File: UntarRunnable.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Internal convenience method determines the archive type from the filename * extension. */ private static UntarCompressionMethod compressionMethod(File file) { String fn = file.toString(); UntarCompressionMethod out = new UntarCompressionMethod(); if (fn.endsWith("gz")) { out.setValue("gzip"); } else if (fn.endsWith("bz2")) { out.setValue("bzip2"); } else if (fn.endsWith("tar")) { out.setValue("none"); } else { throw new IllegalArgumentException("UntarJob doesn't know what to do with that file. " + "tar, gz, and bz2 files accepted."); } return out; }
Example #3
Source File: AntDecorator.java From oodt with Apache License 2.0 | 5 votes |
public static void untarFile(File tarFile, File destDir) throws IOException { Untarer untar = new Untarer(); Untar.UntarCompressionMethod compMethod = new UntarCompressionMethod(); compMethod.setValue("gzip"); untar.setCompression(compMethod); untar.setDest(destDir); untar.setSrc(tarFile); untar.execute(); // now that the work is done, use file utils to // move everything out of destDir/tarFileNoExt // into destDir // then delete destDir/tarFileNoExt String wrongInstallDir = destDir.getCanonicalPath() + File.separator + getFileNameNoExt(tarFile.getName()); FileUtils.copyDirectory(new File(wrongInstallDir), destDir, true); // grrr java IO, love it // because it sucks, we have to CHMOD everything in destDir/bin File binDir = new File(destDir.getCanonicalPath() + File.separator + "bin"); Chmoder chmod = new Chmoder(); chmod.setDir(binDir); chmod.setPerm("ugo+rx"); chmod.setIncludes("*"); chmod.execute(); deleteAllFilesAndDir(new File(wrongInstallDir)); }