Browse Source

Fixes to the new config task stuff

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272636 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
cae2d444f7
9 changed files with 46 additions and 48 deletions
  1. +11
    -3
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java
  2. +0
    -8
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java
  3. +0
    -1
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfigHandler.java
  4. +8
    -4
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
  5. +0
    -4
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java
  6. +2
    -4
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
  7. +1
    -1
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LoadLib.java
  8. +21
    -22
      proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java
  9. +3
    -1
      proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java

+ 11
- 3
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java View File

@@ -166,9 +166,17 @@ public class AntLibManager {
if (libraries.containsKey(libraryId)) {
AntLibrary currentVersion
= (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);
}
}
}



+ 0
- 8
proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java View File

@@ -52,17 +52,9 @@
* <http://www.apache.org/>.
*/
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.HashMap;
import java.util.Iterator;
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;

/**


+ 0
- 1
proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfigHandler.java View File

@@ -52,7 +52,6 @@
* <http://www.apache.org/>.
*/
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.modelparser.BuildElementHandler;
import org.xml.sax.Attributes;


+ 8
- 4
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java View File

@@ -111,7 +111,7 @@ public class ComponentManager implements ComponentService {
* These are AntLibraries which have been loaded into this component
* manager
*/
private Map antLibraries = new HashMap();
private static Map antLibraries = new HashMap();

/** dynamic libraries which have been defined */
private Map dynamicLibraries;
@@ -149,9 +149,12 @@ public class ComponentManager implements ComponentService {
* @param libLocation the file or URL of the library location
* @param importAll if true all tasks are imported as the library is
* loaded
* @param autoImport true if libraries in the Ant namespace should be
* automatically imported.
* @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 {
try {
Map librarySpecs = new HashMap();
@@ -162,8 +165,9 @@ public class ComponentManager implements ComponentService {
Iterator i = librarySpecs.keySet().iterator();
while (i.hasNext()) {
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);
}
}


+ 0
- 4
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java View File

@@ -52,13 +52,9 @@
* <http://www.apache.org/>.
*/
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.List;
import java.util.Map;
import org.apache.ant.antcore.antlib.AntLibManager;
import org.apache.ant.antcore.config.AntConfig;
import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.model.Project;


+ 2
- 4
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java View File

@@ -153,8 +153,6 @@ public class Frame implements DemuxOutputReceiver {
/**
* 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 initConfig Ant's initialisation config
* @exception ExecutionException if a component of the library cannot be
@@ -951,14 +949,14 @@ public class Frame implements DemuxOutputReceiver {
// load system ant lib
URL systemLibs
= new URL(initConfig.getLibraryURL(), "syslibs/");
componentManager.loadLib(systemLibs.toString(), true);
componentManager.loadLib(systemLibs.toString(), true, true);
// execute any config tasks
executeTasks(config.getTasks());
// now load other system libraries
URL antLibs = new URL(initConfig.getLibraryURL(), "antlibs/");
componentManager.loadLib(antLibs.toString(), false);
componentManager.loadLib(antLibs.toString(), false, true);
executeTasks(project.getTasks());
} catch (MalformedURLException e) {


+ 1
- 1
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LoadLib.java View File

@@ -151,7 +151,7 @@ public class LoadLib extends AbstractTask {
AntContext context = getAntContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
componentService.loadLib(url.toString(), importAll);
componentService.loadLib(url.toString(), importAll, false);
}

/**


+ 21
- 22
proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java View File

@@ -53,7 +53,6 @@
*/
package org.apache.ant.builder;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;

import java.util.List;
@@ -90,7 +89,7 @@ public class Builder {
/** the input root */
private static final File INPUT_ROOT
= new File(PACKAGE_ROOT, "input");
/** the input root */
/** the root forthe depend task's support classes */
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 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) {
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() {
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, "Location.java"));


+ 3
- 1
proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java View File

@@ -77,10 +77,12 @@ public interface ComponentService {
* @param libLocation the location of the library or the libraries
* @param importAll true if all components of the loaded libraries
* 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
* imported.
*/
void loadLib(String libLocation, boolean importAll)
void loadLib(String libLocation, boolean importAll, boolean autoImport)
throws ExecutionException;

/**


Loading…
Cancel
Save