Browse Source

Implement get all properties

Don't try to build non-existent IO library (Sorry Gump)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271122 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
4bd65dfb59
5 changed files with 112 additions and 5 deletions
  1. +18
    -4
      proposal/mutant/build.xml
  2. +10
    -0
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionDataService.java
  3. +28
    -1
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java
  4. +47
    -0
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
  5. +9
    -0
      proposal/mutant/src/java/common/org/apache/ant/common/service/DataService.java

+ 18
- 4
proposal/mutant/build.xml View File

@@ -127,9 +127,6 @@
</target>

<target name="antlibs" depends="common">
<antcall target="build-lib" inheritall="false">
<param name="libset" value="io"/>
</antcall>
<antcall target="build-lib" inheritall="false">
<param name="libset" value="system"/>
</antcall>
@@ -171,7 +168,24 @@
parampattern="[a-z].*"
staticpattern="[a-z].*"
ignoreCastWhitespace="true">
<fileset dir="${java.dir}" includes="**/*.java"/>
<fileset dir="${java.dir}">
<include name="**/*.java"/>
<exclude name="**/org/apache/tools/ant/Task.java"/>
<exclude name="**/org/apache/tools/ant/ProjectComponent.java"/>
<exclude name="**/org/apache/tools/ant/types/DataType.java"/>
</fileset>
</checkstyle>
<checkstyle maxlinelen="80"
memberpattern="[a-z].*"
parampattern="[a-z].*"
staticpattern="[a-z].*"
allowProtected="true"
ignoreCastWhitespace="true">
<fileset dir="${java.dir}">
<include name="**/org/apache/tools/ant/Task.java"/>
<include name="**/org/apache/tools/ant/ProjectComponent.java"/>
<include name="**/org/apache/tools/ant/types/DataType.java"/>
</fileset>
</checkstyle>
</target>


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

@@ -208,5 +208,15 @@ public class ExecutionDataService implements DataService {
return sb.toString();
}

/**
* Get all the properties from the frame and any references frames. This
* is an expensive operation since it must clone all of the property
* stores in all frames
*
* @return a Map containing the frames properties indexed by their full name.
*/
public Map getAllProperties() {
return frame.getAllProperties();
}
}


+ 28
- 1
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java View File

@@ -235,7 +235,7 @@ public class ExecutionFrame {
this.initConfig = initConfig;

configureServices();
antLibraries = new HashMap(standardLibs);

try {
@@ -276,6 +276,33 @@ public class ExecutionFrame {
return project;
}


/**
* Get all the properties from the frame and any references frames. This
* is an expensive operation since it must clone all of the property
* stores in all frames
*
* @return a Map containing the frames properties indexed by their full name.
*/
public Map getAllProperties() {
Map allProperties = new HashMap(dataValues);
Iterator i = referencedFrames.keySet().iterator();
while (i.hasNext()) {
String refName = (String)i.next();
ExecutionFrame refFrame = getReferencedFrame(refName);
Map refProperties = refFrame.getAllProperties();
Iterator j = refProperties.keySet().iterator();
while (j.hasNext()) {
String name = (String)j.next();
Object value = refProperties.get(name);
allProperties.put(refName + Project.REF_DELIMITER + name,
value);
}
}
return allProperties;
}

/**
* Log a message as a build event
*


+ 47
- 0
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java View File

@@ -54,6 +54,9 @@
package org.apache.tools.ant;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Map;
import java.util.Iterator;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.service.FileService;
@@ -618,5 +621,49 @@ public class Project {
throw new BuildException(e);
}
}
/**
* get a copy of the property hashtable
* @return the hashtable containing all properties, user included
*/
public Hashtable getProperties() {
Map properties = dataService.getAllProperties();
Hashtable result = new Hashtable();
for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
String name = (String)i.next();
Object value = properties.get(name);
if (value instanceof String) {
result.put(name, value);
}
}
return result;
}

/**
* get a copy of the property hashtable
* @return the hashtable containing all properties, user included
*/
public Hashtable getUserProperties() {
return getProperties();
}
/**
* Get all references in the project
* @return the hashtable containing all references
*/
public Hashtable getReferences() {
Map properties = dataService.getAllProperties();
Hashtable result = new Hashtable();
for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
String name = (String)i.next();
Object value = properties.get(name);
if (!(value instanceof String)) {
result.put(name, value);
}
}
return result;
}
}


+ 9
- 0
proposal/mutant/src/java/common/org/apache/ant/common/service/DataService.java View File

@@ -128,5 +128,14 @@ public interface DataService {
String replacePropertyRefs(String value, Map replacementValues)
throws ExecutionException;

/**
* Get all the properties from the frame and any references frames. This
* is an expensive operation since it must clone all of the property
* stores in all frames
*
* @return a Map containing the frames properties indexed by their full name.
*/
Map getAllProperties();
}


Loading…
Cancel
Save