Search in sources :

Example 1 with Target

use of org.apache.tools.ant.Target in project gradle by gradle.

the class DefaultAntBuilder method importBuild.

public void importBuild(Object antBuildFile, Transformer<? extends String, ? super String> taskNamer) {
    File file = gradleProject.file(antBuildFile);
    final File baseDir = file.getParentFile();
    Set<String> existingAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    File oldBaseDir = getAntProject().getBaseDir();
    getAntProject().setBaseDir(baseDir);
    try {
        getAntProject().setUserProperty(MagicNames.ANT_FILE, file.getAbsolutePath());
        ProjectHelper.configureProject(getAntProject(), file);
    } catch (Exception e) {
        throw new GradleException("Could not import Ant build file '" + String.valueOf(file) + "'.", e);
    } finally {
        getAntProject().setBaseDir(oldBaseDir);
    }
    // Chuck away the implicit target. It has already been executed
    getAntProject().getTargets().remove("");
    // Add an adapter for each newly added target
    Set<String> newAntTargets = new HashSet<String>(getAntProject().getTargets().keySet());
    newAntTargets.removeAll(existingAntTargets);
    for (String name : newAntTargets) {
        final Target target = getAntProject().getTargets().get(name);
        String taskName = taskNamer.transform(target.getName());
        final AntTarget task = gradleProject.getTasks().create(taskName, AntTarget.class);
        configureTask(target, task, baseDir, taskNamer);
    }
}
Also used : AntTarget(org.gradle.api.tasks.ant.AntTarget) Target(org.apache.tools.ant.Target) File(java.io.File) MissingPropertyException(groovy.lang.MissingPropertyException) AntTarget(org.gradle.api.tasks.ant.AntTarget)

Example 2 with Target

use of org.apache.tools.ant.Target 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 Target

use of org.apache.tools.ant.Target in project adempiere by adempiere.

the class CreateZipFile method tarFolder.

public static void tarFolder(File srcFolder, File destTarFile, String includesdir) {
    Tar tarer = new Tar();
    tarer.setDestFile(destTarFile);
    tarer.setBasedir(srcFolder);
    tarer.setIncludes(includesdir);
    tarer.setCaseSensitive(false);
    tarer.setTaskName("tar");
    tarer.setTaskType("tar");
    tarer.setProject(new Project());
    tarer.setOwningTarget(new Target());
    tarer.execute();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) Tar(org.apache.tools.ant.taskdefs.Tar)

Example 4 with Target

use of org.apache.tools.ant.Target in project adempiere by adempiere.

the class CreateZipFile method gzipFile.

public static void gzipFile(File srcFile, File destFile) {
    GZip GZiper = new GZip();
    GZiper.setDestfile(destFile);
    GZiper.setSrc(srcFile);
    GZiper.setTaskName("gzip");
    GZiper.setTaskType("gzip");
    GZiper.setProject(new Project());
    GZiper.setOwningTarget(new Target());
    GZiper.execute();
}
Also used : Project(org.apache.tools.ant.Project) Target(org.apache.tools.ant.Target) GZip(org.apache.tools.ant.taskdefs.GZip)

Example 5 with Target

use of org.apache.tools.ant.Target in project Gargoyle by callakrsos.

the class AntJavaCompilerTest method extracted.

private Target extracted(Project p) {
    Target target = new Target() {
    };
    target.setProject(p);
    target.setName("Hello build");
    target.setDescription("Runtime Adding Target");
    Echo echo = new Echo();
    echo.setMessage("Hello ant build");
    echo.setProject(p);
    target.addTask(echo);
    return target;
}
Also used : Target(org.apache.tools.ant.Target) Echo(org.apache.tools.ant.taskdefs.Echo)

Aggregations

Target (org.apache.tools.ant.Target)7 Project (org.apache.tools.ant.Project)4 GZip (org.apache.tools.ant.taskdefs.GZip)2 MissingPropertyException (groovy.lang.MissingPropertyException)1 File (java.io.File)1 Task (org.apache.tools.ant.Task)1 Echo (org.apache.tools.ant.taskdefs.Echo)1 Expand (org.apache.tools.ant.taskdefs.Expand)1 Tar (org.apache.tools.ant.taskdefs.Tar)1 Zip (org.apache.tools.ant.taskdefs.Zip)1 AntTarget (org.gradle.api.tasks.ant.AntTarget)1