git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268343 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -151,6 +151,27 @@ public class DefaultTskDeployer | |||||
| public void deployDataType( final String name, final String location, final URL url ) | public void deployDataType( final String name, final String location, final URL url ) | ||||
| throws DeploymentException | 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 ) | public void deployTasklet( final String name, final String location, final URL url ) | ||||
| @@ -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 ); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -84,6 +84,16 @@ Legal: | |||||
| <echo message="foo=${foo}" /> | <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> | ||||
| <target name="property-test2"> | <target name="property-test2"> | ||||
| @@ -8,6 +8,7 @@ | |||||
| <task name="register-tasklet" classname="org.apache.ant.tasks.core.RegisterTasklet" /> | <task name="register-tasklet" classname="org.apache.ant.tasks.core.RegisterTasklet" /> | ||||
| <task name="register-converter" classname="org.apache.ant.tasks.core.RegisterConverter" /> | <task name="register-converter" classname="org.apache.ant.tasks.core.RegisterConverter" /> | ||||
| <task name="ant-call" classname="org.apache.ant.tasks.core.AntCall" /> | <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" /> | <datatype name="pattern" classname="org.apache.ant.datatypes.Pattern" /> | ||||