Search in sources :

Example 1 with Expand

use of org.apache.tools.ant.taskdefs.Expand 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)

Example 2 with Expand

use of org.apache.tools.ant.taskdefs.Expand in project adempiere by adempiere.

the class CreateZipFile method unpackFile.

public static void unpackFile(File zipFilepath, File destinationDir) {
    Expand Unzipper = new Expand();
    Unzipper.setDest(destinationDir);
    Unzipper.setSrc(zipFilepath);
    Unzipper.setTaskType("unzip");
    Unzipper.setTaskName("unzip");
    Unzipper.setProject(new Project());
    Unzipper.setOwningTarget(new Target());
    Unzipper.execute();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) Expand(org.apache.tools.ant.taskdefs.Expand)

Example 3 with Expand

use of org.apache.tools.ant.taskdefs.Expand in project JessMA by ldcsaa.

the class UnArchiver method getTask.

/** 获取解压任务对象 */
@Override
protected Task getTask() {
    Project project = new Project();
    Expand expand = getExpand();
    PatternSet ps = getPatternSet();
    expand.setProject(project);
    expand.setSrc(getSourceFile());
    expand.setDest(getTargetDir());
    expand.setOverwrite(isOverwrite());
    if (ps != null) {
        ps.setProject(project);
        expand.addPatternset(ps);
    }
    return expand;
}
Also used : Project(org.apache.tools.ant.Project) Expand(org.apache.tools.ant.taskdefs.Expand) PatternSet(org.apache.tools.ant.types.PatternSet)

Aggregations

Project (org.apache.tools.ant.Project)3 Expand (org.apache.tools.ant.taskdefs.Expand)3 IOException2 (hudson.util.IOException2)1 File (java.io.File)1 BuildException (org.apache.tools.ant.BuildException)1 Target (org.apache.tools.ant.Target)1 PatternSet (org.apache.tools.ant.types.PatternSet)1