Browse Source

Fixes, build file, get it to work.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272729 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 23 years ago
parent
commit
892725299a
4 changed files with 61 additions and 33 deletions
  1. +23
    -33
      proposal/sandbox/embed/RuntimeConfigurable2.java
  2. BIN
      proposal/sandbox/embed/ant-sax2.jar
  3. +37
    -0
      proposal/sandbox/embed/build.xml
  4. +1
    -0
      proposal/sandbox/embed/org.apache.tools.ant.ProjectHelper

+ 23
- 33
proposal/sandbox/embed/RuntimeConfigurable2.java View File

@@ -58,6 +58,7 @@ import org.apache.tools.ant.helper.*;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Vector;
import java.util.Hashtable;
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributeListImpl;
@@ -98,6 +99,8 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable {
super( proxy, elementTag );
wrappedObject = proxy;
this.elementTag = elementTag;
if( proxy instanceof Task )
((Task)proxy).setRuntimeConfigurableWrapper( this );
}

/**
@@ -280,7 +283,6 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable {
try {
ih.setAttribute(project, target,
attrs.getQName(i).toLowerCase(Locale.US), value);
} catch (BuildException be) {
// id attribute must be set externally
if (!attrs.getQName(i).equals("id")) {
@@ -329,7 +331,19 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable {
return sb.toString();

}

static Hashtable propertySources=new Hashtable();

public static interface ProjectPropertySource {

public String getProperty( Project project, String key );
}
public static void addPropertySource( String ns, ProjectPropertySource src ) {
propertySources.put( ns, src );
}

/** Use the reference table to generate values for ${} substitution.
* To preserve backward compat ( as much as possible ) we'll only process
@@ -343,20 +357,6 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable {
* bean:idName.propertyName - we get the idName and call the getter for the property.
*/
static String processReference( Project project, String name ) {
if( name.startsWith("dom:") ) {
name=name.substring( 4 );
int idx=name.indexOf(":");
if( idx<0 ) return null;

String objName=name.substring( 0, idx );
String path=name.substring( idx );
System.out.println("XXX dom: " + objName + " " + path );

Object v=project.getReference( objName );
if( v==null ) return null;

}

if( name.startsWith( "toString:" )) {
name=name.substring( "toString:".length());
Object v=project.getReference( name );
@@ -364,26 +364,16 @@ public class RuntimeConfigurable2 extends RuntimeConfigurable {
return v.toString();
}

if( name.startsWith( "bean:" )) {
name=name.substring( "toString:".length());
int idx=name.indexOf(":");
if( idx<0 ) return null;

String objName=name.substring( 0, idx );
String path=name.substring( idx );
System.out.println("XXX bean: " + objName + " " + path );
int idx=name.indexOf(":");
if( idx<0 ) return null;

Object v=project.getReference( objName );
if( v==null ) return null;

return v.toString();
}
String ns=name.substring( 0, idx );
String path=name.substring( idx );

ProjectPropertySource ps=(ProjectPropertySource)propertySources.get( ns );
if( ps == null )
return null;

// If everything else fails, use toString()
return null;
return ps.getProperty( project, path );
}


}

BIN
proposal/sandbox/embed/ant-sax2.jar View File


+ 37
- 0
proposal/sandbox/embed/build.xml View File

@@ -0,0 +1,37 @@
<project name="helper2" default="main" >
<property name="ant.src" location="../../.." />
<property name="ant.build" location="${ant.src}/build" />
<property name="debug" value="true"/>

<target name="main">
<copy file="ProjectHelperImpl2.java"
todir="${ant.src}/src/main/org/apache/tools/ant/helper" />
<copy file="RuntimeConfigurable2.java"
todir="${ant.src}/src/main/org/apache/tools/ant" />

<javac srcdir="${ant.src}/src"
debug="${debug}"
destdir="${ant.build}/classes" >
<classpath location="${ant.build}/classes" />
<include name="**/ProjectHelperImpl2.java" />
<include name="**/RuntimeConfigurable2.java" />
</javac>

<mkdir dir="${ant.build}/classes/META-INF/services" />

<copy file="org.apache.tools.ant.ProjectHelper"
tofile="${ant.build}/classes/META-INF/services/org.apache.tools.ant.ProjectHelper" />

<jar file="ant-sax2.jar" basedir="${ant.build}/classes" >
<include name="META-INF/**" />
<include name="org/apache/tools/ant/helper/ProjectHelperImpl2*" />
<include name="org/apache/tools/ant/RuntimeConfigurable2*" />
</jar>
</target>

<target name="clean">
<delete file="${ant.src}/src/main/org/apache/tools/ant/RuntimeConfigurable2.java" />
<delete file="${ant.src}/src/main/org/apache/tools/ant/helper/ProjectHelperImpl2.java" />
</target>

</project>

+ 1
- 0
proposal/sandbox/embed/org.apache.tools.ant.ProjectHelper View File

@@ -0,0 +1 @@
org.apache.tools.ant.helper.ProjectHelperImpl2

Loading…
Cancel
Save