* TransformingProjectBuilder
- Performs an XSL transform on all ".xml" build files.
- Identity transform is used for projects with "version" attribute.
- Added xalan.jar to lib - replaced jaxp.jar with xml-apis.jar
* Compatibility Layer
- Described more fully in src/ant1compat/README.txt
- Uses pre-compiled Ant1 jar files for Ant1 code-base.
Insulates from changes in the main tree, and simplifies build.
- "ant." prefix used for all ant1 tasks
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271884 13f79535-47bb-0310-9956-ffa450edef68
master
| @@ -0,0 +1,96 @@ | |||||
| <project name="ant1-compatibility" default="main"> | |||||
| <property name="ant1compat.source" value="src/ant1compat"/> | |||||
| <property name="manifest.dir" value="src/manifest"/> | |||||
| <property name="java.dir" value="src/java"/> | |||||
| <property name="build.dir" value="build/ant1compat"/> | |||||
| <property name="build.lib" value="${build.dir}/lib"/> | |||||
| <property name="build.classes" value="${build.dir}/classes"/> | |||||
| <property name="custom-tasks-dir" value="build/tasks"/> | |||||
| <path id="project.class.path"> | |||||
| <pathelement location="build/classes"/> | |||||
| <fileset dir="lib"> | |||||
| <include name="*.jar"/> | |||||
| </fileset> | |||||
| </path> | |||||
| <taskdef name="antlib-jar" classname="org.apache.myrmidon.build.AntlibJarTask"> | |||||
| <classpath location="${custom-tasks-dir}"/> | |||||
| </taskdef> | |||||
| <target name="main" depends="antlib"/> | |||||
| <target name="clean"> | |||||
| <delete dir="${build.dir}"/> | |||||
| </target> | |||||
| <!-- Builds the Ant1 compatibility layer --> | |||||
| <target name="antlib" | |||||
| description="Builds the Ant1 compatibility layer."> | |||||
| <property name="ant1compat.dir" value="src/ant1compat"/> | |||||
| <property name="ant1.jar" value="${ant1compat.dir}/jar/ant.jar"/> | |||||
| <property name="ant1optional.jar" value="${ant1compat.dir}/jar/optional.jar"/> | |||||
| <property name="ant1.package" value="org/apache/tools"/> | |||||
| <property name="build.ant1classes" value="${build.dir}/ant1classes"/> | |||||
| <mkdir dir="${build.ant1classes}"/> | |||||
| <mkdir dir="${build.classes}"/> | |||||
| <mkdir dir="${build.lib}"/> | |||||
| <unjar src="${ant1.jar}" dest="${build.ant1classes}" overwrite="no"/> | |||||
| <unjar src="${ant1optional.jar}" dest="${build.ant1classes}" overwrite="no"/> | |||||
| <javac destdir="${build.classes}" | |||||
| debug="on" | |||||
| includeAntRuntime="false"> | |||||
| <classpath> | |||||
| <path refid="project.class.path"/> | |||||
| <pathelement location="${build.ant1classes}"/> | |||||
| </classpath> | |||||
| <src location="${ant1compat.dir}"/> | |||||
| <include name="${ant1.package}/**"/> | |||||
| </javac> | |||||
| <patternset id="ant1.omit"> | |||||
| <exclude name="${ant1.package}/ant/Main.class"/> | |||||
| <exclude name="${ant1.package}/ant/Task.class"/> | |||||
| <exclude name="${ant1.package}/ant/taskdefs/Ant.class"/> | |||||
| <exclude name="${ant1.package}/ant/taskdefs/CallTarget.class"/> | |||||
| </patternset> | |||||
| <!-- Create the ant1compat antlib --> | |||||
| <antlib-jar jarfile="${build.lib}/ant1compat.atl" | |||||
| descriptor="${ant1compat.dir}/ant-descriptor.xml" | |||||
| rolesDescriptor="${manifest.dir}/empty-roles.xml" | |||||
| manifest="${ant1compat.dir}/ant1compat.mf"> | |||||
| <fileset dir="${build.ant1classes}"> | |||||
| <include name="${ant1.package}/**"/> | |||||
| <patternset refid="ant1.omit"/> | |||||
| </fileset> | |||||
| <fileset dir="${build.classes}"> | |||||
| <include name="${ant1.package}/**"/> | |||||
| </fileset> | |||||
| </antlib-jar> | |||||
| <copy todir="dist/lib" file="${build.lib}/ant1compat.atl"/> | |||||
| </target> | |||||
| <!-- Runs the supplied build file through the XSL converter --> | |||||
| <target name="ant1convert" | |||||
| description="Converts an Ant1 build file into a Myrmidon build file."> | |||||
| <property name="ant1file" value="build.xml"/> | |||||
| <style | |||||
| style="${java.dir}/org/apache/myrmidon/components/builder/ant1convert.xsl" | |||||
| in="${ant1file}" | |||||
| out="${ant1file}.ant"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -200,7 +200,8 @@ Legal: | |||||
| <classpath location="${custom-tasks-dir}"/> | <classpath location="${custom-tasks-dir}"/> | ||||
| </taskdef> | </taskdef> | ||||
| <taskdef name="antlib-descriptor" classname="org.apache.myrmidon.build.AntlibDescriptorTask"> | |||||
| <taskdef name="antlib-descriptor" | |||||
| classname="org.apache.myrmidon.build.AntlibDescriptorTask"> | |||||
| <classpath> | <classpath> | ||||
| <pathelement location="${custom-tasks-dir}"/> | <pathelement location="${custom-tasks-dir}"/> | ||||
| <path refid="project.class.path"/> | <path refid="project.class.path"/> | ||||
| @@ -0,0 +1,60 @@ | |||||
| Myrmidon Ant1 compatibility layer. | |||||
| This directory contains the source for the Ant1 compatibility layer. | |||||
| DESCRIPTION | |||||
| ----------- | |||||
| The layer works by reusing most of the Ant1 code, with tasks and datatypes | |||||
| being prefixed with "ant1." in build files. Almost all of the main Ant1 tree | |||||
| is included in the compatibility layer antlib. To insulate from changes in | |||||
| the Ant1 tree, Ant1 class files are extracted from a jar, rather than | |||||
| being compiled from scratch. | |||||
| Here's how it works: The first time an Ant1 task is encountered, an Ant1 | |||||
| project is created, and stored in the TaskContext. The Ant1 versions of Task | |||||
| and Project have been extended, with Task implementing Configurable so that | |||||
| it may can mimic the Ant1 configuration policy using the IntrospectionHelper. | |||||
| The idea is to provide hooks between the Ant1 project and the Myrmidon | |||||
| project, eg | |||||
| logging: done | |||||
| properties: done but not quite working | |||||
| references: not done | |||||
| Task definitions: done. | |||||
| So at present, while a <ant1:path> reference works fine in other <ant1:xxx> | |||||
| tasks, it's not visible to the rest of the build, and vice-versa. | |||||
| The <taskdef> task works ok, registering the task with the TypeManager using the | |||||
| "ant1." prefix. Only a couple of DataTypes (Path and Patternset) are working | |||||
| as top-level types, but this should be just a matter of adding references to | |||||
| the Ant1 version of TypeInstanceTask in the descriptor. | |||||
| The TransformingProjectBuilder (which is now the default builder for files | |||||
| of type ".xml", applies a transformation stylesheet to the file, prefixing select | |||||
| tasks (all at present) with "ant.". If a version attribute is encountered, the | |||||
| file is not transformed | |||||
| USAGE INSTRUCTIONS | |||||
| ------------------ | |||||
| Myrmidon will automatically attempt to upgrade any ".xml" build file that | |||||
| doesn't have a version attribute on the root element. So, using an Ant1 build | |||||
| file with Myrmidon should be as simple as: | |||||
| [myrmidon-command] -f ant1-build-file.xml | |||||
| BUILD INSTRUCTIONS | |||||
| ------------------ | |||||
| * It is required that Myrmidon is first build by running the default target | |||||
| in the Myrmidon directory. | |||||
| * Run "ant -f ant1compat.xml" | |||||
| TODO | |||||
| ---- | |||||
| * Convert this to an Xdoc document | |||||
| * Try out automatic registration of tasks - remove everything | |||||
| from ant-descriptor.xml and just use Project.addTaskDefinition() | |||||
| to register tasks? (similar for DataTypes) | |||||
| * Get a version of <ant> and <antcall> working | |||||
| * Test heaps more tasks | |||||
| * Fix problem with classloaders and <taskdef> | |||||
| @@ -0,0 +1,310 @@ | |||||
| <ant-lib version="1.0"> | |||||
| <types> | |||||
| <!-- Type instance tasks --> | |||||
| <task name="ant1.path" | |||||
| classname="org.apache.tools.ant.Ant1CompatTypeInstanceTask" /> | |||||
| <task name="ant1.patternset" | |||||
| classname="org.apache.tools.ant.Ant1CompatTypeInstanceTask" /> | |||||
| <!-- TaskAdapter tasks --> | |||||
| <task name="ant1.condition" | |||||
| classname="org.apache.tools.ant.Ant1CompatTaskAdapter" /> | |||||
| <!-- standard ant tasks --> | |||||
| <task name="ant1.mkdir" | |||||
| classname="org.apache.tools.ant.taskdefs.Mkdir" /> | |||||
| <task name="ant1.javac" | |||||
| classname="org.apache.tools.ant.taskdefs.Javac" /> | |||||
| <task name="ant1.chmod" | |||||
| classname="org.apache.tools.ant.taskdefs.Chmod" /> | |||||
| <task name="ant1.delete" | |||||
| classname="org.apache.tools.ant.taskdefs.Delete" /> | |||||
| <task name="ant1.copy" | |||||
| classname="org.apache.tools.ant.taskdefs.Copy" /> | |||||
| <task name="ant1.move" | |||||
| classname="org.apache.tools.ant.taskdefs.Move" /> | |||||
| <task name="ant1.jar" | |||||
| classname="org.apache.tools.ant.taskdefs.Jar" /> | |||||
| <task name="ant1.rmic" | |||||
| classname="org.apache.tools.ant.taskdefs.Rmic" /> | |||||
| <task name="ant1.cvs" | |||||
| classname="org.apache.tools.ant.taskdefs.Cvs" /> | |||||
| <task name="ant1.get" | |||||
| classname="org.apache.tools.ant.taskdefs.Get" /> | |||||
| <task name="ant1.unzip" | |||||
| classname="org.apache.tools.ant.taskdefs.Expand" /> | |||||
| <task name="ant1.unjar" | |||||
| classname="org.apache.tools.ant.taskdefs.Expand" /> | |||||
| <task name="ant1.unwar" | |||||
| classname="org.apache.tools.ant.taskdefs.Expand" /> | |||||
| <task name="ant1.echo" | |||||
| classname="org.apache.tools.ant.taskdefs.Echo" /> | |||||
| <task name="ant1.javadoc" | |||||
| classname="org.apache.tools.ant.taskdefs.Javadoc" /> | |||||
| <task name="ant1.zip" | |||||
| classname="org.apache.tools.ant.taskdefs.Zip" /> | |||||
| <task name="ant1.gzip" | |||||
| classname="org.apache.tools.ant.taskdefs.GZip" /> | |||||
| <task name="ant1.gunzip" | |||||
| classname="org.apache.tools.ant.taskdefs.GUnzip" /> | |||||
| <task name="ant1.replace" | |||||
| classname="org.apache.tools.ant.taskdefs.Replace" /> | |||||
| <task name="ant1.java" | |||||
| classname="org.apache.tools.ant.taskdefs.Java" /> | |||||
| <task name="ant1.tstamp" | |||||
| classname="org.apache.tools.ant.taskdefs.Tstamp" /> | |||||
| <task name="ant1.property" | |||||
| classname="org.apache.tools.ant.taskdefs.Property" /> | |||||
| <task name="ant1.taskdef" | |||||
| classname="org.apache.tools.ant.taskdefs.Taskdef" /> | |||||
| <task name="ant1.ant" | |||||
| classname="org.apache.tools.ant.taskdefs.Ant" /> | |||||
| <task name="ant1.exec" | |||||
| classname="org.apache.tools.ant.taskdefs.ExecTask" /> | |||||
| <task name="ant1.tar" | |||||
| classname="org.apache.tools.ant.taskdefs.Tar" /> | |||||
| <task name="ant1.untar" | |||||
| classname="org.apache.tools.ant.taskdefs.Untar" /> | |||||
| <task name="ant1.available" | |||||
| classname="org.apache.tools.ant.taskdefs.Available" /> | |||||
| <task name="ant1.filter" | |||||
| classname="org.apache.tools.ant.taskdefs.Filter" /> | |||||
| <task name="ant1.fixcrlf" | |||||
| classname="org.apache.tools.ant.taskdefs.FixCRLF" /> | |||||
| <task name="ant1.patch" | |||||
| classname="org.apache.tools.ant.taskdefs.Patch" /> | |||||
| <task name="ant1.style" | |||||
| classname="org.apache.tools.ant.taskdefs.XSLTProcess" /> | |||||
| <task name="ant1.touch" | |||||
| classname="org.apache.tools.ant.taskdefs.Touch" /> | |||||
| <task name="ant1.signjar" | |||||
| classname="org.apache.tools.ant.taskdefs.SignJar" /> | |||||
| <task name="ant1.genkey" | |||||
| classname="org.apache.tools.ant.taskdefs.GenerateKey" /> | |||||
| <task name="ant1.antstructure" | |||||
| classname="org.apache.tools.ant.taskdefs.AntStructure" /> | |||||
| <task name="ant1.execon" | |||||
| classname="org.apache.tools.ant.taskdefs.ExecuteOn" /> | |||||
| <task name="ant1.antcall" | |||||
| classname="org.apache.tools.ant.taskdefs.CallTarget" /> | |||||
| <task name="ant1.sql" | |||||
| classname="org.apache.tools.ant.taskdefs.SQLExec" /> | |||||
| <task name="ant1.mail" | |||||
| classname="org.apache.tools.ant.taskdefs.email.EmailTask" /> | |||||
| <task name="ant1.fail" | |||||
| classname="org.apache.tools.ant.taskdefs.Exit" /> | |||||
| <task name="ant1.war" | |||||
| classname="org.apache.tools.ant.taskdefs.War" /> | |||||
| <task name="ant1.uptodate" | |||||
| classname="org.apache.tools.ant.taskdefs.UpToDate" /> | |||||
| <task name="ant1.apply" | |||||
| classname="org.apache.tools.ant.taskdefs.Transform" /> | |||||
| <task name="ant1.record" | |||||
| classname="org.apache.tools.ant.taskdefs.Recorder" /> | |||||
| <task name="ant1.cvspass" | |||||
| classname="org.apache.tools.ant.taskdefs.CVSPass" /> | |||||
| <task name="ant1.typedef" | |||||
| classname="org.apache.tools.ant.taskdefs.Typedef" /> | |||||
| <task name="ant1.sleep" | |||||
| classname="org.apache.tools.ant.taskdefs.Sleep" /> | |||||
| <task name="ant1.pathconvert" | |||||
| classname="org.apache.tools.ant.taskdefs.PathConvert" /> | |||||
| <task name="ant1.ear" | |||||
| classname="org.apache.tools.ant.taskdefs.Ear" /> | |||||
| <task name="ant1.parallel" | |||||
| classname="org.apache.tools.ant.taskdefs.Parallel" /> | |||||
| <task name="ant1.sequential" | |||||
| classname="org.apache.tools.ant.taskdefs.Sequential" /> | |||||
| <task name="ant1.dependset" | |||||
| classname="org.apache.tools.ant.taskdefs.DependSet" /> | |||||
| <task name="ant1.bzip2" | |||||
| classname="org.apache.tools.ant.taskdefs.BZip2" /> | |||||
| <task name="ant1.bunzip2" | |||||
| classname="org.apache.tools.ant.taskdefs.BUnzip2" /> | |||||
| <task name="ant1.checksum" | |||||
| classname="org.apache.tools.ant.taskdefs.Checksum" /> | |||||
| <task name="ant1.waitfor" | |||||
| classname="org.apache.tools.ant.taskdefs.WaitFor" /> | |||||
| <task name="ant1.input" | |||||
| classname="org.apache.tools.ant.taskdefs.Input" /> | |||||
| <task name="ant1.loadfile" | |||||
| classname="org.apache.tools.ant.taskdefs.LoadFile" /> | |||||
| <task name="ant1.manifest" | |||||
| classname="org.apache.tools.ant.taskdefs.Manifest" /> | |||||
| <task name="ant1.loadproperties" | |||||
| classname="org.apache.tools.ant.taskdefs.LoadProperties" /> | |||||
| <!-- optional tasks --> | |||||
| <task name="ant1.script" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Script" /> | |||||
| <task name="ant1.netrexxc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.NetRexxC" /> | |||||
| <task name="ant1.renameext" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.RenameExtensions" /> | |||||
| <task name="ant1.ejbc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.Ejbc" /> | |||||
| <task name="ant1.ddcreator" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.DDCreator" /> | |||||
| <task name="ant1.wlrun" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.WLRun" /> | |||||
| <task name="ant1.wlstop" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.WLStop" /> | |||||
| <task name="ant1.vssget" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSGET" /> | |||||
| <task name="ant1.ejbjar" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.EjbJar" /> | |||||
| <task name="ant1.mparse" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.metamata.MParse" /> | |||||
| <task name="ant1.mmetrics" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.metamata.MMetrics" /> | |||||
| <task name="ant1.maudit" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.metamata.MAudit" /> | |||||
| <task name="ant1.junit" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" /> | |||||
| <task name="ant1.cab" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Cab" /> | |||||
| <task name="ant1.ftp" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.net.FTP" /> | |||||
| <task name="ant1.icontract" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.IContract" /> | |||||
| <task name="ant1.javacc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.javacc.JavaCC" /> | |||||
| <task name="ant1.jjtree" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.javacc.JJTree" /> | |||||
| <task name="ant1.stcheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout" /> | |||||
| <task name="ant1.stcheckin" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin" /> | |||||
| <task name="ant1.stlabel" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamLabel" /> | |||||
| <task name="ant1.stlist" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamList" /> | |||||
| <task name="ant1.wljspc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.jsp.WLJspc" /> | |||||
| <task name="ant1.jlink" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.jlink.JlinkTask" /> | |||||
| <task name="ant1.native2ascii" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Native2Ascii" /> | |||||
| <task name="ant1.propertyfile" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.PropertyFile" /> | |||||
| <task name="ant1.depend" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.depend.Depend" /> | |||||
| <task name="ant1.antlr" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ANTLR" /> | |||||
| <task name="ant1.vajload" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ide.VAJLoadProjects" /> | |||||
| <task name="ant1.vajexport" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ide.VAJExport" /> | |||||
| <task name="ant1.vajimport" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ide.VAJImport" /> | |||||
| <task name="ant1.telnet" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.net.TelnetTask" /> | |||||
| <task name="ant1.csc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.dotnet.CSharp" /> | |||||
| <task name="ant1.ilasm" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm" /> | |||||
| <task name="ant1.stylebook" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.StyleBook" /> | |||||
| <task name="ant1.test" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Test" /> | |||||
| <task name="ant1.pvcs" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.pvcs.Pvcs" /> | |||||
| <task name="ant1.p4change" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Change" /> | |||||
| <task name="ant1.p4label" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Label" /> | |||||
| <task name="ant1.p4have" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Have" /> | |||||
| <task name="ant1.p4sync" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Sync" /> | |||||
| <task name="ant1.p4edit" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Edit" /> | |||||
| <task name="ant1.p4submit" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Submit" /> | |||||
| <task name="ant1.p4counter" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Counter" /> | |||||
| <task name="ant1.javah" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Javah" /> | |||||
| <task name="ant1.ccupdate" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCUpdate" /> | |||||
| <task name="ant1.cccheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckout" /> | |||||
| <task name="ant1.cccheckin" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckin" /> | |||||
| <task name="ant1.ccuncheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCUnCheckout" /> | |||||
| <task name="ant1.sound" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sound.SoundTask" /> | |||||
| <task name="ant1.junitreport" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator" /> | |||||
| <task name="ant1.vsslabel" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL" /> | |||||
| <task name="ant1.vsshistory" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSHISTORY" /> | |||||
| <task name="ant1.blgenclient" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient" /> | |||||
| <task name="ant1.rpm" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.Rpm" /> | |||||
| <task name="ant1.xmlvalidate" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.XMLValidateTask" /> | |||||
| <task name="ant1.vsscheckin" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKIN" /> | |||||
| <task name="ant1.vsscheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT" /> | |||||
| <task name="ant1.iplanet-ejbc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask" /> | |||||
| <task name="ant1.jdepend" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask" /> | |||||
| <task name="ant1.mimemail" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.net.MimeMail" /> | |||||
| <task name="ant1.ccmcheckin" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin" /> | |||||
| <task name="ant1.ccmcheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout" /> | |||||
| <task name="ant1.ccmcheckintask" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault" /> | |||||
| <task name="ant1.ccmreconfigure" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure" /> | |||||
| <task name="ant1.ccmcreatetask" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask" /> | |||||
| <task name="ant1.jpcoverage" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sitraka.Coverage" /> | |||||
| <task name="ant1.jpcovmerge" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sitraka.CovMerge" /> | |||||
| <task name="ant1.jpcovreport" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sitraka.CovReport" /> | |||||
| <task name="ant1.p4add" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Add" /> | |||||
| <task name="ant1.jspc" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.jsp.JspC" /> | |||||
| <task name="ant1.replaceregexp" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.ReplaceRegExp" /> | |||||
| <task name="ant1.translate" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.i18n.Translate" /> | |||||
| <task name="ant1.sosget" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sos.SOSGet" /> | |||||
| <task name="ant1.soscheckin" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckin" /> | |||||
| <task name="ant1.soscheckout" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckout" /> | |||||
| <task name="ant1.soslabel" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.sos.SOSLabel" /> | |||||
| <task name="ant1.echoproperties" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.EchoProperties" /> | |||||
| <!-- deprecated ant tasks (kept for back compatibility) --> | |||||
| <task name="ant1.starteam" | |||||
| classname="org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut" /> | |||||
| <task name="ant1.javadoc2" | |||||
| classname="org.apache.tools.ant.taskdefs.Javadoc" /> | |||||
| <task name="ant1.copydir" | |||||
| classname="org.apache.tools.ant.taskdefs.Copydir" /> | |||||
| <task name="ant1.copyfile" | |||||
| classname="org.apache.tools.ant.taskdefs.Copyfile" /> | |||||
| <task name="ant1.deltree" | |||||
| classname="org.apache.tools.ant.taskdefs.Deltree" /> | |||||
| <task name="ant1.rename" | |||||
| classname="org.apache.tools.ant.taskdefs.Rename" /> | |||||
| </types> | |||||
| </ant-lib> | |||||
| @@ -0,0 +1,12 @@ | |||||
| Manifest-Version: 1.0 | |||||
| Created-By: Apache Ant Project | |||||
| Extension-Name: ant1.compat | |||||
| Specification-Title: Myrmidon Ant1 Compatibility Layer | |||||
| Specification-Version: 0.01 | |||||
| Specification-Vendor: Jakarta Apache | |||||
| Implementation-Vendor-Id: org.apache.jakarta | |||||
| Implementation-Vendor: Jakarta Apache Project | |||||
| Implementation-Version: 0.01 | |||||
| Extension-List: tools | |||||
| tools-Extension-Name: com.sun.tools | |||||
| tools-Specification-Version: 1.0 | |||||
| @@ -0,0 +1,342 @@ | |||||
| /* | |||||
| * 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.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.util.Enumeration; | |||||
| import java.util.Properties; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.interfaces.type.DefaultTypeFactory; | |||||
| import org.apache.myrmidon.interfaces.type.TypeManager; | |||||
| /** | |||||
| * Ant1 Project proxy for Myrmidon. Provides hooks between Myrmidon TaskContext | |||||
| * and Ant1 project. | |||||
| * Note that there is no logical separation between Ant1Project and this extension - | |||||
| * they could easily be flattened. Ant1Project is barely modified from the | |||||
| * Ant1 original, this class contains the extensions. | |||||
| * | |||||
| * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class Ant1CompatProject extends Project | |||||
| { | |||||
| private TaskContext m_context; | |||||
| public static final String ANT1_TASK_PREFIX = "ant1."; | |||||
| public Ant1CompatProject( TaskContext context ) | |||||
| { | |||||
| super(); | |||||
| m_context = context; | |||||
| setBaseDir( m_context.getBaseDirectory() ); | |||||
| } | |||||
| /** | |||||
| * Writes a project level message to the log with the given log level. | |||||
| * @param msg The text to log. Should not be <code>null</code>. | |||||
| * @param msgLevel The priority level to log at. | |||||
| */ | |||||
| public void log( String msg, int msgLevel ) | |||||
| { | |||||
| doLog( msg, msgLevel ); | |||||
| super.log( msg, msgLevel ); | |||||
| } | |||||
| /** | |||||
| * Writes a task level message to the log with the given log level. | |||||
| * @param task The task to use in the log. Must not be <code>null</code>. | |||||
| * @param msg The text to log. Should not be <code>null</code>. | |||||
| * @param msgLevel The priority level to log at. | |||||
| */ | |||||
| public void log( Task task, String msg, int msgLevel ) | |||||
| { | |||||
| doLog( msg, msgLevel ); | |||||
| super.log( task, msg, msgLevel ); | |||||
| } | |||||
| /** | |||||
| * Writes a target level message to the log with the given log level. | |||||
| * @param target The target to use in the log. | |||||
| * Must not be <code>null</code>. | |||||
| * @param msg The text to log. Should not be <code>null</code>. | |||||
| * @param msgLevel The priority level to log at. | |||||
| */ | |||||
| public void log( Target target, String msg, int msgLevel ) | |||||
| { | |||||
| doLog( msg, msgLevel ); | |||||
| super.log( target, msg, msgLevel ); | |||||
| } | |||||
| private void doLog( String msg, int msgLevel ) | |||||
| { | |||||
| switch( msgLevel ) | |||||
| { | |||||
| case Ant1CompatProject.MSG_ERR: | |||||
| m_context.error( msg ); | |||||
| break; | |||||
| case Ant1CompatProject.MSG_WARN: | |||||
| m_context.warn( msg ); | |||||
| break; | |||||
| case Ant1CompatProject.MSG_INFO: | |||||
| m_context.info( msg ); | |||||
| break; | |||||
| case Ant1CompatProject.MSG_VERBOSE: | |||||
| case Ant1CompatProject.MSG_DEBUG: | |||||
| m_context.debug( msg ); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * This is a copy of init() from the Ant1 Project, which adds Ant1 tasks and | |||||
| * DataTypes to the underlying Ant1 Project, but calling add methods on the | |||||
| * superclass to avoid adding everything to the TypeManager. | |||||
| * | |||||
| * @exception BuildException if the default task list cannot be loaded | |||||
| */ | |||||
| public void init() throws BuildException | |||||
| { | |||||
| setJavaVersionProperty(); | |||||
| String defs = "/org/apache/tools/ant/taskdefs/defaults.properties"; | |||||
| try | |||||
| { | |||||
| Properties props = new Properties(); | |||||
| InputStream in = this.getClass().getResourceAsStream( defs ); | |||||
| if( in == null ) | |||||
| { | |||||
| throw new BuildException( "Can't load default task list" ); | |||||
| } | |||||
| props.load( in ); | |||||
| in.close(); | |||||
| Enumeration enum = props.propertyNames(); | |||||
| while( enum.hasMoreElements() ) | |||||
| { | |||||
| String key = (String)enum.nextElement(); | |||||
| String value = props.getProperty( key ); | |||||
| try | |||||
| { | |||||
| Class taskClass = Class.forName( value ); | |||||
| // NOTE: Line modified from Ant1 Project. | |||||
| super.addTaskDefinition( key, taskClass ); | |||||
| } | |||||
| catch( NoClassDefFoundError ncdfe ) | |||||
| { | |||||
| log( "Could not load a dependent class (" | |||||
| + ncdfe.getMessage() + ") for task " + key, MSG_DEBUG ); | |||||
| } | |||||
| catch( ClassNotFoundException cnfe ) | |||||
| { | |||||
| log( "Could not load class (" + value | |||||
| + ") for task " + key, MSG_DEBUG ); | |||||
| } | |||||
| } | |||||
| } | |||||
| catch( IOException ioe ) | |||||
| { | |||||
| throw new BuildException( "Can't load default task list" ); | |||||
| } | |||||
| String dataDefs = "/org/apache/tools/ant/types/defaults.properties"; | |||||
| try | |||||
| { | |||||
| Properties props = new Properties(); | |||||
| InputStream in = this.getClass().getResourceAsStream( dataDefs ); | |||||
| if( in == null ) | |||||
| { | |||||
| throw new BuildException( "Can't load default datatype list" ); | |||||
| } | |||||
| props.load( in ); | |||||
| in.close(); | |||||
| Enumeration enum = props.propertyNames(); | |||||
| while( enum.hasMoreElements() ) | |||||
| { | |||||
| String key = (String)enum.nextElement(); | |||||
| String value = props.getProperty( key ); | |||||
| try | |||||
| { | |||||
| Class dataClass = Class.forName( value ); | |||||
| // NOTE: Line modified from Ant1 Project. | |||||
| super.addDataTypeDefinition( key, dataClass ); | |||||
| } | |||||
| catch( NoClassDefFoundError ncdfe ) | |||||
| { | |||||
| // ignore... | |||||
| } | |||||
| catch( ClassNotFoundException cnfe ) | |||||
| { | |||||
| // ignore... | |||||
| } | |||||
| } | |||||
| } | |||||
| catch( IOException ioe ) | |||||
| { | |||||
| throw new BuildException( "Can't load default datatype list" ); | |||||
| } | |||||
| setSystemProperties(); | |||||
| } | |||||
| /** | |||||
| * Adds a new task definition to the project, registering it with the | |||||
| * TypeManager, as well as the underlying Ant1 Project. | |||||
| * | |||||
| * @param taskName The name of the task to add. | |||||
| * Must not be <code>null</code>. | |||||
| * @param taskClass The full name of the class implementing the task. | |||||
| * Must not be <code>null</code>. | |||||
| * | |||||
| * @exception BuildException if the class is unsuitable for being an Ant | |||||
| * task. An error level message is logged before | |||||
| * this exception is thrown. | |||||
| * | |||||
| * @see #checkTaskClass(Class) | |||||
| */ | |||||
| public void addTaskDefinition( String taskName, Class taskClass ) | |||||
| throws BuildException | |||||
| { | |||||
| String ant2name = ANT1_TASK_PREFIX + taskName; | |||||
| try | |||||
| { | |||||
| registerType( org.apache.myrmidon.api.Task.ROLE, ant2name, taskClass ); | |||||
| } | |||||
| catch( Exception e ) | |||||
| { | |||||
| throw new BuildException( e ); | |||||
| } | |||||
| super.addTaskDefinition( taskName, taskClass ); | |||||
| } | |||||
| /** | |||||
| * Utility method to register a type. | |||||
| */ | |||||
| protected void registerType( final String roleType, | |||||
| final String typeName, | |||||
| final Class type ) | |||||
| throws Exception | |||||
| { | |||||
| final ClassLoader loader = type.getClassLoader(); | |||||
| final DefaultTypeFactory factory = new DefaultTypeFactory( loader ); | |||||
| factory.addNameClassMapping( typeName, type.getName() ); | |||||
| TypeManager typeManager = (TypeManager)m_context.getService( TypeManager.class ); | |||||
| typeManager.registerType( roleType, typeName, factory ); | |||||
| } | |||||
| // /** | |||||
| // * Sets a property. Any existing property of the same name | |||||
| // * is overwritten, unless it is a user property. | |||||
| // * @param name The name of property to set. | |||||
| // * Must not be <code>null</code>. | |||||
| // * @param value The new value of the property. | |||||
| // * Must not be <code>null</code>. | |||||
| // */ | |||||
| // public void setProperty( String name, String value ) | |||||
| // { | |||||
| // if( null != getProperty( name ) ) | |||||
| // { | |||||
| // log( "Overriding previous definition of property " + name, | |||||
| // MSG_VERBOSE ); | |||||
| // } | |||||
| // | |||||
| // doSetProperty( name, value ); | |||||
| // } | |||||
| // | |||||
| // /** | |||||
| // * Sets a property if no value currently exists. If the property | |||||
| // * exists already, a message is logged and the method returns with | |||||
| // * no other effect. | |||||
| // * | |||||
| // * @param name The name of property to set. | |||||
| // * Must not be <code>null</code>. | |||||
| // * @param value The new value of the property. | |||||
| // * Must not be <code>null</code>. | |||||
| // * @since 1.5 | |||||
| // */ | |||||
| // public void setNewProperty( String name, String value ) | |||||
| // { | |||||
| // if( null != getProperty( name ) ) | |||||
| // { | |||||
| // log( "Override ignored for property " + name, MSG_VERBOSE ); | |||||
| // return; | |||||
| // } | |||||
| // log( "Setting project property: " + name + " -> " + | |||||
| // value, MSG_DEBUG ); | |||||
| // doSetProperty( name, value ); | |||||
| // } | |||||
| // | |||||
| // private void doSetProperty( String name, String value ) | |||||
| // { | |||||
| // try | |||||
| // { | |||||
| // m_context.setProperty( name, value ); | |||||
| // } | |||||
| // catch( TaskException e ) | |||||
| // { | |||||
| // throw new BuildException( e ); | |||||
| // } | |||||
| // } | |||||
| // | |||||
| // /** | |||||
| // * Returns the value of a property, if it is set. | |||||
| // * | |||||
| // * @param name The name of the property. | |||||
| // * May be <code>null</code>, in which case | |||||
| // * the return value is also <code>null</code>. | |||||
| // * @return the property value, or <code>null</code> for no match | |||||
| // * or if a <code>null</code> name is provided. | |||||
| // */ | |||||
| // public String getProperty( String name ) | |||||
| // { | |||||
| // if( name == null ) | |||||
| // { | |||||
| // return null; | |||||
| // } | |||||
| // Object value = m_context.getProperty( name ); | |||||
| // if( value == null ) | |||||
| // { | |||||
| // return null; | |||||
| // } | |||||
| // return String.valueOf( value ); | |||||
| // } | |||||
| // | |||||
| // /** | |||||
| // * Returns a copy of the properties table. | |||||
| // * @return a hashtable containing all properties | |||||
| // * (including user properties). | |||||
| // */ | |||||
| // public Hashtable getProperties() | |||||
| // { | |||||
| // Map properties = m_context.getProperties(); | |||||
| // Hashtable propertiesCopy = new Hashtable(); | |||||
| // | |||||
| // Iterator iterator = properties.keySet().iterator(); | |||||
| // while( iterator.hasNext() ) | |||||
| // { | |||||
| // String key = (String)iterator.next(); | |||||
| // String value = (String)properties.get( key ); | |||||
| // | |||||
| // propertiesCopy.put( key, value ); | |||||
| // | |||||
| // } | |||||
| // | |||||
| // return propertiesCopy; | |||||
| // } | |||||
| } | |||||
| @@ -0,0 +1,49 @@ | |||||
| /* | |||||
| * 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.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | |||||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
| /** | |||||
| * An adapter for running (in Myrmidon) Ant1 tasks which do not extend Task | |||||
| * | |||||
| * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class Ant1CompatTaskAdapter | |||||
| extends TaskAdapter | |||||
| { | |||||
| public void configure( Configuration configuration ) throws ConfigurationException | |||||
| { | |||||
| // Create a new instance of the proxy object, | |||||
| // and configure it. | |||||
| String taskName = getAnt1Name( configuration.getName() ); | |||||
| Class taskClass = (Class)project.getTaskDefinitions().get( taskName ); | |||||
| if( taskClass == null ) | |||||
| { | |||||
| throw new ConfigurationException( "Invalid task name for TaskAdapter: " + taskName ); | |||||
| } | |||||
| Object adaptedTask = null; | |||||
| try | |||||
| { | |||||
| adaptedTask = taskClass.newInstance(); | |||||
| } | |||||
| catch( Exception e ) | |||||
| { | |||||
| throw new ConfigurationException( "Could not instantiate adapted task: " + taskClass.getName() ); | |||||
| } | |||||
| configure( adaptedTask, configuration ); | |||||
| setProxy( adaptedTask ); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| /* | |||||
| * 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.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | |||||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
| /** | |||||
| * A task for instantiating Ant1 datatypes. | |||||
| * | |||||
| * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class Ant1CompatTypeInstanceTask | |||||
| extends Task | |||||
| { | |||||
| public void configure( Configuration configuration ) throws ConfigurationException | |||||
| { | |||||
| if( configuration.getAttribute( "id", null ) == null ) | |||||
| { | |||||
| final String message = "id is required."; | |||||
| throw new ConfigurationException( message ); | |||||
| } | |||||
| String typeName = configuration.getName(); | |||||
| Object datatype = project.createDataType( getAnt1Name( typeName ) ); | |||||
| // Configure the datatype. The type is added to the project | |||||
| // as a reference during configuration. | |||||
| configure( datatype, configuration ); | |||||
| } | |||||
| /** | |||||
| * Execute task. Don't do anything. | |||||
| */ | |||||
| public void execute() | |||||
| { | |||||
| // Everything is done during configuration. | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,374 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant; | |||||
| /** | |||||
| * Base class for all tasks. | |||||
| * | |||||
| * Use Project.createTask to create a new task instance rather than | |||||
| * using this class directly for construction. | |||||
| * | |||||
| * @see Project#createTask | |||||
| */ | |||||
| public abstract class OriginalAnt1Task extends ProjectComponent { | |||||
| /** Target this task belongs to, if any. */ | |||||
| protected Target target = null; | |||||
| /** Description of this task, if any. */ | |||||
| protected String description = null; | |||||
| /** Location within the build file of this task definition. */ | |||||
| protected Location location = Location.UNKNOWN_LOCATION; | |||||
| /** | |||||
| * Name of this task to be used for logging purposes. | |||||
| * This defaults to the same as the type, but may be | |||||
| * overridden by the user. For instance, the name "java" | |||||
| * isn't terribly descriptive for a task used within | |||||
| * another task - the outer task code can probably | |||||
| * provide a better one. | |||||
| */ | |||||
| protected String taskName = null; | |||||
| /** Type of this task. */ | |||||
| protected String taskType = null; | |||||
| /** Wrapper for this object, used to configure it at runtime. */ | |||||
| protected RuntimeConfigurable wrapper; | |||||
| /** | |||||
| * Whether or not this task is invalid. A task becomes invalid | |||||
| * if a conflicting class is specified as the implementation for | |||||
| * its type. | |||||
| */ | |||||
| private boolean invalid = false; | |||||
| /** Sole constructor. */ | |||||
| public OriginalAnt1Task() { | |||||
| } | |||||
| /** | |||||
| * Sets the target container of this task. | |||||
| * | |||||
| * @param target Target in whose scope this task belongs. | |||||
| * May be <code>null</code>, indicating a top-level task. | |||||
| */ | |||||
| public void setOwningTarget(Target target) { | |||||
| this.target = target; | |||||
| } | |||||
| /** | |||||
| * Returns the container target of this task. | |||||
| * | |||||
| * @return The target containing this task, or <code>null</code> if | |||||
| * this task is a top-level task. | |||||
| */ | |||||
| public Target getOwningTarget() { | |||||
| return target; | |||||
| } | |||||
| /** | |||||
| * Sets the name to use in logging messages. | |||||
| * | |||||
| * @param name The name to use in logging messages. | |||||
| * Should not be <code>null</code>. | |||||
| */ | |||||
| public void setTaskName(String name) { | |||||
| this.taskName = name; | |||||
| } | |||||
| /** | |||||
| * Returns the name to use in logging messages. | |||||
| * | |||||
| * @return the name to use in logging messages. | |||||
| */ | |||||
| public String getTaskName() { | |||||
| return taskName; | |||||
| } | |||||
| /** | |||||
| * Sets the name with which the task has been invoked. | |||||
| * | |||||
| * @param type The name the task has been invoked as. | |||||
| * Should not be <code>null</code>. | |||||
| */ | |||||
| void setTaskType(String type) { | |||||
| this.taskType = type; | |||||
| } | |||||
| /** | |||||
| * Sets a description of the current action. This may be used for logging | |||||
| * purposes. | |||||
| * | |||||
| * @param desc Description of the current action. | |||||
| * May be <code>null</code>, indicating that no description is | |||||
| * available. | |||||
| * | |||||
| */ | |||||
| public void setDescription( String desc ) { | |||||
| description = desc; | |||||
| } | |||||
| /** | |||||
| * Returns the description of the current action. | |||||
| * | |||||
| * @return the description of the current action, or <code>null</code> if | |||||
| * no description is available. | |||||
| */ | |||||
| public String getDescription() { | |||||
| return description; | |||||
| } | |||||
| /** | |||||
| * Called by the project to let the task initialize properly. | |||||
| * The default implementation is a no-op. | |||||
| * | |||||
| * @exception BuildException if someting goes wrong with the build | |||||
| */ | |||||
| public void init() throws BuildException {} | |||||
| /** | |||||
| * Called by the project to let the task do its work. This method may be | |||||
| * called more than once, if the task is invoked more than once. | |||||
| * For example, | |||||
| * if target1 and target2 both depend on target3, then running | |||||
| * "ant target1 target2" will run all tasks in target3 twice. | |||||
| * | |||||
| * @exception BuildException if something goes wrong with the build | |||||
| */ | |||||
| public void execute() throws BuildException {} | |||||
| /** | |||||
| * Returns the file/location where this task was defined. | |||||
| * | |||||
| * @return the file/location where this task was defined. | |||||
| * Should not return <code>null</code>. Location.UNKNOWN_LOCATION | |||||
| * is used for unknown locations. | |||||
| * | |||||
| * @see Location#UNKNOWN_LOCATION | |||||
| */ | |||||
| public Location getLocation() { | |||||
| return location; | |||||
| } | |||||
| /** | |||||
| * Sets the file/location where this task was defined. | |||||
| * | |||||
| * @param location The file/location where this task was defined. | |||||
| * Should not be <code>null</code> - use | |||||
| * Location.UNKNOWN_LOCATION if the location isn't known. | |||||
| * | |||||
| * @see Location#UNKNOWN_LOCATION | |||||
| */ | |||||
| public void setLocation(Location location) { | |||||
| this.location = location; | |||||
| } | |||||
| /** | |||||
| * Returns the wrapper used for runtime configuration. | |||||
| * | |||||
| * @return the wrapper used for runtime configuration. This | |||||
| * method will generate a new wrapper (and cache it) | |||||
| * if one isn't set already. | |||||
| */ | |||||
| public RuntimeConfigurable getRuntimeConfigurableWrapper() { | |||||
| if (wrapper == null) { | |||||
| wrapper = new RuntimeConfigurable(this, getTaskName()); | |||||
| } | |||||
| return wrapper; | |||||
| } | |||||
| /** | |||||
| * Sets the wrapper to be used for runtime configuration. | |||||
| * | |||||
| * @param wrapper The wrapper to be used for runtime configuration. | |||||
| * May be <code>null</code>, in which case the next call | |||||
| * to getRuntimeConfigurableWrapper will generate a new | |||||
| * wrapper. | |||||
| */ | |||||
| protected void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper) { | |||||
| this.wrapper = wrapper; | |||||
| } | |||||
| // XXX: (Jon Skeet) The comment "if it hasn't been done already" may | |||||
| // not be strictly true. wrapper.maybeConfigure() won't configure the same | |||||
| // attributes/text more than once, but it may well add the children again, | |||||
| // unless I've missed something. | |||||
| /** | |||||
| * Configures this task - if it hasn't been done already. | |||||
| * If the task has been invalidated, it is replaced with an | |||||
| * UnknownElement task which uses the new definition in the project. | |||||
| * | |||||
| * @exception BuildException if the task cannot be configured. | |||||
| */ | |||||
| public void maybeConfigure() throws BuildException { | |||||
| if (!invalid) { | |||||
| if (wrapper != null) { | |||||
| wrapper.maybeConfigure(project); | |||||
| } | |||||
| } else { | |||||
| getReplacement(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Handles a line of output by logging it with the INFO priority. | |||||
| * | |||||
| * @param line The line of output to log. Should not be <code>null</code>. | |||||
| */ | |||||
| protected void handleOutput(String line) { | |||||
| log(line, Project.MSG_INFO); | |||||
| } | |||||
| /** | |||||
| * Handles an error line by logging it with the INFO priority. | |||||
| * | |||||
| * @param line The error line to log. Should not be <code>null</code>. | |||||
| */ | |||||
| protected void handleErrorOutput(String line) { | |||||
| log(line, Project.MSG_ERR); | |||||
| } | |||||
| /** | |||||
| * Logs a message with the default (INFO) priority. | |||||
| * | |||||
| * @param msg The message to be logged. Should not be <code>null</code>. | |||||
| */ | |||||
| public void log(String msg) { | |||||
| log(msg, Project.MSG_INFO); | |||||
| } | |||||
| /** | |||||
| * Logs a mesage with the given priority. This delegates | |||||
| * the actual logging to the project. | |||||
| * | |||||
| * @param msg The message to be logged. Should not be <code>null</code>. | |||||
| * @param msgLevel The message priority at which this message is to | |||||
| * be logged. | |||||
| */ | |||||
| public void log(String msg, int msgLevel) { | |||||
| project.log(getThis(), msg, msgLevel); | |||||
| } | |||||
| /** | |||||
| * Performs this task if it's still valid, or gets a replacement | |||||
| * version and performs that otherwise. | |||||
| * | |||||
| * Performing a task consists of firing a task started event, | |||||
| * configuring the task, executing it, and then firing task finished | |||||
| * event. If a runtime exception is thrown, the task finished event | |||||
| * is still fired, but with the exception as the cause. | |||||
| */ | |||||
| public final void perform() { | |||||
| if (!invalid) { | |||||
| try { | |||||
| project.fireTaskStarted(getThis()); | |||||
| maybeConfigure(); | |||||
| execute(); | |||||
| project.fireTaskFinished(getThis(), null); | |||||
| } | |||||
| catch (RuntimeException exc) { | |||||
| if (exc instanceof BuildException) { | |||||
| BuildException be = (BuildException) exc; | |||||
| if (be.getLocation() == Location.UNKNOWN_LOCATION) { | |||||
| be.setLocation(getLocation()); | |||||
| } | |||||
| } | |||||
| project.fireTaskFinished(getThis(), exc); | |||||
| throw exc; | |||||
| } | |||||
| } else { | |||||
| UnknownElement ue = getReplacement(); | |||||
| Task task = ue.getTask(); | |||||
| task.perform(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Marks this task as invalid. Any further use of this task | |||||
| * will go through a replacement with the updated definition. | |||||
| */ | |||||
| final void markInvalid() { | |||||
| invalid = true; | |||||
| } | |||||
| /** | |||||
| * Replacement element used if this task is invalidated. | |||||
| */ | |||||
| private UnknownElement replacement; | |||||
| /** | |||||
| * Creates an UnknownElement that can be used to replace this task. | |||||
| * Once this has been created once, it is cached and returned by | |||||
| * future calls. | |||||
| * | |||||
| * @return the UnknownElement instance for the new definition of this task. | |||||
| */ | |||||
| private UnknownElement getReplacement() { | |||||
| if (replacement == null) { | |||||
| replacement = new UnknownElement(taskType); | |||||
| replacement.setProject(project); | |||||
| replacement.setTaskType(taskType); | |||||
| replacement.setTaskName(taskName); | |||||
| replacement.setLocation(location); | |||||
| replacement.setOwningTarget(target); | |||||
| replacement.setRuntimeConfigurableWrapper(wrapper); | |||||
| wrapper.setProxy(replacement); | |||||
| target.replaceChild(getThis(), replacement); | |||||
| replacement.maybeConfigure(); | |||||
| } | |||||
| return replacement; | |||||
| } | |||||
| private Task getThis() | |||||
| { | |||||
| return (Task) this; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,148 @@ | |||||
| /* | |||||
| * 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.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant; | |||||
| import java.util.Locale; | |||||
| import org.apache.avalon.framework.configuration.Configurable; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | |||||
| import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
| import org.apache.myrmidon.api.TaskContext; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | |||||
| * Ant1 Task proxy for Myrmidon. | |||||
| * Note that this class and OriginalAnt1Task (superclass) comprise a single logical | |||||
| * class, but the code is kept separate for ease of development. OriginalAnt1Task | |||||
| * is barely modified from the Ant1 original, whereas this class contains | |||||
| * all of the Myrmidon-specific adaptations. | |||||
| * | |||||
| * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a> | |||||
| * @version $Revision$ $Date$ | |||||
| */ | |||||
| public class Task extends OriginalAnt1Task | |||||
| implements org.apache.myrmidon.api.Task, Configurable | |||||
| { | |||||
| private TaskContext m_context; | |||||
| /** | |||||
| * Specify the context in which the task operates in. | |||||
| * The Task will use the TaskContext to receive information | |||||
| * about it's environment. | |||||
| */ | |||||
| public void contextualize( TaskContext context ) | |||||
| throws TaskException | |||||
| { | |||||
| m_context = context; | |||||
| this.setTaskType( context.getName() ); | |||||
| this.setTaskName( context.getName() ); | |||||
| Project project = (Project)context.getProperty( "ant1.project" ); | |||||
| if( project == null ) | |||||
| { | |||||
| project = createProject(); | |||||
| m_context.setProperty( "ant1.project", project ); | |||||
| } | |||||
| this.setProject( project ); | |||||
| } | |||||
| private Project createProject() | |||||
| throws TaskException | |||||
| { | |||||
| Project project = new Ant1CompatProject( m_context ); | |||||
| project.init(); | |||||
| return project; | |||||
| } | |||||
| public void configure( Configuration configuration ) throws ConfigurationException | |||||
| { | |||||
| configure( this, configuration ); | |||||
| } | |||||
| protected void configure( Object target, Configuration configuration ) throws ConfigurationException | |||||
| { | |||||
| IntrospectionHelper helper = IntrospectionHelper.getHelper( target.getClass() ); | |||||
| // Configure the id. | |||||
| String id = configuration.getAttribute( "id", null ); | |||||
| if( id != null ) | |||||
| { | |||||
| project.addReference( id, target ); | |||||
| } | |||||
| // Configure the attributes. | |||||
| final String[] attribs = configuration.getAttributeNames(); | |||||
| for( int i = 0; i < attribs.length; i++ ) | |||||
| { | |||||
| final String name = attribs[ i ]; | |||||
| final String value = | |||||
| project.replaceProperties( configuration.getAttribute( name ) ); | |||||
| try | |||||
| { | |||||
| helper.setAttribute( project, target, | |||||
| name.toLowerCase( Locale.US ), value ); | |||||
| } | |||||
| catch( BuildException be ) | |||||
| { | |||||
| // id attribute must be set externally | |||||
| if( !name.equals( "id" ) ) | |||||
| { | |||||
| throw be; | |||||
| } | |||||
| } | |||||
| } | |||||
| // Configure the text content. | |||||
| String text = configuration.getValue( null ); | |||||
| if( text != null ) | |||||
| { | |||||
| helper.addText( project, target, text ); | |||||
| } | |||||
| // Configure the nested elements | |||||
| Configuration[] nestedConfigs = configuration.getChildren(); | |||||
| for( int i = 0; i < nestedConfigs.length; i++ ) | |||||
| { | |||||
| Configuration nestedConfig = nestedConfigs[ i ]; | |||||
| String name = nestedConfig.getName(); | |||||
| Object nestedElement = helper.createElement( project, target, name ); | |||||
| configure( nestedElement, nestedConfig ); | |||||
| helper.storeElement( project, target, nestedElement, name ); | |||||
| } | |||||
| /* | |||||
| task.setLocation(new Location(helperImpl.buildFile.toString(), helperImpl.locator.getLineNumber(), | |||||
| helperImpl.locator.getColumnNumber())); | |||||
| String id = attr.getValue("id"); | |||||
| if (id != null) { | |||||
| project.addReference(id, target); | |||||
| } | |||||
| // Top level tasks don't have associated targets | |||||
| if (target != null) { | |||||
| task.setOwningTarget(target); | |||||
| container.addTask(task); | |||||
| task.init(); | |||||
| wrapper = task.getRuntimeConfigurableWrapper(); | |||||
| wrapper.setAttributes(attrs); | |||||
| if (parentWrapper != null) { | |||||
| parentWrapper.addChild(wrapper); | |||||
| } | |||||
| } else { | |||||
| task.init(); | |||||
| configure(task, attrs, helperImpl.project); | |||||
| } | |||||
| */ | |||||
| } | |||||
| protected String getAnt1Name( String fullName ) | |||||
| { | |||||
| return fullName.substring( Ant1CompatProject.ANT1_TASK_PREFIX.length() ); | |||||
| } | |||||
| } | |||||
| @@ -36,7 +36,6 @@ import org.xml.sax.XMLReader; | |||||
| * @author <a href="mailto:peter@apache.org">Peter Donald</a> | * @author <a href="mailto:peter@apache.org">Peter Donald</a> | ||||
| * @version $Revision$ $Date$ | * @version $Revision$ $Date$ | ||||
| * | * | ||||
| * @ant:type type="project-builder" name="xml" | |||||
| * @ant:type type="project-builder" name="ant" | * @ant:type type="project-builder" name="ant" | ||||
| */ | */ | ||||
| public class DefaultProjectBuilder | public class DefaultProjectBuilder | ||||
| @@ -105,7 +104,7 @@ public class DefaultProjectBuilder | |||||
| /** | /** | ||||
| * Parses the project. | * Parses the project. | ||||
| */ | */ | ||||
| private Configuration parseProject( final String systemID ) | |||||
| protected Configuration parseProject( final String systemID ) | |||||
| throws ProjectException | throws ProjectException | ||||
| { | { | ||||
| try | try | ||||
| @@ -30,5 +30,8 @@ ant.version-missing.error=Project has no version attribute. | |||||
| ant.bad-version.error=Incompatible build file version detected. Expected version {0} but found version {1}. | ant.bad-version.error=Incompatible build file version detected. Expected version {0} but found version {1}. | ||||
| ant.no-project-file.error=Project file does not exist, or is not a file. | ant.no-project-file.error=Project file does not exist, or is not a file. | ||||
| ant.project-convert.notice=Applying compatibility stylesheet to project file. | |||||
| ant.project-convert.error=Error converting build file. | |||||
| duplicate-project.error=Can not have two projects referenced in a file with the name {0}. | duplicate-project.error=Can not have two projects referenced in a file with the name {0}. | ||||
| duplicate-target.error=Can not have two targets in a file with the name {0}. | duplicate-target.error=Can not have two targets in a file with the name {0}. | ||||
| @@ -0,0 +1,90 @@ | |||||
| /* | |||||
| * 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.txt file. | |||||
| */ | |||||
| package org.apache.myrmidon.components.builder; | |||||
| import java.io.InputStream; | |||||
| import javax.xml.transform.Result; | |||||
| import javax.xml.transform.Source; | |||||
| import javax.xml.transform.Transformer; | |||||
| import javax.xml.transform.TransformerConfigurationException; | |||||
| import javax.xml.transform.TransformerFactory; | |||||
| import javax.xml.transform.sax.SAXResult; | |||||
| import javax.xml.transform.stream.StreamSource; | |||||
| import org.apache.avalon.excalibur.i18n.ResourceManager; | |||||
| import org.apache.avalon.excalibur.i18n.Resources; | |||||
| import org.apache.avalon.framework.configuration.Configuration; | |||||
| import org.apache.avalon.framework.configuration.SAXConfigurationHandler; | |||||
| import org.apache.myrmidon.interfaces.builder.ProjectException; | |||||
| /** | |||||
| * A Project Builder which performs an XSL transformation on a project. | |||||
| * | |||||
| * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a> | |||||
| * @version $Revision$ $Date$ | |||||
| * | |||||
| * @ant:type type="project-builder" name="xml" | |||||
| */ | |||||
| public class TransformingProjectBuilder | |||||
| extends DefaultProjectBuilder | |||||
| { | |||||
| private final static Resources REZ = | |||||
| ResourceManager.getPackageResources( TransformingProjectBuilder.class ); | |||||
| private final static String STYLESHEET = "ant1convert.xsl"; | |||||
| private Transformer m_transformer; | |||||
| protected Configuration parseProject( String systemID ) | |||||
| throws ProjectException | |||||
| { | |||||
| if( getLogger().isDebugEnabled() ) | |||||
| { | |||||
| final String message = REZ.getString( "ant.project-convert.notice" ); | |||||
| getLogger().debug( message ); | |||||
| } | |||||
| try | |||||
| { | |||||
| // Create a XSLT source for the build file. | |||||
| Source source = new StreamSource( systemID ); | |||||
| // Create a configuration handler for the output. | |||||
| final SAXConfigurationHandler handler = new SAXConfigurationHandler(); | |||||
| Result result = new SAXResult( handler ); | |||||
| // Perform the transformation. | |||||
| getTransformer().transform( source, result ); | |||||
| return handler.getConfiguration(); | |||||
| } | |||||
| catch( Exception e ) | |||||
| { | |||||
| throw new ProjectException( REZ.getString( "ant.project-convert.error" ), | |||||
| e ); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Lazy load a Transformer with the conversion stylesheet. | |||||
| * @return the initialised Transformer | |||||
| * @throws TransformerConfigurationException | |||||
| */ | |||||
| private Transformer getTransformer() | |||||
| throws TransformerConfigurationException | |||||
| { | |||||
| // Lazy loading of stylesheet source. | |||||
| if( m_transformer == null ) | |||||
| { | |||||
| InputStream stylesheet = | |||||
| this.getClass().getResourceAsStream( STYLESHEET ); | |||||
| StreamSource stylesheetSource = new StreamSource( stylesheet ); | |||||
| TransformerFactory xformFactory = TransformerFactory.newInstance(); | |||||
| m_transformer = xformFactory.newTransformer( stylesheetSource ); | |||||
| } | |||||
| return m_transformer; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,115 @@ | |||||
| <?xml version="1.0"?> | |||||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |||||
| <xsl:output method="xml" indent="yes"/> | |||||
| <xsl:template match="/project"> | |||||
| <xsl:comment>Converted Project file.</xsl:comment> | |||||
| <xsl:copy> | |||||
| <xsl:attribute name="version">2.0</xsl:attribute> | |||||
| <xsl:apply-templates select="@*[name() != 'version']" mode="copy"/> | |||||
| <xsl:apply-templates/> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- For projects with a version attribute, simply copy the entire tree. --> | |||||
| <!-- TODO check for version >= 2.0.0 --> | |||||
| <xsl:template match="/project[@version]"> | |||||
| <xsl:comment>Copied Project file.</xsl:comment> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*"/> | |||||
| <xsl:apply-templates mode="copy"/> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Handle simple target nodes --> | |||||
| <xsl:template match="/project/target"> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*"/> | |||||
| <xsl:apply-templates/> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Handle target nodes with 'if' --> | |||||
| <xsl:template match="/project/target[@if]"> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*[name() != 'if']"/> | |||||
| <!-- Put in the condition --> | |||||
| <xsl:element name="if"> | |||||
| <xsl:attribute name="test"><xsl:value-of select="@if"/></xsl:attribute> | |||||
| <xsl:apply-templates/> | |||||
| </xsl:element> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Handle target nodes with 'unless' --> | |||||
| <xsl:template match="/project/target[@unless]"> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*[name() != 'unless']"/> | |||||
| <!-- Put in the condition --> | |||||
| <xsl:element name="if"> | |||||
| <xsl:attribute name="not-test"> | |||||
| <xsl:value-of select="@unless"/> | |||||
| </xsl:attribute> | |||||
| <xsl:apply-templates/> | |||||
| </xsl:element> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Handle target nodes with 'if' and 'unless' --> | |||||
| <xsl:template match="/project/target[@if and @unless]"> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*[name()!='if' and name()!='unless']"/> | |||||
| <!-- Put in the 'if' condition --> | |||||
| <xsl:element name="if"> | |||||
| <xsl:attribute name="test"><xsl:value-of select="@if"/></xsl:attribute> | |||||
| <!-- Put in the 'unless' condition --> | |||||
| <xsl:element name="if"> | |||||
| <xsl:attribute name="not-test"><xsl:value-of select="@unless"/></xsl:attribute> | |||||
| <xsl:apply-templates/> | |||||
| </xsl:element> | |||||
| </xsl:element> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Handle task nodes --> | |||||
| <xsl:template match="*"> | |||||
| <xsl:element name="ant1.{name()}"> | |||||
| <xsl:apply-templates select="@*"/> | |||||
| <xsl:apply-templates mode="copy"/> | |||||
| </xsl:element> | |||||
| </xsl:template> | |||||
| <!-- Copy all elements in copy-mode --> | |||||
| <xsl:template match="*" mode="copy"> | |||||
| <xsl:copy> | |||||
| <xsl:apply-templates select="@*"/> | |||||
| <xsl:apply-templates mode="copy"/> | |||||
| </xsl:copy> | |||||
| </xsl:template> | |||||
| <!-- Always copy attributes --> | |||||
| <xsl:template match="@*"> | |||||
| <xsl:copy/> | |||||
| </xsl:template> | |||||
| <xsl:template match="@*" mode="copy"> | |||||
| <xsl:copy/> | |||||
| </xsl:template> | |||||
| <!-- Always copy comments --> | |||||
| <xsl:template match="comment()"> | |||||
| <xsl:copy/> | |||||
| </xsl:template> | |||||
| <xsl:template match="comment()" mode="copy"> | |||||
| <xsl:copy/> | |||||
| </xsl:template> | |||||
| </xsl:stylesheet> | |||||