Browse Source

* Ant1CompatProject now provides a hacked "java.class.path" property,

which includes the ant1compat.atl file. This is closer to what's expected
  by Ant1 build files.
* antlib.xml typedefs everything it needs, in preparation for building with
  myrmidon.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272068 13f79535-47bb-0310-9956-ffa450edef68
master
Darrell DeBoer 23 years ago
parent
commit
7c531e59a9
2 changed files with 45 additions and 7 deletions
  1. +11
    -0
      proposal/myrmidon/antlib.xml
  2. +34
    -7
      proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java

+ 11
- 0
proposal/myrmidon/antlib.xml View File

@@ -19,6 +19,7 @@ Legal:
<property name="build.dir" value="build"/>
<property name="build.lib" value="${build.dir}/lib"/>
<property name="build.custom-tasks" value="${build.dir}/tasks"/>
<property name="build.classes" value="${build.dir}/classes"/>

<property name="src.base" value="src"/>
<property name="java.dir" value="${src.base}/java"/>
@@ -43,6 +44,16 @@ Legal:
<pathelement path="${build.custom-tasks}" />
</path>

<taskdef name="antlib-jar"
classname="org.apache.myrmidon.build.AntlibJarTask">
<classpath location="${build.custom-tasks}"/>
</taskdef>

<taskdef name="antlib-descriptor"
classname="org.apache.myrmidon.build.AntlibDescriptorTask">
<classpath refid="project.class.path"/>
</taskdef>

<!-- Main target -->
<target name="main" depends="antlib-jar" />



+ 34
- 7
proposal/myrmidon/src/ant1compat/org/apache/tools/ant/Ant1CompatProject.java View File

@@ -10,6 +10,7 @@ package org.apache.tools.ant;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
@@ -41,11 +42,24 @@ public class Ant1CompatProject extends Project
{
public static final String ANT1_TASK_PREFIX = "ant1.";

private static String javaclasspath;

static
{
URL ant1jar =
Ant1CompatProject.class.getProtectionDomain().getCodeSource().getLocation();
String ant1classpath = ant1jar.getFile().toString();
javaclasspath = System.getProperty( "java.class.path" ) +
File.pathSeparator +
ant1classpath;
}

private final PropertyResolver m_ant1PropertyResolver;
private final Converter m_converter;

private Set m_userProperties = new HashSet();
private TaskContext m_context;
private TaskContext m_underlyingContext;

/**
* Create an Ant1 project.
@@ -55,7 +69,8 @@ public class Ant1CompatProject extends Project
throws TaskException
{
super();
m_context = context;
recontextulize( context );

setBaseDir( m_context.getBaseDirectory() );
String projectName = (String)
m_context.getProperty( org.apache.myrmidon.interfaces.model.Project.PROJECT );
@@ -64,9 +79,9 @@ public class Ant1CompatProject extends Project
setName( projectName );
}

m_converter = (Converter)context.getService( Converter.class );
m_converter = (Converter)m_context.getService( Converter.class );

TypeManager typeManager = (TypeManager)context.getService( TypeManager.class );
TypeManager typeManager = (TypeManager)m_context.getService( TypeManager.class );
try
{
TypeFactory factory = typeManager.getFactory( PropertyResolver.ROLE );
@@ -76,7 +91,6 @@ public class Ant1CompatProject extends Project
{
throw new TaskException( "Failed to create PropertyResolver.", e );
}

}

/**
@@ -84,8 +98,21 @@ public class Ant1CompatProject extends Project
* @param context The TaskContext for the currently executing Task.
*/
void recontextulize( TaskContext context )
throws TaskException
{
m_context = context;
// Only reset the context if it is a different instance.
if( m_underlyingContext == context )
{
return;
}

// Need the underlying context for setting properties which
// should be propogated to other Tasks.
m_underlyingContext = context;

// The main context allows Ant1 specific property overrides.
m_context = context.createSubContext( "ant1-overrides" );
m_context.setProperty( "java.class.path", javaclasspath );
}

/**
@@ -360,7 +387,7 @@ public class Ant1CompatProject extends Project
}

/**
* Sets a property value in the context, wrapping exceptions as
* Sets a property value in the underlying context, wrapping exceptions as
* Ant1 BuildExceptions.
* @param name property name
* @param value property value
@@ -369,7 +396,7 @@ public class Ant1CompatProject extends Project
{
try
{
m_context.setProperty( name, value );
m_underlyingContext.setProperty( name, value );
}
catch( TaskException e )
{


Loading…
Cancel
Save