![JAR search and dependency download from the Maven repository](/logo.png)
protoj.util.UntarTask Maven / Gradle / Ivy
Show all versions of protoj-jdk6 Show documentation
/**
* Copyright 2009 Ashley Williams
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package protoj.util;
import java.io.File;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Untar;
/**
* A convenience class for unpacking compressed tar files. Use the constructors
* to specify the minimal and most widely anticipated configuration and the
* initXXX
methods for the less common configuration options.
*
* This is a fairly thin wrapper to the ant tasks, so consult the ant help for
* more information.
*
* @author Ashley Williams
*
*/
public final class UntarTask {
private AntTarget target = new AntTarget("protoj-untar");
private Untar untar;
/**
* Creates a command that can unpack untar files of the given name in the
* given directory.
*
* @param src
* the source file to be unpacked
* @param dest
* the dest directory to unpack to
*/
public UntarTask(File src, File dest) {
untar = new Untar();
untar.setTaskName("untar");
target.addTask(untar);
untar.setSrc(src);
untar.setDest(dest);
}
/**
* Sets the untar compression with the given name.
*
* @param name
*/
public void initCompression(String name) {
Untar.UntarCompressionMethod method = new Untar.UntarCompressionMethod();
method.setValue(name);
untar.setCompression(method);
}
/**
* Enables logging to the specified log file at Project.MSG_INFO level.
*/
public void initLogging() {
target.initLogging(Project.MSG_INFO);
}
public void execute() {
target.execute();
}
public Untar getUntar() {
return untar;
}
}