Browse Source

Added register-datatype task

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268343 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
51e2cc5435
4 changed files with 75 additions and 0 deletions
  1. +21
    -0
      proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java
  2. +43
    -0
      proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterDataType.java
  3. +10
    -0
      proposal/myrmidon/src/make/sample.xmk
  4. +1
    -0
      proposal/myrmidon/src/manifest/taskdefs.xml

+ 21
- 0
proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTskDeployer.java View File

@@ -151,6 +151,27 @@ public class DefaultTskDeployer
public void deployDataType( final String name, final String location, final URL url )
throws DeploymentException
{
checkDeployment( location, url );
final ZipFile zipFile = getZipFileFor( url );
final Configuration datatypedefs = loadConfiguration( zipFile, TSKDEF_FILE );
try
{
final Iterator datatypes = datatypedefs.getChildren( "datatype" );
while( datatypes.hasNext() )
{
final Configuration datatype = (Configuration)datatypes.next();
if( datatype.getAttribute( "name" ).equals( name ) )
{
handleDataType( datatype, url );
break;
}
}
}
catch( final ConfigurationException ce )
{
throw new DeploymentException( "Malformed taskdefs.xml", ce );
}
}
public void deployTasklet( final String name, final String location, final URL url )


+ 43
- 0
proposal/myrmidon/src/java/org/apache/ant/tasks/core/RegisterDataType.java View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.ant.tasks.core;

import java.net.URL;
import org.apache.ant.AntException;
import org.apache.avalon.camelot.DefaultLocator;
import org.apache.avalon.camelot.DeploymentException;
import org.apache.avalon.camelot.RegistryException;

/**
* Method to register a single datatype.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
*/
public class RegisterDataType
extends AbstractResourceRegisterer
{
protected void registerResource( final String name,
final String classname,
final URL url )
throws AntException, RegistryException
{
if( null == classname )
{
try { m_engine.getTskDeployer().deployDataType( name, url.toString(), url ); }
catch( final DeploymentException de )
{
throw new AntException( "Failed deploying " + name + " from " + url, de );
}
}
else
{
final DefaultLocator locator = new DefaultLocator( classname, url );
m_engine.getDataTypeEngine().getRegistry().register( name, locator );
}
}
}

+ 10
- 0
proposal/myrmidon/src/make/sample.xmk View File

@@ -84,6 +84,16 @@ Legal:

<echo message="foo=${foo}" />

<register-datatype lib="../../dist/lib/core.tsk"
name="pattern2"
classname="org.apache.ant.datatypes.Pattern" />

<property name="foo2">
<pattern name="*.java"/>
</property>

<echo message="foo2=${foo2}" />

</target>

<target name="property-test2">


+ 1
- 0
proposal/myrmidon/src/manifest/taskdefs.xml View File

@@ -8,6 +8,7 @@
<task name="register-tasklet" classname="org.apache.ant.tasks.core.RegisterTasklet" />
<task name="register-converter" classname="org.apache.ant.tasks.core.RegisterConverter" />
<task name="ant-call" classname="org.apache.ant.tasks.core.AntCall" />
<task name="register-datatype" classname="org.apache.ant.tasks.core.RegisterDataType" />

<datatype name="pattern" classname="org.apache.ant.datatypes.Pattern" />



Loading…
Cancel
Save