org.apache.tools.ant.MagicNames Java Examples

The following examples show how to use org.apache.tools.ant.MagicNames. 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: DefaultAntBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
    }
}
 
Example #2
Source File: DefaultAntBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void importBuild(Object antBuildFile) {
    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) {
        Target target = getAntProject().getTargets().get(name);
        AntTarget task = gradleProject.getTasks().create(target.getName(), AntTarget.class);
        task.setTarget(target);
        task.setBaseDir(baseDir);
        addDependencyOrdering(target.getDependencies());
    }
}
 
Example #3
Source File: DefaultAntBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
    }
}
 
Example #4
Source File: DefaultAntBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void importBuild(Object antBuildFile) {
    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) {
        Target target = getAntProject().getTargets().get(name);
        AntTarget task = gradleProject.getTasks().create(target.getName(), AntTarget.class);
        task.setTarget(target);
        task.setBaseDir(baseDir);
        addDependencyOrdering(target.getDependencies());
    }
}
 
Example #5
Source File: AntRunner.java    From spoofax with Apache License 2.0 5 votes vote down vote up
public AntRunner(IResourceService resourceService, FileObject antFile, FileObject baseDir,
    Map<String, String> properties, @SuppressWarnings("unused") @Nullable URL[] classpaths,
    @Nullable BuildListener listener) {
    this.antProject = new Project();

    final File localAntFile = resourceService.localFile(antFile);
    final File localBaseDir = resourceService.localPath(baseDir);

    // TODO: use classpaths

    antProject.setProperty(MagicNames.ANT_FILE, localAntFile.getPath());
    antProject.setBaseDir(localBaseDir);
    antProject.init();
    if(listener != null) {
        antProject.addBuildListener(listener);
    }

    final PropertyHelper propHelper = PropertyHelper.getPropertyHelper(antProject);
    antProject.addReference(MagicNames.REFID_PROPERTY_HELPER, propHelper);
    for(Entry<String, String> property : properties.entrySet()) {
        propHelper.setUserProperty(property.getKey(), property.getValue());
    }

    final ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
    antProject.addReference(MagicNames.REFID_PROJECT_HELPER, projectHelper);
    projectHelper.parse(antProject, localAntFile);
}