org.gradle.api.internal.project.DefaultAntBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2013 the original author or authors.
*
* 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 org.gradle.api.internal.project;
import com.google.common.collect.Sets;
import groovy.lang.GroovyObject;
import groovy.lang.MissingPropertyException;
import groovy.util.ObservableMap;
import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.PropertyHelper;
import org.apache.tools.ant.Target;
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.Transformer;
import org.gradle.api.UnknownTaskException;
import org.gradle.api.internal.project.ant.AntLoggingAdapter;
import org.gradle.api.internal.project.ant.BasicAntBuilder;
import org.gradle.api.internal.tasks.TaskDependencyInternal;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.ant.AntTarget;
import org.gradle.internal.Transformers;
import javax.annotation.Nullable;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
public class DefaultAntBuilder extends BasicAntBuilder implements GroovyObject {
private final Project gradleProject;
private final AntLoggingAdapter loggingAdapter;
public DefaultAntBuilder(Project gradleProject, AntLoggingAdapter loggingAdapter) {
this.gradleProject = gradleProject;
this.loggingAdapter = loggingAdapter;
}
public void propertyMissing(String property, Object newValue) {
doSetProperty(property, newValue);
}
@SuppressWarnings("deprecation")
private void doSetProperty(String property, Object newValue) {
PropertyHelper.getPropertyHelper(getProject()).setUserProperty(null, property, newValue);
}
public Object propertyMissing(String name) {
if (getProject().getProperties().containsKey(name)) {
return getProject().getProperties().get(name);
}
throw new MissingPropertyException(name, getClass());
}
@Override
public Map getProperties() {
ObservableMap map = new ObservableMap(getProject().getProperties());
map.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
doSetProperty(event.getPropertyName(), event.getNewValue());
}
});
@SuppressWarnings("unchecked") Map castMap = (Map) map;
return castMap;
}
@Override
public Map getReferences() {
ObservableMap map = new ObservableMap(getProject().getReferences());
map.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
getProject().addReference(event.getPropertyName(), event.getNewValue());
}
});
@SuppressWarnings("unchecked") Map castMap = (Map) map;
return castMap;
}
@Override
public void importBuild(Object antBuildFile) {
importBuild(antBuildFile, Transformers.noOpTransformer());
}
@Override
public void importBuild(Object antBuildFile, String baseDirectory) {
importBuild(antBuildFile, baseDirectory, Transformers.noOpTransformer());
}
@Override
public void importBuild(Object antBuildFile, Transformer extends String, ? super String> taskNamer) {
importBuild(antBuildFile, null, taskNamer);
}
@Override
public void importBuild(Object antBuildFile, String baseDirectory, Transformer extends String, ? super String> taskNamer) {
File file = gradleProject.file(antBuildFile);
Optional
© 2015 - 2025 Weber Informatics LLC | Privacy Policy