git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272636 13f79535-47bb-0310-9956-ffa450edef68master
@@ -166,9 +166,17 @@ public class AntLibManager { | |||||
if (libraries.containsKey(libraryId)) { | if (libraries.containsKey(libraryId)) { | ||||
AntLibrary currentVersion | AntLibrary currentVersion | ||||
= (AntLibrary) libraries.get(libraryId); | = (AntLibrary) libraries.get(libraryId); | ||||
throw new ExecutionException("Ant Library \"" + libraryId | |||||
+ "\" is already loaded from " | |||||
+ currentVersion.getDefinitionURL()); | |||||
// same location? | |||||
AntLibrarySpec spec | |||||
= (AntLibrarySpec) librarySpecs.get(libraryId); | |||||
URL specURL = spec.getLibraryURL(); | |||||
if (!specURL.equals(currentVersion.getDefinitionURL())) { | |||||
throw new ExecutionException("Ant Library \"" + libraryId | |||||
+ "\" is already loaded from " | |||||
+ currentVersion.getDefinitionURL() | |||||
+ " new version found at " | |||||
+ specURL); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -52,17 +52,9 @@ | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.ant.antcore.config; | package org.apache.ant.antcore.config; | ||||
import java.io.File; | |||||
import java.net.MalformedURLException; | |||||
import java.net.URL; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import org.apache.ant.common.util.ConfigException; | |||||
import org.apache.ant.common.util.PathTokenizer; | |||||
import org.apache.ant.init.InitUtils; | |||||
import org.apache.ant.common.model.BuildElement; | import org.apache.ant.common.model.BuildElement; | ||||
/** | /** | ||||
@@ -52,7 +52,6 @@ | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.ant.antcore.config; | package org.apache.ant.antcore.config; | ||||
import org.apache.ant.common.util.ConfigException; | |||||
import org.apache.ant.antcore.xml.ElementHandler; | import org.apache.ant.antcore.xml.ElementHandler; | ||||
import org.apache.ant.antcore.modelparser.BuildElementHandler; | import org.apache.ant.antcore.modelparser.BuildElementHandler; | ||||
import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||||
@@ -111,7 +111,7 @@ public class ComponentManager implements ComponentService { | |||||
* These are AntLibraries which have been loaded into this component | * These are AntLibraries which have been loaded into this component | ||||
* manager | * manager | ||||
*/ | */ | ||||
private Map antLibraries = new HashMap(); | |||||
private static Map antLibraries = new HashMap(); | |||||
/** dynamic libraries which have been defined */ | /** dynamic libraries which have been defined */ | ||||
private Map dynamicLibraries; | private Map dynamicLibraries; | ||||
@@ -149,9 +149,12 @@ public class ComponentManager implements ComponentService { | |||||
* @param libLocation the file or URL of the library location | * @param libLocation the file or URL of the library location | ||||
* @param importAll if true all tasks are imported as the library is | * @param importAll if true all tasks are imported as the library is | ||||
* loaded | * loaded | ||||
* @param autoImport true if libraries in the Ant namespace should be | |||||
* automatically imported. | |||||
* @exception ExecutionException if the library cannot be loaded | * @exception ExecutionException if the library cannot be loaded | ||||
*/ | */ | ||||
public void loadLib(String libLocation, boolean importAll) | |||||
public void loadLib(String libLocation, boolean importAll, | |||||
boolean autoImport) | |||||
throws ExecutionException { | throws ExecutionException { | ||||
try { | try { | ||||
Map librarySpecs = new HashMap(); | Map librarySpecs = new HashMap(); | ||||
@@ -162,8 +165,9 @@ public class ComponentManager implements ComponentService { | |||||
Iterator i = librarySpecs.keySet().iterator(); | Iterator i = librarySpecs.keySet().iterator(); | ||||
while (i.hasNext()) { | while (i.hasNext()) { | ||||
String libraryId = (String) i.next(); | String libraryId = (String) i.next(); | ||||
if (importAll | |||||
|| libraryId.startsWith(Constants.ANT_LIB_PREFIX)) { | |||||
boolean doAuto = autoImport | |||||
&& libraryId.startsWith(Constants.ANT_LIB_PREFIX); | |||||
if (importAll || doAuto) { | |||||
importLibrary(libraryId); | importLibrary(libraryId); | ||||
} | } | ||||
} | } | ||||
@@ -52,13 +52,9 @@ | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.ant.antcore.execution; | package org.apache.ant.antcore.execution; | ||||
import java.net.MalformedURLException; | |||||
import java.net.URL; | |||||
import java.util.HashMap; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.ant.antcore.antlib.AntLibManager; | |||||
import org.apache.ant.antcore.config.AntConfig; | import org.apache.ant.antcore.config.AntConfig; | ||||
import org.apache.ant.common.event.BuildListener; | import org.apache.ant.common.event.BuildListener; | ||||
import org.apache.ant.common.model.Project; | import org.apache.ant.common.model.Project; | ||||
@@ -153,8 +153,6 @@ public class Frame implements DemuxOutputReceiver { | |||||
/** | /** | ||||
* Create an Execution Frame for the given project | * Create an Execution Frame for the given project | ||||
* | * | ||||
* @param standardLibs The libraries of tasks and types available to this | |||||
* frame | |||||
* @param config the user config to use for this execution of Ant | * @param config the user config to use for this execution of Ant | ||||
* @param initConfig Ant's initialisation config | * @param initConfig Ant's initialisation config | ||||
* @exception ExecutionException if a component of the library cannot be | * @exception ExecutionException if a component of the library cannot be | ||||
@@ -951,14 +949,14 @@ public class Frame implements DemuxOutputReceiver { | |||||
// load system ant lib | // load system ant lib | ||||
URL systemLibs | URL systemLibs | ||||
= new URL(initConfig.getLibraryURL(), "syslibs/"); | = new URL(initConfig.getLibraryURL(), "syslibs/"); | ||||
componentManager.loadLib(systemLibs.toString(), true); | |||||
componentManager.loadLib(systemLibs.toString(), true, true); | |||||
// execute any config tasks | // execute any config tasks | ||||
executeTasks(config.getTasks()); | executeTasks(config.getTasks()); | ||||
// now load other system libraries | // now load other system libraries | ||||
URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/"); | URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/"); | ||||
componentManager.loadLib(antLibs.toString(), false); | |||||
componentManager.loadLib(antLibs.toString(), false, true); | |||||
executeTasks(project.getTasks()); | executeTasks(project.getTasks()); | ||||
} catch (MalformedURLException e) { | } catch (MalformedURLException e) { | ||||
@@ -151,7 +151,7 @@ public class LoadLib extends AbstractTask { | |||||
AntContext context = getAntContext(); | AntContext context = getAntContext(); | ||||
ComponentService componentService = (ComponentService) | ComponentService componentService = (ComponentService) | ||||
context.getCoreService(ComponentService.class); | context.getCoreService(ComponentService.class); | ||||
componentService.loadLib(url.toString(), importAll); | |||||
componentService.loadLib(url.toString(), importAll, false); | |||||
} | } | ||||
/** | /** | ||||
@@ -53,7 +53,6 @@ | |||||
*/ | */ | ||||
package org.apache.ant.builder; | package org.apache.ant.builder; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FilenameFilter; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -90,7 +89,7 @@ public class Builder { | |||||
/** the input root */ | /** the input root */ | ||||
private static final File INPUT_ROOT | private static final File INPUT_ROOT | ||||
= new File(PACKAGE_ROOT, "input"); | = new File(PACKAGE_ROOT, "input"); | ||||
/** the input root */ | |||||
/** the root forthe depend task's support classes */ | /** the root forthe depend task's support classes */ | ||||
private static final File DEPEND_ROOT | private static final File DEPEND_ROOT | ||||
@@ -107,21 +106,22 @@ public class Builder { | |||||
} | } | ||||
/** | /** | ||||
* Add all the java files fro, a given directory. | |||||
* Add all the java files from a given directory. | |||||
* | * | ||||
* @param files the list to which the files are to be added. | * @param files the list to which the files are to be added. | ||||
* @param dir the directory from which the Java files are added. | * @param dir the directory from which the Java files are added. | ||||
* @param recurse true if subdirectories should be searched. | |||||
*/ | */ | ||||
private void addJavaFiles(List files, File dir) { | |||||
File[] javaFiles = dir.listFiles(new FilenameFilter() { | |||||
public boolean accept(File dir, String name) { | |||||
return name.endsWith(".java"); | |||||
} | |||||
}); | |||||
private void addJavaFiles(List files, File dir, boolean recurse) { | |||||
File[] javaFiles = dir.listFiles(); | |||||
if (javaFiles != null) { | if (javaFiles != null) { | ||||
for (int i = 0; i < javaFiles.length; ++i) { | for (int i = 0; i < javaFiles.length; ++i) { | ||||
files.add(javaFiles[i]); | |||||
if (javaFiles[i].isDirectory() && recurse) { | |||||
addJavaFiles(files, javaFiles[i], recurse); | |||||
} else if (javaFiles[i].getName().endsWith(".java")) { | |||||
files.add(javaFiles[i]); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -134,18 +134,17 @@ public class Builder { | |||||
*/ | */ | ||||
private File[] getAnt1Files() { | private File[] getAnt1Files() { | ||||
List files = new ArrayList(); | List files = new ArrayList(); | ||||
addJavaFiles(files, TASKDEFS_ROOT); | |||||
addJavaFiles(files, new File(TASKDEFS_ROOT, "compilers")); | |||||
addJavaFiles(files, new File(TASKDEFS_ROOT, "condition")); | |||||
addJavaFiles(files, DEPEND_ROOT); | |||||
addJavaFiles(files, new File(DEPEND_ROOT, "constantpool")); | |||||
addJavaFiles(files, TYPES_ROOT); | |||||
addJavaFiles(files, FILTERS_ROOT); | |||||
addJavaFiles(files, UTIL_ROOT); | |||||
addJavaFiles(files, new File(UTIL_ROOT, "depend")); | |||||
addJavaFiles(files, ZIP_ROOT); | |||||
addJavaFiles(files, new File(UTIL_ROOT, "facade")); | |||||
addJavaFiles(files, INPUT_ROOT); | |||||
addJavaFiles(files, TASKDEFS_ROOT, false); | |||||
addJavaFiles(files, new File(TASKDEFS_ROOT, "compilers"), true); | |||||
addJavaFiles(files, new File(TASKDEFS_ROOT, "condition"), true); | |||||
addJavaFiles(files, DEPEND_ROOT, true); | |||||
addJavaFiles(files, TYPES_ROOT, true); | |||||
addJavaFiles(files, FILTERS_ROOT, false); | |||||
addJavaFiles(files, UTIL_ROOT, false); | |||||
addJavaFiles(files, new File(UTIL_ROOT, "depend"), false); | |||||
addJavaFiles(files, new File(UTIL_ROOT, "facade"), true); | |||||
addJavaFiles(files, ZIP_ROOT, true); | |||||
addJavaFiles(files, INPUT_ROOT, true); | |||||
files.add(new File(PACKAGE_ROOT, "BuildException.java")); | files.add(new File(PACKAGE_ROOT, "BuildException.java")); | ||||
files.add(new File(PACKAGE_ROOT, "Location.java")); | files.add(new File(PACKAGE_ROOT, "Location.java")); | ||||
@@ -77,10 +77,12 @@ public interface ComponentService { | |||||
* @param libLocation the location of the library or the libraries | * @param libLocation the location of the library or the libraries | ||||
* @param importAll true if all components of the loaded libraries | * @param importAll true if all components of the loaded libraries | ||||
* should be imported | * should be imported | ||||
* @param autoImport true if libraries in the Ant namespace should be | |||||
* automatically imported. | |||||
* @exception ExecutionException if the library or libraries cannot be | * @exception ExecutionException if the library or libraries cannot be | ||||
* imported. | * imported. | ||||
*/ | */ | ||||
void loadLib(String libLocation, boolean importAll) | |||||
void loadLib(String libLocation, boolean importAll, boolean autoImport) | |||||
throws ExecutionException; | throws ExecutionException; | ||||
/** | /** | ||||