Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.apache.tools.ant.taskdefs;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.ProjectHelperRepository;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.URLProvider;
import org.apache.tools.ant.types.resources.URLResource;
import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.util.FileUtils;
/**
* Task to import another build file into the current project.
*
* It must be 'top level'. On execution it will read another Ant file
* into the same Project.
*
*
* Important: Trying to understand how relative file references
* resolved in deep/complex build hierarchies - such as what happens
* when an imported file imports another file can be difficult. Use absolute references for
* enhanced build file stability, especially in the imported files.
*
*
Examples:
*
* <import file="../common-targets.xml"/>
*
*
Import targets from a file in a parent directory.
*
* <import file="${deploy-platform}.xml"/>
*
*
Import the project defined by the property deploy-platform.
*
* @since Ant1.6
* @ant.task category="control"
*/
public class ImportTask extends Task {
private String file;
private boolean optional;
private String targetPrefix = ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX;
private String prefixSeparator = ".";
private final Union resources = new Union();
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
public ImportTask() {
resources.setCache(true);
}
/**
* sets the optional attribute
*
* @param optional if true ignore files that are not present,
* default is false
*/
public void setOptional(boolean optional) {
this.optional = optional;
}
/**
* the name of the file to import. How relative paths are resolved is still
* in flux: use absolute paths for safety.
* @param file the name of the file
*/
public void setFile(String file) {
// I don't think we can use File - different rules
// for relative paths.
this.file = file;
}
/**
* The prefix to use when prefixing the imported target names.
*
* @since Ant 1.8.0
*/
public void setAs(String prefix) {
targetPrefix = prefix;
}
/**
* The separator to use between prefix and target name, default is
* ".".
*
* @since Ant 1.8.0
*/
public void setPrefixSeparator(String s) {
prefixSeparator = s;
}
/**
* The resource to import.
*
* @since Ant 1.8.0
*/
public void add(ResourceCollection r) {
resources.add(r);
}
public void execute() {
if (file == null && resources.size() == 0) {
throw new BuildException("import requires file attribute or"
+ " at least one nested resource");
}
if (getOwningTarget() == null
|| !"".equals(getOwningTarget().getName())) {
throw new BuildException("import only allowed as a top-level task");
}
ProjectHelper helper =
(ProjectHelper) getProject().
getReference(ProjectHelper.PROJECTHELPER_REFERENCE);
if (helper == null) {
// this happens if the projecthelper was not registered with the project.
throw new BuildException("import requires support in ProjectHelper");
}
Vector