Browse Source

Wow - look at all the things you can do in a single commit. No need to

commit each directory separately. :-)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273087 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 23 years ago
parent
commit
70936fadd1
100 changed files with 0 additions and 20888 deletions
  1. +0
    -30
      proposal/mutant/bootstrap.bat
  2. +0
    -29
      proposal/mutant/bootstrap.sh
  3. +0
    -5
      proposal/mutant/build.bat
  4. +0
    -6
      proposal/mutant/build.sh
  5. +0
    -285
      proposal/mutant/build.xml
  6. +0
    -799
      proposal/mutant/build/ant1compat.xml
  7. +0
    -9
      proposal/mutant/build/bootstrap.xml
  8. +0
    -198
      proposal/mutant/build/bootstrap.xsl
  9. +0
    -49
      proposal/mutant/build/docs.xml
  10. +0
    -51
      proposal/mutant/build/script.xml
  11. +0
    -657
      proposal/mutant/docs/desc.html
  12. +0
    -82
      proposal/mutant/docs/design.html
  13. +0
    -82
      proposal/mutant/docs/developers.html
  14. +0
    -1112
      proposal/mutant/docs/features.html
  15. +0
    -867
      proposal/mutant/docs/goals.html
  16. +0
    -180
      proposal/mutant/docs/index.html
  17. +0
    -121
      proposal/mutant/docs/intro.html
  18. +0
    -1
      proposal/mutant/lib/ant1compat/readme.txt
  19. +0
    -1
      proposal/mutant/lib/antlib/script/readme.txt
  20. BIN
      proposal/mutant/lib/parser/xercesImpl.jar
  21. BIN
      proposal/mutant/lib/parser/xml-apis.jar
  22. +0
    -49
      proposal/mutant/src/conf/ant.policy
  23. +0
    -115
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibDefinition.java
  24. +0
    -134
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibException.java
  25. +0
    -195
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibHandler.java
  26. +0
    -418
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java
  27. +0
    -301
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java
  28. +0
    -334
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrarySpec.java
  29. +0
    -109
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/ClassNameHandler.java
  30. +0
    -106
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/ComponentLibrary.java
  31. +0
    -144
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DefinitionHandler.java
  32. +0
    -166
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DynamicLibrary.java
  33. +0
    -222
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java
  34. +0
    -169
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfigHandler.java
  35. +0
    -176
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/AttributeSetter.java
  36. +0
    -257
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/BuildEventSupport.java
  37. +0
    -171
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ClassIntrospector.java
  38. +0
    -1048
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
  39. +0
    -66
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Constants.java
  40. +0
    -525
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreDataService.java
  41. +0
    -99
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreEventService.java
  42. +0
    -311
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java
  43. +0
    -97
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java
  44. +0
    -87
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreInputService.java
  45. +0
    -190
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/DeferredSetter.java
  46. +0
    -182
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionContext.java
  47. +0
    -136
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionException.java
  48. +0
    -1085
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
  49. +0
    -128
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java
  50. +0
    -486
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Reflector.java
  51. +0
    -166
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Setter.java
  52. +0
    -122
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/TaskAdapter.java
  53. +0
    -129
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/frontend/FrontendException.java
  54. +0
    -137
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/frontend/FrontendUtils.java
  55. +0
    -146
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/BuildElementHandler.java
  56. +0
    -139
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/IncludeHandler.java
  57. +0
    -103
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ModelElementHandler.java
  58. +0
    -65
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/NoProjectReadException.java
  59. +0
    -202
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ProjectHandler.java
  60. +0
    -164
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/TargetHandler.java
  61. +0
    -94
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/XMLProjectParser.java
  62. +0
    -411
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ElementHandler.java
  63. +0
    -183
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ParseContext.java
  64. +0
    -154
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/RootHandler.java
  65. +0
    -130
      proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/XMLParseException.java
  66. +0
    -194
      proposal/mutant/src/java/antlibs/ant1compat/antlib.xml
  67. +0
    -129
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1CompatException.java
  68. +0
    -136
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Converter.java
  69. +0
    -212
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java
  70. +0
    -95
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1InputHandler.java
  71. +0
    -1525
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
  72. +0
    -146
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/ProjectComponent.java
  73. +0
    -150
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/ProjectHelper.java
  74. +0
    -191
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/RuntimeConfigurable.java
  75. +0
    -106
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Target.java
  76. +0
    -322
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java
  77. +0
    -71
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/TaskContainer.java
  78. +0
    -71
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/input/InputRequest.java
  79. +0
    -215
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java
  80. +0
    -165
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java
  81. +0
    -240
      proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/types/DataType.java
  82. +0
    -4
      proposal/mutant/src/java/antlibs/monitor/antlib.xml
  83. +0
    -135
      proposal/mutant/src/java/antlibs/monitor/org/apache/ant/antlib/monitor/MonitorAspect.java
  84. +0
    -112
      proposal/mutant/src/java/antlibs/monitor/org/apache/ant/antlib/monitor/MonitorRecord.java
  85. +0
    -6
      proposal/mutant/src/java/antlibs/script/antlib.xml
  86. +0
    -191
      proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java
  87. +0
    -128
      proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptDef.java
  88. +0
    -129
      proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptException.java
  89. +0
    -205
      proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptFactory.java
  90. +0
    -21
      proposal/mutant/src/java/antlibs/system/antlib.xml
  91. +0
    -171
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
  92. +0
    -204
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntAspect.java
  93. +0
    -94
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntAspectContext.java
  94. +0
    -201
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntBase.java
  95. +0
    -90
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntCall.java
  96. +0
    -101
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/FileConverter.java
  97. +0
    -159
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Import.java
  98. +0
    -177
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LibPath.java
  99. +0
    -172
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LoadLib.java
  100. +0
    -205
      proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Parallel.java

+ 0
- 30
proposal/mutant/bootstrap.bat View File

@@ -1,30 +0,0 @@
@echo off
REM Copyright (c) 2000-2001 The Apache Software Foundation. All rights
REM reserved.

REM cleanup curretn boot area
if exist bin rmdir /s/q bin
if exist bootstrap rmdir /s/q bootstrap
if exist dist rmdir /s/q dist

REM compile init jar
mkdir bin\init
javac -d bin\init src\java\init\org\apache\ant\init\*.java

REM compile bootstrap classes
mkdir bin\bootstrap
javac -classpath bin\init -d bin\bootstrap src\java\bootstrap\org\apache\ant\bootstrap\*.java

REM compiler builder classes
mkdir bin\builder
javac -classpath bin\init;bin\bootstrap -d bin\builder src\java\bootstrap\org\apache\ant\builder\*.java

REM run bootstrap
java -classpath bin\init;bin\bootstrap org.apache.ant.bootstrap.Bootstrap

REM run full build using bootstrapped version
java -jar bootstrap\lib\start.jar %*

REM Use the full build as the build used by the build script
xcopy /s /y dist bootstrap


+ 0
- 29
proposal/mutant/bootstrap.sh View File

@@ -1,29 +0,0 @@
#!/bin/sh

# Copyright (c) 2000-2001 The Apache Software Foundation. All rights
# reserved.

# cleanup curretn boot area
rm -rf bin bootstrap dist

# compile init jar
mkdir -p bin/init
javac -d bin/init src/java/init/org/apache/ant/init/*.java

# compile bootstrap classes
mkdir bin/bootstrap
javac -classpath bin/init -d bin/bootstrap src/java/bootstrap/org/apache/ant/bootstrap/*.java

# compiler builder classes
mkdir bin/builder
javac -classpath bin/init:bin/bootstrap -d bin/builder src/java/bootstrap/org/apache/ant/builder/*.java

# run bootstrap
java -classpath bin/init:bin/bootstrap org.apache.ant.bootstrap.Bootstrap

# run full build using bootstrapped version
java -jar bootstrap/lib/core/start/start.jar $*

# Use the full build as the build used by the build script
cp -r dist/lib bootstrap


+ 0
- 5
proposal/mutant/build.bat View File

@@ -1,5 +0,0 @@
@echo off
REM Copyright (c) 2002 The Apache Software Foundation. All rights
REM reserved.

java -jar bootstrap\lib\start.jar %*

+ 0
- 6
proposal/mutant/build.sh View File

@@ -1,6 +0,0 @@
#!/bin/sh

# Copyright (c) 2002 The Apache Software Foundation. All rights
# reserved.

java -jar bootstrap/lib/core/start/start.jar $@

+ 0
- 285
proposal/mutant/build.xml View File

@@ -1,285 +0,0 @@
<project default="dist-lite" name="Mutant">

<!-- source locations -->
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="java.dir" value="${src.dir}/java"/>
<property name="script.dir" value="${src.dir}/script"/>
<property name="conf.dir" value="${src.dir}/conf"/>

<!-- build and distribution locations -->
<property name="bin.dir" value="bin"/>
<property name="dist.dir" value="dist"/>
<property name="dist.bin" value="${dist.dir}/bin"/>
<property name="dist.conf" value="${dist.dir}/conf"/>
<property name="javadocs.dir" value="${dist.dir}/docs/manual/api"/>
<property name="dist.lib.dir" value="${dist.dir}/lib"/>
<property name="dist.core.dir" value="${dist.lib.dir}/core"/>
<property name="dist.frontend.dir" value="${dist.lib.dir}/frontend"/>
<property name="dist.antlibs.dir" value="${dist.lib.dir}/antlibs"/>
<property name="dist.syslibs.dir" value="${dist.core.dir}/syslibs"/>

<!-- control flags -->
<property name="debug" value="true"/>
<property name="chmod.fail" value="true" />

<path id="classpath.parser">
<fileset dir="${lib.dir}/parser" includes="*.jar"/>
</path>

<path id="classpath.common">
<pathelement location="${dist.core.dir}/start/init.jar"/>
</path>

<path id="classpath.antcore">
<path refid="classpath.common"/>
<pathelement location="${dist.core.dir}/common/common.jar"/>
<path refid="classpath.parser"/>
</path>

<path id="classpath.frontend">
<path refid="classpath.antcore"/>
<pathelement location="${dist.core.dir}/antcore/antcore.jar"/>
</path>

<path id="classpath.start">
<pathelement location="${dist.core.dir}/start/init.jar"/>
</path>

<target name="buildsetup">
<available classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"
property="checkstyle.available"/>
<mkdir dir="${bin.dir}"/>
<mkdir dir="${dist.core.dir}"/>
<copy todir="${dist.core.dir}/parser">
<fileset dir="${lib.dir}/parser"/>
</copy>
</target>

<target name="initjar" depends="buildsetup">
<mkdir dir="${bin.dir}/init"/>
<mkdir dir="${dist.core.dir}/start"/>
<depend destdir="${bin.dir}/init" srcdir="${java.dir}/init" closure="yes"/>
<javac destdir="${bin.dir}/init" srcdir="${java.dir}/init" debug="${debug}"/>
<jar basedir="${bin.dir}/init" jarfile="${dist.core.dir}/start/init.jar"/>
</target>

<target name="common" depends="initjar">
<mkdir dir="${bin.dir}/common"/>
<mkdir dir="${dist.core.dir}/common"/>
<depend destdir="${bin.dir}/common" srcdir="${java.dir}/common" closure="yes">
<classpath refid="classpath.common"/>
</depend>
<javac destdir="${bin.dir}/common" srcdir="${java.dir}/common" debug="${debug}">
<classpath refid="classpath.common"/>
</javac>
<jar basedir="${bin.dir}/common" jarfile="${dist.core.dir}/common/common.jar"/>
</target>

<target name="antcore" depends="common">
<mkdir dir="${bin.dir}/antcore"/>
<mkdir dir="${dist.core.dir}/antcore"/>
<depend destdir="${bin.dir}/antcore" srcdir="${java.dir}/antcore" closure="yes">
<classpath refid="classpath.antcore"/>
</depend>
<javac destdir="${bin.dir}/antcore" srcdir="${java.dir}/antcore" debug="${debug}">
<classpath refid="classpath.antcore"/>
</javac>
<jar basedir="${bin.dir}/antcore" jarfile="${dist.core.dir}/antcore/antcore.jar"/>
</target>

<target name="frontend" depends="antcore, startjar">
<mkdir dir="${bin.dir}/frontend"/>
<mkdir dir="${dist.frontend.dir}"/>
<depend destdir="${bin.dir}/frontend" srcdir="${java.dir}/frontend" closure="yes">
<classpath refid="classpath.frontend"/>
</depend>
<javac destdir="${bin.dir}/frontend" srcdir="${java.dir}/frontend" debug="${debug}">
<classpath refid="classpath.frontend"/>
</javac>
<jar basedir="${bin.dir}/frontend" jarfile="${dist.frontend.dir}/cli.jar">
<include name="**/cli/*.class"/>
<manifest>
<attribute name="Main-Class" value="org.apache.ant.cli.Commandline"/>
</manifest>
</jar>
</target>

<target name="startjar" depends="initjar">
<mkdir dir="${bin.dir}/start"/>
<mkdir dir="${dist.core.dir}/start"/>
<depend destdir="${bin.dir}/start" srcdir="${java.dir}/start" closure="yes">
<classpath refid="classpath.start"/>
</depend>
<javac destdir="${bin.dir}/start" srcdir="${java.dir}/start" debug="${debug}">
<classpath refid="classpath.start"/>
</javac>
<jar basedir="${bin.dir}/start" jarfile="${dist.core.dir}/start/start.jar">
<manifest>
<attribute name="Main-Class" value="org.apache.ant.start.Main"/>
<attribute name="Class-Path" value="init.jar"/>
</manifest>
<include name="org/apache/ant/**/*"/>
</jar>
<jar basedir="${bin.dir}/start" jarfile="${dist.core.dir}/start/ant.jar">
<manifest>
<attribute name="Main-Class" value="org.apache.tools.ant.Main"/>
<attribute name="Class-Path" value="start.jar"/>
</manifest>
<include name="org/apache/tools/ant/**/*"/>
</jar>
</target>

<!--
<target name="remote" depends="initjar">
<mkdir dir="${bin.dir}/remote"/>
<depend destdir="${bin.dir}/remote" srcdir="${java.dir}/remote" closure="yes">
<classpath refid="classpath.start"/>
</depend>
<javac destdir="${bin.dir}/remote" srcdir="${java.dir}/remote" debug="${debug}">
<classpath refid="classpath.start"/>
</javac>
<jar basedir="${bin.dir}/remote" jarfile="${distlib.dir}/remote.jar">
<manifest>
<attribute name="Main-Class" value="org.apache.ant.remote.RemoteMain"/>
</manifest>
</jar>
</target>
-->

<target name="antlibs" depends="common">
<!-- <ant antfile="build/script.xml"/> -->
<antcall target="buildlib">
<param name="libname" value="system"/>
<param name="antlibdir" value="${dist.syslibs.dir}"/>
</antcall>
<antcall target="buildlib">
<param name="libname" value="monitor"/>
<param name="antlibdir" value="${dist.syslibs.dir}"/>
</antcall>
<ant antfile="build/ant1compat.xml"/>
</target>

<target name="buildlib">
<property name="antlib.build.dir" value="${bin.dir}/antlibs/${libname}"/>
<property name="antlib.src.dir" value="${java.dir}/antlibs/${libname}"/>
<mkdir dir="${antlib.build.dir}"/>
<mkdir dir="${antlibdir}"/>
<path id="classpath.antlibs">
<path refid="classpath.common"/>
<pathelement location="${dist.core.dir}/common/common.jar"/>
</path>
<depend destdir="${antlib.build.dir}" srcdir="${antlib.src.dir}" closure="yes">
<classpath refid="classpath.antlibs"/>
</depend>
<javac destdir="${antlib.build.dir}" srcdir="${antlib.src.dir}" debug="${debug}">
<classpath refid="classpath.antlibs"/>
</javac>
<jar basedir="${antlib.build.dir}" jarfile="${antlibdir}/${libname}.jar">
<metainf dir="${antlib.src.dir}"
includes="antlib.xml"/>
</jar>
</target>


<target name="setup-bin">
<mkdir dir="${dist.bin}"/>
<copy todir="${dist.bin}">
<fileset dir="${script.dir}/" />
</copy>

<fixcrlf srcdir="${dist.bin}" eol="crlf" includes="*.bat" />
<fixcrlf srcdir="${dist.bin}" eol="lf">
<include name="mutant" />
<include name="antRun" />
<include name="*.pl" />
</fixcrlf>

<chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
failonerror="${chmod.fail}" />
<chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
failonerror="${chmod.fail}" />
<chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
<fileset dir="${dist.bin}">
<include name="**/mutant" />
<include name="**/antRun" />
<include name="**/*.pl" />
<include name="**/*.py" />
</fileset>
</chmod>

</target>

<target name="setup-conf">
<mkdir dir="${dist.conf}"/>
<copy todir="${dist.conf}">
<fileset dir="${conf.dir}/" />
</copy>
</target>


<target name="clean">
<delete dir="${bin.dir}"/>
<delete dir="${dist.dir}"/>
</target>

<target name="checkstyle" depends="buildsetup" if="checkstyle.available">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
<mkdir dir="${bin.dir}/check"/>
<checkstyle headerFile="../../src/etc/RequiredHeader.txt"
headerIgnoreLine="4">
<fileset dir="${java.dir}">
<include name="**/*.java"/>
<exclude name="**/org/apache/tools/ant/Task.java"/>
<exclude name="**/org/apache/tools/ant/ProjectComponent.java"/>
<exclude name="**/org/apache/tools/ant/types/DataType.java"/>
<exclude name="**/builder/MutantBuilder.java"/>
<exclude name="**/builder/Ant1CompatBuilder.java"/>
</fileset>
</checkstyle>
<checkstyle allowProtected="true"
headerFile="../../src/etc/RequiredHeader.txt"
headerIgnoreLine="4">
<fileset dir="${java.dir}">
<include name="**/org/apache/tools/ant/Task.java"/>
<include name="**/org/apache/tools/ant/ProjectComponent.java"/>
<include name="**/org/apache/tools/ant/types/DataType.java"/>
</fileset>
</checkstyle>
</target>

<target name="javadocs">
<mkdir dir="${javadocs.dir}"/>
<javadoc packagenames="org.apache.*"
useexternalfile="yes"
sourcepath="${java.dir}/antcore:${java.dir}/init:${java.dir}/common:${java.dir}/frontend:${java.dir}/start"
destdir="${javadocs.dir}"
author="true"
private ="true"
version="true"
windowtitle="Mutant API"
doctitle="Mutant">
<group title="Ant Library" packages="org.apache.ant.common.antlib*" />
<group title="Services" packages="org.apache.ant.common.service*" />
<group title="Common Facilities" packages="org.apache.ant.common*" />
<group title="Core" packages="org.apache.ant.antcore*" />
<group title="Initialisation" packages="org.apache.ant.init*,org.apache.ant.start*" />
<group title="Command Line" packages="org.apache.ant.cli*" />
<group title="Ant1 Compatability Layer" packages="org.apache.tools.ant*" />
<tag name="created" description="Date Created:" scope="types"/>
</javadoc>
</target>


<target name="test">
<ant antfile="build/ant1compat.xml" target="test"/>
</target>

<target name="jars" depends="initjar, startjar, antcore, frontend, antlibs"/>

<target name="dist-lite" depends="jars, setup-bin, setup-conf"/>

<target name="dist" depends="dist-lite, javadocs"/>

</project>

+ 0
- 799
proposal/mutant/build/ant1compat.xml View File

@@ -1,799 +0,0 @@
<project default="ant1compat" name="Ant1Compat" basedir="..">

<property name="debug" value="true" />
<property name="deprecation" value="false" />
<property name="optimize" value="true" />

<property name="junit.fork" value="false" />
<property name="junit.filtertrace" value="off"/>
<property name="junit.summary" value="no"/>

<property name="ant1base.dir" value="../.."/>
<property name="ant1src.dir" value="${ant1base.dir}/src"/>
<property name="ant1java.dir" value="${ant1src.dir}/main"/>
<property name="ant1etc.dir" value="${ant1src.dir}/etc"/>
<property name="ant1.tests.dir" value="${ant1src.dir}/etc/testcases"/>

<property name="src.dir" value="src"/>
<property name="java.dir" value="${src.dir}/java"/>
<property name="lib.dir" value="lib"/>
<property name="tests.dir" value="${ant1src.dir}/testcases"/>
<property name="tests.etc.dir" value="${src.dir}/etc/testcases"/>

<property name="bin.dir" value="bin"/>
<property name="dist.dir" value="dist"/>
<property name="dist.lib.dir" value="${dist.dir}/lib"/>
<property name="dist.core.dir" value="${dist.lib.dir}/core"/>
<property name="dist.antlibs.dir" value="${dist.lib.dir}/antlibs"/>
<property name="dist.syslibs.dir" value="${dist.core.dir}/syslibs"/>

<property name="ant.package" value="org/apache/tools/ant"/>
<property name="optional.package" value="${ant.package}/taskdefs/optional"/>
<property name="optional.type.package" value="${ant.package}/types/optional"/>
<property name="util.package" value="${ant.package}/util"/>
<property name="regexp.package" value="${util.package}/regexp"/>

<!--
===================================================================
Set the properties for the build area
===================================================================
-->
<property name="build.tests" value="${bin.dir}/testcases"/>


<path id="classpath">
<pathelement location="${dist.core.dir}/start/init.jar"/>
<fileset dir="${dist.core.dir}/parser" includes="*.jar"/>
<!-- <fileset dir="${lib.dir}/ant1compat" includes="*.jar"/> -->
<pathelement location="${dist.core.dir}/common/common.jar"/>
<pathelement location="${dist.syslibs.dir}/system.jar"/>
</path>

<path id="tests-classpath">
<pathelement location="${build.classes}" />
<pathelement location="${build.tests}" />
<!--
include the test source and test data dirs
so that we can pick resources via getResource(AsStream)
-->
<pathelement location="${tests.dir}"/>
<pathelement location="${tests.etc.dir}"/>
<path refid="classpath" />
</path>

<patternset id="deprecated">
<exclude name="org/apache/tools/ant/taskdefs/Copydir.java"/>
<exclude name="org/apache/tools/ant/taskdefs/Copyfile.java"/>
</patternset>

<patternset id="toohard">
</patternset>

<patternset id="converted">
<exclude name="org/apache/tools/ant/taskdefs/Ant.java"/>
<exclude name="org/apache/tools/ant/taskdefs/CallTarget.java"/>
<exclude name="org/apache/tools/ant/taskdefs/input/InputRequest.java"/>
<exclude name="org/apache/tools/ant/types/DataType.java"/>
<exclude name="org/apache/tools/ant/Project.java"/>
<exclude name="org/apache/tools/ant/Target.java"/>
<exclude name="org/apache/tools/ant/TaskContainer.java"/>
<exclude name="org/apache/tools/ant/ProjectComponent.java"/>
<exclude name="org/apache/tools/ant/ProjectHelper.java"/>
<exclude name="org/apache/tools/ant/Task.java"/>
<exclude name="org/apache/tools/ant/Main.java"/>
<exclude name="org/apache/tools/ant/input/InputRequest.java"/>
</patternset>

<patternset id="notrequired">
<exclude name="org/apache/tools/ant/DemuxOutputStream.java"/>
<exclude name="org/apache/tools/ant/RuntimeConfigurable.java"/>
<exclude name="org/apache/tools/ant/UnknownElement.java"/>
</patternset>

<patternset id="unsupportedTests">
<exclude name="org/apache/tools/ant/taskdefs/ParallelTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/AntTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/InitializeClassTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/InputTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/JavaTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/JavacTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/TStampTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/TaskdefTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/TypedefTest.java"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/sitraka/XMLReportTest.java"/>
</patternset>

<fileset id="ant1src_tocopy" dir="${ant1java.dir}">
<include name="**/*.properties"/>
<include name="**/*.mf"/>
<include name="org/apache/tools/ant/taskdefs/**/*.java"/>
<include name="org/apache/tools/ant/types/**/*.java"/>
<include name="org/apache/tools/ant/filters/**/*.java"/>
<include name="org/apache/tools/ant/util/**/*.java"/>
<include name="org/apache/tools/zip/**/*.java"/>
<include name="org/apache/tools/bzip2/**/*.java"/>
<include name="org/apache/tools/mail/**/*.java"/>
<include name="org/apache/tools/tar/**/*.java"/>
<include name="org/apache/tools/ant/*.java"/>
<include name="org/apache/tools/ant/input/*.java"/>
<!-- <patternset refid="deprecated"/> -->
<patternset refid="toohard"/>
<patternset refid="converted"/>
<patternset refid="notrequired"/>
</fileset>

<fileset id="ant1testcases_tocopy" dir="${ant1.tests.dir}">
</fileset>

<!--
===================================================================
Set up patternsets to be used by javac and junit to exclude
files that have dependencies that are not available
===================================================================
-->
<!-- depends on JDK version -->
<patternset id="needs.jdk1.2+">
<exclude name="${util.package}/optional/NoExitSecurityManager.java"
unless="jdk1.2+" />
<exclude name="${optional.package}/Javah.java"
unless="jdk1.2+" />
<exclude name="${optional.package}/metamata/*.java"
unless="jdk1.2+" />
<exclude name="${optional.package}/ejb/EjbJar.java"
unless="jdk1.2+" />
<exclude name="${optional.package}/ejb/*DeploymentTool.java"
unless="jdk1.2+" />
<exclude name="${optional.package}/ejb/IPlanet*.java"
unless="jdk1.2+" />
<!-- uses the context classloader -->
<exclude name="${optional.package}/junit/JUnitClassLoaderTest.java"
unless="jdk1.2+" />
<!-- use various 1.2 methods -->
<exclude name="${optional.package}/sitraka/**/*.java"
unless="jdk1.2+" />
</patternset>
<patternset id="needs.jdk1.3+">
<exclude name="${ant.package}/taskdefs/TestProcess.java"
unless="jdk1.3+" />
<exclude name="${optional.package}/extension/**/*.java"
unless="jdk1.3+" />
</patternset>
<patternset id="needs.jdk1.4+">
<exclude name="${regexp.package}/Jdk14Regexp*.java"
unless="jdk1.4+" />
</patternset>

<!-- classes that should be present in Sun based JVMs, but not in
Kaffe for example -->
<patternset id="needs.sun.tools">
<exclude name="${optional.package}/Native2Ascii.java"
unless="sun.tools.present" />
<exclude name="${optional.package}/Javah.java"
unless="sun.tools.present" />
</patternset>
<patternset id="needs.sun.uue">
<exclude name="${ant.package}/taskdefs/email/UUMailer.java"
unless="sunuue.present" />
</patternset>
<patternset id="needs.sun.b64">
<exclude name="${ant.package}/taskdefs/Get.java"
unless="base64.present" />
<exclude name="${optional.package}/splash/SplashTask.java"
unless="base64.present" />
</patternset>

<!-- depends on external libraries -->
<patternset id="needs.trax">
<exclude name="${optional.package}/TraXLiaison*.java"
unless="trax.present" />
<exclude name="${optional.package}/sitraka/**"
unless="trax.present"/>
<exclude name="${optional.package}/metamata/MMetrics*"
unless="trax.present"/>
<exclude name="${optional.package}/XsltTest.java"
unless="trax.present"/>
</patternset>
<patternset id="needs.xalan1">
<exclude name="${optional.package}/XalanLiaison*.java"
unless="xalan.present" />
<exclude name="${optional.package}/junit/Xalan1Executor.java"
unless="xalan.present" />
</patternset>
<patternset id="needs.xalan2">
<exclude name="${optional.package}/junit/Xalan2Executor.java"
unless="xalan2.present" />
</patternset>
<patternset id="needs.xslp">
<exclude name="${optional.package}/XslpLiaison*.java"
unless="xslp.present" />
</patternset>
<patternset id="needs.junit">
<exclude name="${optional.package}/junit/*.java" unless="junit.present" />
</patternset>
<patternset id="needs.jakarta.regexp">
<exclude name="${regexp.package}/JakartaRegexp*.java"
unless="jakarta.regexp.present" />
</patternset>
<patternset id="needs.jakarta.oro">
<exclude name="${regexp.package}/JakartaOro*.java"
unless="jakarta.oro.present" />
<exclude name="${optional.package}/perforce/*.java"
unless="jakarta.oro.present" />
<exclude name="${optional.package}/metamata/MAudit*.java"
unless="jakarta.oro.present"/>
</patternset>
<patternset id="needs.jakarta.bcel">
<exclude name="${ant.package}/filters/util/JavaClassHelper.java"
unless="bcel.present" />
<exclude name="${util.package}/depend/bcel/*.java"
unless="bcel.present" />
<exclude name="${optional.type.package}/depend/ClassFileSetTest.java"
unless="bcel.present" />
</patternset>
<patternset id="needs.jakarta.log4j">
<exclude name="${ant.package}/listener/Log4jListener.java"
unless="log4j.present" />
</patternset>
<patternset id="needs.commons.logging">
<exclude name="${ant.package}/listener/CommonsLoggingListener.java"
unless="commons.logging.present" />
</patternset>
<patternset id="needs.bsf">
<exclude name="${optional.package}/Script.java"
unless="bsf.present" />
</patternset>
<patternset id="needs.stylebook">
<exclude name="${optional.package}/StyleBook.java"
unless="stylebook.present" />
</patternset>
<patternset id="needs.javamail">
<exclude name="${ant.package}/taskdefs/email/MimeMailer.java"
unless="javamail.complete" />
</patternset>
<patternset id="needs.icontract">
<exclude name="${optional.package}/IContract.java"
unless="icontract.present" />
</patternset>
<patternset id="needs.netrexx">
<exclude name="${optional.package}/NetRexxC.java"
unless="netrexx.present" />
</patternset>
<patternset id="needs.weblogic.ejbc">
<exclude name="${optional.package}/ejb/Ejbc*.java"
unless="ejb.ejbc.present" />
</patternset>
<patternset id="needs.weblogic.ddcreator">
<exclude name="${optional.package}/ejb/DDCreator*.java"
unless="ejb.DDCreator.present" />
</patternset>
<patternset id="needs.weblogic.server">
<exclude name="${optional.package}/ejb/WLRun.java"
unless="ejb.wls.present" />
<exclude name="${optional.package}/ejb/WLStop.java"
unless="ejb.wls.present" />
</patternset>
<patternset id="needs.netcomponents">
<exclude name="${optional.package}/net/FTP.java"
unless="netcomp.present" />
<exclude name="${optional.package}/net/TelnetTask.java"
unless="netcomp.present" />
</patternset>
<patternset id="needs.starteam">
<exclude name="${optional.package}/scm/AntStarTeam*.java"
unless="starteam.present" />
<exclude name="${optional.package}/starteam/*.java"
unless="starteam.present" />
</patternset>
<patternset id="needs.vaj">
<exclude name="${optional.package}/ide/VAJ*.java"
unless="vaj.present" />
</patternset>
<patternset id="needs.antlr">
<exclude name="${optional.package}/ANTLR*.java" unless="antlr.present" />
</patternset>
<patternset id="needs.servletapi">
<exclude name="${optional.package}/ide/VAJ*Servlet.java"
unless="servlet.present" />
</patternset>
<patternset id="needs.jmf">
<exclude name="${optional.package}/sound/*.java" unless="jmf.present" />
</patternset>
<patternset id="needs.jdepend">
<exclude name="${optional.package}/jdepend/*" unless="jdepend.present" />
</patternset>
<patternset id="onlinetests">
<exclude name="**/GetTest.java" if="offline" />
</patternset>
<patternset id="needs.swing">
<exclude name="${optional.package}/splash/*.java" unless="swing.present" />
</patternset>
<patternset id="teststhatfail">
</patternset>

<!--
===================================================================
Check to see what optional dependencies are available
===================================================================
-->
<target name="check_for_optional_packages">
<available property="jdk1.2+" classname="java.lang.ThreadLocal" />
<available property="jdk1.3+" classname="java.lang.StrictMath" />
<available property="jdk1.4+" classname="java.lang.CharSequence" />
<available property="bsf.present"
classname="com.ibm.bsf.BSFManager"
classpathref="classpath" />
<condition property="netrexx.present">
<and>
<isset property="jdk1.2+"/>
<available classname="netrexx.lang.Rexx"
classpathref="classpath"/>
</and>
</condition>
<available property="trax.present"
classname="javax.xml.transform.Transformer"
classpathref="classpath" />
<available property="xslp.present"
classname="com.kvisco.xsl.XSLProcessor"
classpathref="classpath" />
<available property="xalan.present"
classname="org.apache.xalan.xslt.XSLTProcessorFactory"
classpathref="classpath" />
<available property="xalan2.present"
classname="org.apache.xalan.transformer.TransformerImpl"
classpathref="classpath" />
<available property="ejb.ejbc.present"
classname="weblogic.ejbc"
classpathref="classpath" />
<available property="ejb.DDCreator.present"
classname="weblogic.ejb.utils.DDCreator"
classpathref="classpath" />
<available property="ejb.wls.present"
classname="weblogic.Server"
classpathref="classpath" />
<available property="junit.present"
classname="junit.framework.TestCase"
classpathref="classpath" />
<available property="netcomp.present"
classname="com.oroinc.net.ftp.FTPClient"
classpathref="classpath" />
<available property="starteam.present"
classname="com.starbase.util.Platform"
classpathref="classpath" />
<available property="antlr.present"
classname="antlr.Tool"
classpathref="classpath"/>
<available property="vaj.present"
classname="com.ibm.ivj.util.base.Workspace"
classpathref="classpath"/>
<available property="stylebook.present"
classname="org.apache.stylebook.Engine"
classpathref="classpath"/>
<available property="jakarta.regexp.present"
classname="org.apache.regexp.RE"
classpathref="classpath"/>
<available property="jakarta.oro.present"
classname="org.apache.oro.text.regex.Perl5Matcher"
classpathref="classpath" />
<available property="jmf.present"
classname="javax.sound.sampled.Clip"
classpathref="classpath"/>
<condition property="icontract.present">
<and>
<isset property="jdk1.2+"/>
<available classname="com.reliablesystems.iContract.IContracted"
classpathref="classpath"/>
</and>
</condition>
<available property="jdepend.present"
classname="jdepend.framework.JDepend"
classpathref="classpath"/>
<available property="log4j.present"
classname="org.apache.log4j.Category"
classpathref="classpath"/>
<available property="commons.logging.present"
classname="org.apache.commons.logging.LogFactory"
classpathref="classpath"/>
<!-- this is just a way to check for a TraX implementation -->
<available property="trax.impl.present"
resource="META-INF/services/javax.xml.transform.TransformerFactory"
classpathref="classpath"/>
<available property="xalan.envcheck"
classname="org.apache.xalan.xslt.EnvironmentCheck"
classpathref="classpath" />
<available property="which.present"
classname="org.apache.env.Which"
classpathref="classpath" />

<available property="servlet.present"
classname="javax.servlet.Servlet"
classpathref="classpath"/>

<available property="xerces.present"
classname="org.apache.xerces.parsers.SAXParser"
classpathref="classpath" />
<condition property="bcel.present">
<and>
<isset property="jdk1.2+"/>
<available classname="org.apache.bcel.Constants"
classpathref="classpath"/>
</and>
</condition>
<available property="sunuue.present"
classname="sun.misc.UUEncoder"
classpathref="classpath" />

<condition property="javamail.complete">
<and>
<available classname="javax.activation.DataHandler"
classpathref="classpath"/>
<available classname="javax.mail.Transport"
classpathref="classpath"/>
</and>
</condition>

<condition property="some.regexp.support">
<or>
<isset property="jdk1.4+" />
<isset property="jakarta.regexp.present" />
<isset property="jakarta.oro.present" />
</or>
</condition>

<condition property="tests.and.ant.share.classloader">
<or>
<equals arg1="${junit.fork}" arg2="true" />
<equals arg1="${build.sysclasspath}" arg2="only" />
</or>
</condition>

<condition property="sun.tools.present">
<and>
<available classname="sun.tools.native2ascii.Main" />
<available classname="com.sun.tools.javah.Main" />
</and>
</condition>

<available property="base64.present" classname="sun.misc.BASE64Encoder" />

<property name="build.tests.resolved" location="${build.tests}" />
<condition property="tests.are.on.system.classpath">
<or>
<!-- relative paths in CLASSPATH -->
<contains string="${java.class.path}"
substring="${build.tests}" />
<!-- absolute paths in CLASSPATH -->
<contains string="${java.class.path}"
substring="${build.tests.resolved}" />
</or>
</condition>

<condition property="jasper.present">
<and>
<available classname="org.apache.jasper.compiler.Compiler" />
<available classname="org.apache.jasper.JasperException" />
</and>
</condition>

<available property="swing.present"
classname="javax.swing.ImageIcon"
classpathref="classpath"/>

<condition property="wsdl.found">
<or>
<available file="wsdl" filepath="${env.PATH}" />
<available file="wsdl.exe" filepath="${env.PATH}" />
<available file="wsdl.exe" filepath="${env.Path}" />
</or>
</condition>
<echo level="verbose"> wsdl.found=${wsdl.found}</echo>
<condition property="csc.found">
<or>
<available file="csc" filepath="${env.PATH}" />
<available file="csc.exe" filepath="${env.PATH}" />
<available file="csc.exe" filepath="${env.Path}" />
</or>
</condition>
<echo level="verbose"> csc.found=${csc.found}</echo>
<condition property="dotnetapps.found">
<and>
<isset property="csc.found"/>
<isset property="wsdl.found"/>
</and>
</condition>
<echo level="verbose"> csc.found=${csc.found}</echo>
</target>

<target name="ant1compat" depends="check_for_optional_packages">
<mkdir dir="${bin.dir}/ant1src_copy"/>
<mkdir dir="${bin.dir}/ant1compat"/>
<copy todir="${bin.dir}/ant1src_copy">
<fileset refid="ant1src_tocopy"/>
</copy>
<depend destdir="${bin.dir}/ant1compat" srcdir="${bin.dir}/ant1src_copy:${java.dir}/antlibs/ant1compat"
closure="yes">
<classpath refid="classpath"/>
</depend>
<javac destdir="${bin.dir}/ant1compat"
srcdir="${bin.dir}/ant1src_copy:${java.dir}/antlibs/ant1compat"
debug="${debug}">
<classpath refid="classpath" />

<patternset refid="needs.jdk1.2+" />
<patternset refid="needs.jdk1.3+" />
<patternset refid="needs.jdk1.4+" />

<patternset refid="needs.jakarta.regexp" />
<patternset refid="needs.jakarta.oro" />
<patternset refid="needs.jakarta.log4j" />
<patternset refid="needs.commons.logging" />
<patternset refid="needs.sun.uue" />
<patternset refid="needs.javamail" />
<patternset refid="needs.icontract" />
<patternset refid="needs.bsf" />
<patternset refid="needs.stylebook" />
<patternset refid="needs.netrexx" />
<patternset refid="needs.trax" />
<patternset refid="needs.xslp" />
<patternset refid="needs.xalan1" />
<patternset refid="needs.weblogic.ejbc" />
<patternset refid="needs.weblogic.ddcreator" />
<patternset refid="needs.weblogic.server" />
<patternset refid="needs.junit" />
<patternset refid="needs.netcomponents" />
<patternset refid="needs.starteam" />
<patternset refid="needs.antlr" />
<patternset refid="needs.vaj" />
<patternset refid="needs.servletapi" />
<patternset refid="needs.jmf" />
<patternset refid="needs.xalan2" />
<patternset refid="needs.jdepend" />
<patternset refid="needs.sun.tools" />
<patternset refid="needs.sun.b64" />
<patternset refid="needs.jakarta.bcel" />
<patternset refid="needs.swing" />
</javac>
<copy todir="${bin.dir}/ant1compat">
<fileset dir="${bin.dir}/ant1src_copy" excludes="**/*.java"/>
</copy>

<copy todir="${bin.dir}/ant1compat/${optional.package}/junit/xsl">
<fileset dir="${ant1etc.dir}">
<include name="junit-frames.xsl" />
<include name="junit-noframes.xsl" />
</fileset>
</copy>

<mkdir dir="${dist.antlibs.dir}"/>
<jar basedir="${bin.dir}/ant1compat" jarfile="${dist.antlibs.dir}/ant1compat.jar">
<metainf dir="${java.dir}/antlibs/ant1compat"
includes="antlib.xml"/>
</jar>
</target>

<!--
===================================================================
Compile testcases
===================================================================
-->
<target name="compile-tests" depends="check_for_optional_packages" if="junit.present">
<mkdir dir="${build.tests}"/>

<javac srcdir="${tests.dir}"
destdir="${build.tests}"
debug="${debug}"
deprecation="${deprecation}" >
<classpath refid="tests-classpath" />

<patternset refid="needs.antlr" />

<patternset refid="needs.jdk1.2+" />
<patternset refid="needs.jdk1.3+" />
<patternset refid="needs.jdk1.4+" />

<patternset refid="needs.jakarta.regexp" />
<patternset refid="needs.jakarta.oro" />

<patternset refid="needs.trax" />
<patternset refid="needs.xslp" />
<patternset refid="needs.xalan1" />
<patternset refid="needs.jakarta.bcel" />
<patternset refid="unsupportedTests" />
</javac>
<copy todir="${tests.etc.dir}">
<fileset refid="ant1testcases_tocopy"/>
</copy>
</target>

<target name="dump-info" depends="dump-sys-properties,run-which" />

<target name="dump-sys-properties" unless="which.present"
depends="xml-check">
<echo message="java.vm.info=${java.vm.info}" />
<echo message="java.vm.name=${java.vm.name}" />
<echo message="java.vm.vendor=${java.vm.vendor}" />
<echo message="java.vm.version=${java.vm.version}" />
<echo message="os.arch=${os.arch}" />
<echo message="os.name=${os.name}" />
<echo message="os.version=${os.version}" />
<echo message="file.encoding=${file.encoding}" />
<echo message="user.language=${user.language}" />
</target>

<!-- helper class from Xalan2 to check for jar versioning of xml/xsl processors -->
<target name="xml-check" depends="check_for_optional_packages"
if="xalan.envcheck" unless="which.present">
<java classname="org.apache.xalan.xslt.EnvironmentCheck"/>
</target>

<target name="run-which" depends="check_for_optional_packages"
if="which.present">
<java classname="org.apache.env.Which" taskname="which"/>
</target>

<!-- test to see if we are online or not. can take a while when we are off line, so
setting the property is a good shortcut-->
<target name="probe-offline">
<condition property="offline">
<or>
<isset property="offline"/>
<not>
<http url="http://www.apache.org/"/>
</not>
</or>
</condition>
<echo level="verbose" > offline=${offline}</echo>
</target>

<!--
===================================================================
Run testcase
===================================================================
-->
<target name="test" depends="run-tests" description="--> run JUnit tests"/>

<target name="run-tests" depends="dump-info,compile-tests,probe-offline" if="junit.present">

<junit printsummary="${junit.summary}" haltonfailure="yes"
filtertrace="${junit.filtertrace}"
fork="${junit.fork}">
<classpath refid="tests-classpath"/>

<sysproperty key="ant.home" value="${ant.home}" />
<sysproperty key="build.tests" value="${build.tests}"/>
<sysproperty key="tests-classpath.value"
value="${tests-classpath.value}" />

<formatter type="brief" usefile="false" />

<batchtest>
<fileset dir="${tests.dir}">
<include name="**/*Test*" />

<!-- abstract classes, not testcases -->
<exclude name="${ant.package}/taskdefs/TaskdefsTest.java" />
<exclude name="${ant.package}/BuildFileTest.java" />
<exclude name="${regexp.package}/RegexpMatcherTest.java" />
<exclude name="${regexp.package}/RegexpTest.java" />
<exclude name="${optional.package}/AbstractXSLTLiaisonTest.java" />
<exclude name="${ant.package}/types/AbstractFileSetTest.java" />

<!-- helper classes, not testcases -->
<exclude name="org/example/**" />
<exclude name="${ant.package}/taskdefs/TaskdefTest*Task.java" />

<!-- interactive test -->
<exclude name="${ant.package}/taskdefs/TestProcess.java" />

<!-- only run these tests if their required libraries are
installed -->
<patternset refid="needs.jdk1.2+" />
<patternset refid="needs.jdk1.4+" />
<patternset refid="needs.jakarta.regexp" />
<patternset refid="needs.jakarta.oro" />
<patternset refid="needs.vaj" />
<patternset refid="needs.antlr" />
<patternset refid="needs.xalan1" />
<patternset refid="needs.xslp" />
<patternset refid="needs.jakarta.bcel" />
<patternset refid="needs.trax" />
<patternset refid="unsupportedTests" />
<!-- fails under 1.1 -->
<exclude name="${optional.package}/perforce/P4ChangeTest.java"
unless="jdk1.2+"/>

<!-- tests excluded if the test is run in offline mode -->
<patternset refid="onlinetests"/>

<!-- failing tests excluded unless run.failing.tests is set -->
<patternset refid="teststhatfail" />

<!-- runtime dependencies that are different from compile
time dependencies -->
<exclude name="${optional.package}/ReplaceRegExpTest.java"
unless="some.regexp.support" />
<exclude name="${optional.package}/sitraka/*.java"
unless="some.regexp.support" />

<!-- fail if testcases can be loaded from the system classloader -->
<exclude name="${optional.package}/junit/JUnitClassLoaderTest.java"
if="tests.are.on.system.classpath"/>
<exclude name="${optional.package}/sitraka/XMLReportTest.java"
if="tests.are.on.system.classpath"/>

<!-- these tests need to be localised before being ran???? -->
<exclude name="${optional.package}/PvcsTest.java" />

<!-- ehm, this is not really a TraX test but rather a xalan2 test..-->
<exclude name="${optional.package}/TraXLiaisonTest.java"
unless="xalan2.present"/>

<!-- needs BSF to work -->
<exclude name="${optional.package}/XalanLiaisonTest.java"
unless="bsf.present" />

<!--
XXX need to figure out what's causing this InvocationTargetException
-->
<exclude name="${optional.package}/junit/JUnitTestRunnerTest.java"
unless="jdk1.2+" />
<!-- DateTime handling seems to be broken in JDK 1.1 -->
<exclude name="${util.package}/DateUtilsTest.java"
unless="jdk1.2+" />

<!-- misc oneoff tests -->
<exclude name="${optional.package}/JspcTest.java"
unless="jasper.present" />
<exclude name="${optional.package}/WsdlToDotnetTest.java"
unless="dotnetapps.found" />

<!-- These tests only passes if testcases and Ant classes have
been loaded by the same classloader - will throw
IllegalAccessExceptions otherwise. -->
<exclude name="${ant.package}/taskdefs/SQLExecTest.java"
unless="tests.and.ant.share.classloader" />
<exclude name="${optional.package}/sos/SOSTest.java"
unless="tests.and.ant.share.classloader" />
<exclude name="${optional.package}/TraXLiaisonTest.java"
unless="tests.and.ant.share.classloader" />
<exclude name="${optional.package}/metamata/MAuditParserTest.java"
unless="tests.and.ant.share.classloader" />

<!-- can only run if cvs is installed on your machine
enable by setting the property have.cvs
-->
<exclude name="${ant.package}/taskdefs/AbstractCvsTaskTest.java"
unless="have.cvs" />

</fileset>
</batchtest>

</junit>
</target>

<target name="run-single-test" if="testcase" depends="compile-tests"
description="--> runs the single unit test defined in the testcase property">


<junit printsummary="${junit.summary}"
haltonfailure="yes"
fork="${junit.fork}"
filtertrace="${junit.filtertrace}">
<!-- <jvmarg value="-classic"/> -->
<sysproperty key="ant.home" value="${ant.home}" />
<sysproperty key="build.tests" value="${build.tests}"/>
<sysproperty key="tests-classpath.value"
value="${tests-classpath.value}" />
<classpath refid="classes.zip" />
<classpath refid="tests-classpath"/>
<formatter type="plain" usefile="false" />
<test name="${testcase}" />
</junit>
</target>

<target name="clean">
<delete dir="${bin.dir}/ant1src_copy"/>
<delete dir="${bin.dir}/ant1compat"/>
<delete dir="${tests.etc.dir}"/>
</target>

</project>

+ 0
- 9
proposal/mutant/build/bootstrap.xml View File

@@ -1,9 +0,0 @@
<project name="mutant-bootstrap" default="main" basedir="..">
<target name="main">
<style in="build.xml" out="src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java"
style="build/bootstrap.xsl"/>
<style in="build/ant1compat.xml" out="src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java"
style="build/bootstrap.xsl"/>
</target>
</project>


+ 0
- 198
proposal/mutant/build/bootstrap.xsl View File

@@ -1,198 +0,0 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output method="text" omit-xml-declaration="yes"/>

<xsl:template match="project">
<xsl:text>package org.apache.ant.builder;&#10;</xsl:text>
<xsl:text>public class </xsl:text>
<xsl:value-of select="attribute::name"/>
<xsl:text>Builder {&#10;</xsl:text>
<xsl:text> protected void _init(BuildHelper helper) {&#10;</xsl:text>
<xsl:apply-templates select="property"/>
<xsl:apply-templates select="path"/>
<xsl:text> }&#10;</xsl:text>
<xsl:apply-templates select="target"/>
<xsl:text>}&#10;</xsl:text>
</xsl:template>

<xsl:template match="property">
<xsl:text> helper.setProperty(&quot;</xsl:text>
<xsl:value-of select="attribute::name"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="attribute::value"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:template>

<xsl:template match="antcall">
<xsl:text> {&#10;</xsl:text>
<xsl:text> BuildHelper subHelper = new BuildHelper();&#10;</xsl:text>
<xsl:for-each select="param">
<xsl:text> subHelper.setProperty(&quot;</xsl:text>
<xsl:value-of select="attribute::name"/>
<xsl:text>&quot;, helper.resolve(&quot;</xsl:text>
<xsl:value-of select="attribute::value"/>
<xsl:text>&quot;));&#10;</xsl:text>
</xsl:for-each>
<xsl:text> subHelper.setParent(helper);&#10;</xsl:text>
<xsl:text> _init(subHelper);&#10;</xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="attribute::target"/>
<xsl:text>(subHelper);&#10;</xsl:text>
<xsl:text> }&#10;</xsl:text>
</xsl:template>

<xsl:template match="echo">
</xsl:template>

<xsl:template match="path">
<xsl:text> helper.createPath(&quot;</xsl:text>
<xsl:variable name="pathName" select="attribute::id"/>
<xsl:value-of select="$pathName"/>
<xsl:text>&quot;);&#10;</xsl:text>

<xsl:for-each select="fileset">
<xsl:text> </xsl:text>
<xsl:text>helper.addFileSetToPath(&quot;</xsl:text>
<xsl:value-of select="$pathName"/>
<xsl:text>&quot;, &#10;</xsl:text>
<xsl:text> &quot;</xsl:text>
<xsl:value-of select="attribute::dir"/>
<xsl:text>&quot;, </xsl:text>
<xsl:choose>
<xsl:when test="attribute::includes">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="attribute::includes"/>
<xsl:text>&quot;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>null</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>);&#10;</xsl:text>
</xsl:for-each>

<xsl:for-each select="pathelement">
<xsl:text> </xsl:text>
<xsl:text>helper.addPathElementToPath(&quot;</xsl:text>
<xsl:value-of select="$pathName"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="attribute::location"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:for-each>

<xsl:for-each select="path">
<xsl:text> </xsl:text>
<xsl:text>helper.addPathToPath(&quot;</xsl:text>
<xsl:value-of select="$pathName"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="attribute::refid"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template match="target">
<xsl:text> protected void </xsl:text>
<xsl:value-of select="translate(attribute::name, '-', '_')"/>
<xsl:text>(BuildHelper helper) {&#10;</xsl:text>
<xsl:text> helper.runDepends(this, &quot;</xsl:text>
<xsl:value-of select="translate(attribute::name, '-', '_')"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="translate(attribute::depends, '-', '_')"/>
<xsl:text>&quot;);&#10;</xsl:text>
<xsl:text> System.out.println(&quot;</xsl:text>
<xsl:value-of select="attribute::name"/>
<xsl:text>: &quot;);&#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text> }&#10;</xsl:text>
</xsl:template>

<xsl:template match="mkdir">
<xsl:text> helper.mkdir(&quot;</xsl:text>
<xsl:value-of select="attribute::dir"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:template>

<xsl:template match="javac">
<xsl:text> helper.javac(&quot;</xsl:text>
<xsl:value-of select="attribute::srcdir"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="attribute::destdir"/>
<xsl:text>&quot;, </xsl:text>
<xsl:choose>
<xsl:when test="classpath">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="classpath/attribute::refid"/>
<xsl:text>&quot;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>null</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>);&#10;</xsl:text>
</xsl:template>

<xsl:template match="jar">
<xsl:text> helper.jar(&quot;</xsl:text>
<xsl:value-of select="attribute::basedir"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="attribute::jarfile"/>
<xsl:text>&quot;,&#10; </xsl:text>
<xsl:choose>
<xsl:when test="metainf">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="metainf/attribute::dir"/>
<xsl:text>&quot;, </xsl:text>
<xsl:choose>
<xsl:when test="metainf/attribute::includes">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="metainf/attribute::includes"/>
<xsl:text>&quot;, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>null, </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>null, null, </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="manifest/attribute[attribute::name='Class-Path']">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="manifest/attribute[attribute::name='Class-Path']/attribute::value"/>
<xsl:text>&quot;, </xsl:text>
</xsl:when>
<xsl:otherwise>null, </xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="manifest/attribute[attribute::name='Main-Class']">
<xsl:text>&quot;</xsl:text>
<xsl:value-of select="manifest/attribute[attribute::name='Main-Class']/attribute::value"/>
<xsl:text>&quot;</xsl:text>
</xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
<xsl:text>);&#10;</xsl:text>
</xsl:template>


<xsl:template match="copy/fileset">
<xsl:choose>
<xsl:when test="attribute::refid">
<xsl:text> helper.copyFilesetRef(&quot;</xsl:text>
<xsl:value-of select="attribute::refid"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="../attribute::todir"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> helper.copyFileset(&quot;</xsl:text>
<xsl:value-of select="attribute::dir"/>
<xsl:text>&quot;, &quot;</xsl:text>
<xsl:value-of select="../attribute::todir"/>
<xsl:text>&quot;);&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

+ 0
- 49
proposal/mutant/build/docs.xml View File

@@ -1,49 +0,0 @@
<project name="build-site" default="docs" basedir="..">

<!-- Initialization properties -->
<property name="project.name" value="mutant"/>
<property name="docs.src" location="xdocs"/>
<property name="docs.dest" location="docs"/>
<property name="project.file" value="stylesheets/project.xml" />
<property name="site.dir" location="../../../jakarta-site2" />
<property name="templ.path" location="xdocs/stylesheets" />
<property name="velocity.props" location="${docs.src}/velocity.properties" />

<path id="anakia.classpath">
<fileset dir="${site.dir}/lib">
<include name="*.jar"/>
</fileset>
</path>

<target name="prepare">
<available classname="org.apache.velocity.anakia.AnakiaTask"
property="AnakiaTask.present">
<classpath refid="anakia.classpath"/>
</available>
</target>

<target depends="prepare" name="prepare-error" unless="AnakiaTask.present">
<echo>
AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath.
</echo>
</target>

<target name="docs" depends="prepare-error" if="AnakiaTask.present">
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="anakia.classpath"/>
</taskdef>

<anakia basedir="${docs.src}" destdir="${docs.dest}/"
extension=".html" style="./site.vsl"
projectFile="${project.file}"
excludes="**/stylesheets/** faq.xml"
includes="**/*.xml"
lastModifiedCheck="true"
templatePath="${templ.path}"
velocityPropertiesFile="${velocity.props}">
</anakia>
</target>

<target name="all" depends="docs"/>
</project>

+ 0
- 51
proposal/mutant/build/script.xml View File

@@ -1,51 +0,0 @@
<project default="build" name="Ant2 script tasks" basedir="..">

<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="java.dir" value="${src.dir}/java"/>

<property name="bin.dir" value="bin"/>
<property name="dist.dir" value="dist"/>
<property name="javadocs.dir" value="${dist.dir}/javadocs"/>
<property name="distlib.dir" value="${dist.dir}/lib"/>
<property name="debug" value="true"/>

<property name="ant.package" value="org/apache/tools/ant"/>
<property name="optional.package" value="${ant.package}/taskdefs/optional"/>
<property name="optional.type.package" value="${ant.package}/types/optional"/>
<property name="util.package" value="${ant.package}/util"/>
<property name="regexp.package" value="${util.package}/regexp"/>

<path id="classpath.script">
<pathelement location="${distlib.dir}/init.jar"/>
<fileset dir="${lib.dir}/antlib/script" includes="*.jar"/>
<pathelement location="${distlib.dir}/common/common.jar"/>
</path>

<target name="check_bsf">
<available property="bsf.present"
classname="com.ibm.bsf.BSFManager"
classpathref="classpath.script" />
</target>
<target name="nobsf" unless="bsf.present">
<echo message="You must provide the bsf.jar library in the ${lib.dir}/antlib/script directory"/>
</target>
<target name="build" depends="check_bsf, nobsf" if="bsf.present">
<mkdir dir="${bin.dir}/antlibs/script"/>
<mkdir dir="${distlib.dir}/antlibs"/>
<depend destdir="${bin.dir}/antlibs/script" srcdir="${java.dir}/antlibs/script" closure="yes">
<classpath refid="classpath.script"/>
</depend>
<javac destdir="${bin.dir}/antlibs/script" srcdir="${java.dir}/antlibs/script" debug="${debug}">
<classpath refid="classpath.script"/>
</javac>
<jar basedir="${bin.dir}/antlibs/script" jarfile="${distlib.dir}/antlibs/script.tsk">
<metainf dir="${java.dir}/antlibs/script"
includes="antlib.xml"/>
</jar>
</target>
</project>

+ 0
- 657
proposal/mutant/docs/desc.html View File

@@ -1,657 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Mutant Design Notes</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>

<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./index.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
<li> <a href="./features.html">User Features</a>
</li>
<li> <a href="./developers.html">Task Developers</a>
</li>
<li> <a href="./design.html">Design Description</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Mutant Design Notes"><strong>Mutant Design Notes</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
This is a brief, albeit rambling description of Mutant.
Mutant has many experimental ideas which may or may not prove useful.
I'll try to describe what is there and let anyone who is interested
comment. Mutant is still immature. You'll notice that there is, at this
time, just one task, a hacked version of the echo task, which I have
been using to test out ideas. Most tasks would end up being pretty
similar to their Ant 1.x version.
</p>
<p>
OK, let me start with some of the motivating requirements. There are of
coure many Ant2 requirements but I want to focus on these two for now.
Mutant does also address many of the other Ant2 requirements.
</p>
<p>
I'll use the terms Ant and mutant somewhat interchangeably - just
habit, not an assumption of any sort.
</p>
<p>
One of the things which is pretty difficult in Ant 1.x is the
management of classpaths and classloaders. For example, today the
antlr task requires the antlr classes in the classpath used to start
ant. I'm talking here about the classpath built up in the ant.bat/ant
script launchers. At the same time, the checkstyle task
which uses antlr won't run if the antlr classes are in the classpath
because then those classes cannot "see" the classes in the taskdef's
classpath.
</p>
<p>
Another requirement I have is extensibility. In Ant 1.x this is
difficult because whenever a new type is created, each task which
needs to support this type must be changed to provide the new addXXX
method. The ejbjar task is on example of this problem with its concept of vendor
specific tools. The zip/jar task, with its support for different types
of fileset, is another. The addition of the classfileset to Ant requires
a change to the zip task.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Mutant Initialization"><strong>Mutant Initialization</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Mutant defines a classloader hierarchy somewhat similar to that used
in Tomcat 4. Tasks join into this hierarchy at a particular point to
ensure they have visibility of the necessary interface classes and no
visibility of the Ant core itself. There is nothing particularly novel
about this approach, but tasks are able to request certain additional resources
as we will see later.
</p>
<p>
Mutant starts with two jars. One is the start.jar which contains just
one class, Main.java which establishes the initial configuration and
then runs the appropriate front end command line class. If a different
front end was desired, a different launch class, in its own jar, would
be used. This would perhaps configure the classloader hierarchy somewhat
differently and start the approriate GUI front end class.
</p>
<p>
The second jar, init.jar, provides a number of initialisation utilities. These
are used by Main.java to setup Ant and would also be used by any other front end
to configure Ant. The important class here is the
InitConfig which communicates the state of Ant at startup into the the core of
Ant when it starts up. Main determines the location of ANT_HOME based on the
location of the start classes and then populates the InitConfig with both
classloaders and information about the location of various jars and config
files.
</p>
<p>
At the top of the classloader hierarchy
are the bootstrap and system classloaders. I won't really
distinguish between these in mutant. Combined they provide the JDK
classes, plus the classes from the init and start jars. One objective is
to keep the footprint of the init and start jars small so they do not
require any external classes, which may then become visible lower in the
hierarchy. Main does not explicitly create these loaders, of course, but
just adds a reference to the init config as system class loader
</p>
<p>
The next jar is for the common area. This provides interface definitions
and utility classes for use by both the core and by tasks/types etc. It
is loaded from ANT_HOME/lib/common/*.jar. Typically this is just
lib/common/common.jar but any other jars in here are loaded. This
pattern is used in the construction of all of the classloaders.
</p>
<p>
Next up is the core loader. It includes the lib/antcore/antcore.jar plus
any others including the XML parser jars. Mutant's core does not assume that
the project model will come from an XML description but XML facilities
are needed in the core for reading in Ant library defs and config files.
The parser jar locations are also stored in the init config. This lets
the jars be added to any Ant library that wants to use Ant's XML parser
rather than providing its own. Similarly tools.jar's location is
determined automatically and added to the config for use by tasks which
request it. I'll go into more detail when discussing the antlib processing.
</p>
<p>
The final jar that is loaded is the jar for the frontend - cli.jar. This
is not passed in init config since these classes are not visible to the
core and are not needed by it. So the hierarchy is
<pre>
jdk classes
|
start/init
|
common
|
antcore
|
cli
</pre>
</p>
<p>
Task classloaders generally will come in at common, hiding the core classes, front
end and XML parser classes from tasks.
</p>
<p>
Once Main has setup the initConfig, it creates the front end commandline
class and launches mutant proper, passing it the command line args and
the init config.
</p>
<p>
A GUI would typically replace start.jar and the cli.jar with its own
versions which manage model construction from GUI processes rather than
from XML files. It may be possible to move some of Main.java's
processing into init.jar if it is useful to other front ends. I haven't
looked at that balance.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Mutant Frontend"><strong>Mutant Frontend</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The front end is responsible for coordinating execution of Ant. It
manages command line arguments, builds a model of the Project to be
evaluated and coordinates the execution services of the core. cli.jar
contains not only the front-end code but also the XML parsing code for
building a project model from an XML description. Other front ends may
choose to build project models in different ways. Commandline is pretty
similar to Ant 1.x's Main.java - it handles arguments, building loggers,
listeners, defines, etc - actually I haven't fully implemented
command line defines in
mutant yet but it would be similar to Ant 1.x.
</p>
<p>
Commandline then moves to building a project model from the XML
representation. I have just expanded the approach in Ant 1's
ProjectHelper for XML parsing, moving away from a stack of inner classes.
The classes in the front end XML parsing use some XML utility base
classes from the core.
</p>
<p>
The XML parsing handles two elements at parse time. One is the &lt;ref&gt;
element which is used for project references - that is relationships
between project files. The referenced project is parsed as well. The
second is the &lt;include&gt; element which includes either another complete
project or a project &lt;fragment&gt; directly into the project. All the other
elements are used to build a project model which is later processed in
the core.
</p>
<p>
The project model itself is organized like this
</p>
<p>
<ul>
<li>A project contains</li>
<ul>
<li>named references to other projects</li>
<li>targets</li>
<li>build elements (tasks, type instances)</li>
</ul>
<li>A target contains</li>
<ul>
<li>build elements (tasks, type instances)</li>
</ul>

<li>A build element contains</li>
<ul>
<li>build elements (nested elements)</li>
</ul>
</ul>
</p>
<p>
So, for now the project model contains top level tasks and type
instances. I'm still thinking about those and property scoping
especially in the face of project refs and property overrides. Anyway,
the running of these tasks is currently disabled.
</p>
<p>
Once the model is built, the commandline creates an execution manager
instance, passing it the initConfig built by Main.jar. It adds build
listeners and then starts the build using the services of the
ExecutionManager.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Ant Libraries"><strong>Ant Libraries</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Before we get into execution proper, I'll deal with the structure of an
ant library and how it works. An antlibrary is a jar file with a library
descriptor located in META-INF/antlib.xml. This defines what
typedefs/taskdefs/converters the library makes available to Ant. The
classes or at least some of the classes for the library will normally be
available in the jar. The descriptor looks like this (I'll provide two
examples here)
</p>
<p>
<pre>
&lt;antlib libid="ant.io"
home="http://jakarta.apache.org/ant"
isolated="true"&gt;
&lt;typedef name="thread" classname="java.lang.Thread"/&gt;
&lt;taskdef name="echo" classname="org.apache.ant.taskdef.io.Echo"/&gt;

&lt;converter classname="org.apache.ant.taskdef.io.FileConverter"/&gt;
&lt;/antlib&gt;

&lt;antlib libid="ant.file"
home="http://jakarta.apache.org/ant"
reqxml="true" reqtools="true" extends="ant.io"
isolated="true"&gt;
&lt;taskdef name="copy" classname="org.apache.ant.file.copy"/&gt;
&lt;/antlib&gt;
</pre>
</p>
<p>
the "libid" attribute is used to globally identify a library. It is used
in Ant to pick which tasks you want to make available to a build file.
As the number of tasks available goes up, this is used to prevent name
collisions, etc. The name is constructed similarly to a Java package name -
i.e Reverse DNS order.
</p>
<p>
The "home" attribute is a bit of fluff unused by mutant to allow tools
to manage libraries and update them etc. More thought could go into
this.
</p>
<p>
"reqxml" allows a library to say that it wants to use Ant's XML parser
classes. Note that these will be coming from the library's classloader
so they will not, in fact, be the same runtime classes as used in Ant's core,
but it saves tasks packaging their own XML parsers.
</p>
<p>
"reqtools" allows a library to specify that it uses classes from Sun's
tools.jar file. Again, if tools.jar is available it will be added to the
list of classes in the library's classloader
</p>
<p>
"extends" allows for a single "inheritance" style relationship between
libraries. I'm not sure how useful this may be yet but it seems
important for accessing common custom types. It basically translates
into the class loader for this library using the one identified in
extends as its parent.
</p>
<p>
"isolate" specifies that each task created from this libary comes from
its own classloader. This can be used with tasks derived from Java
applications which have static initialisers. This used to be an issue
with the Anakia task, for example. Similarly it could be used to ensure that
tool.jar classes are unloaded to stop memory leaks. Again this is
experimental so may not prove ultimately useful.
</p>
<p>
The &lt;typedef&gt; in the example creates a &lt;thread&gt; type. That is just a bit of fun which
I'll use in an example later. It does show the typedefing of a type from
outside the ant library however.
</p>
<p>
&lt;taskdef&gt; is pretty obvious. It identifies a taskname with a class from
the library. The import task, which I have not yet implemented will
allow this name to be aliased - something like
</p>
<p>
&lt;import libid="ant.file" task="echo" alias="antecho"/&gt;
</p>
<p>
Tasks are not made available automatically. The build file must state
which tasks it wants to use using an &lt;import&gt; task. This is similar to
Java's import statement. Similarly classes whose ids start with "ant."
are fully imported at the start of execution.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Mutant Configuration"><strong>Mutant Configuration</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
When mutant starts execution, it reads in a config file. Actually it
attempts to read two files, one from $ANT_HOME/conf/antconfig.xml and
another from $HOME/.ant/antconfig.xml. Others could be added even
specified in the command line. These config files are used to provide
two things - libpaths and task dirs.
</p>
<p>
Taskdirs are locations to search for additional ant libraries. As people
bundle Ant tasks and types with their products, it will not be practical
to bundle all this into ANT_HOME/lib. These additional dirs are scanned
for ant libraries. All .zip/.jar/.tsk files which contain the
META-INF/antlib.xml file will be processed.
</p>
<p>
Sometimes, of course, the tasks and the libraries upon which they depend
are not produced by the same people. It is not feasible to go in and
edit manifests to connect the ant library with its required support
jars, so the libpath element in the config file is used to specify
additional paths to be added to a library's classloader. An example
config would be
</p>
<p>
<pre>
&lt;antconfig&gt;
&lt;libpath libid="ant.file" path="fubar"/&gt;
&lt;libpath libid="ant.file" url="http://fubar"/&gt;
&lt;/antconfig&gt;
</pre>
</p>
<p>
Obviously other information can be added to the config - standard
property values, compiler prefs, etc. I haven't done that yet. User
level config override system level configs.
</p>
<p>
So, when a ant library creates a classloader, it will take a number of
URLS. One is the task library itself, the XML parser classes if
requested, the tools.jar if requested, and any additional libraries
specified in the &lt;antconfig&gt;. The parent loader is the common loader
from the initconfig. unless this library is an extending library.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Mutant Execution"><strong>Mutant Execution</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Execution of a build is provided by the core through two key classes.
One if the ExecutionManager and the other is the ExecutionFrame. An
execution frame is created for each project in the project model
hierarchy. It represents the execution state of the project - data
values, imported tasks, typedefs, taskdefs, etc.
</p>
<p>
The ExecutionManager begins by reading configs, searching for ant
libraries, configuring and appending any additional paths, etc. It then
creates a root ExecutionFrame which represents the root project. when a
build is commenced, the project model is validated and then passed to
the ExecutionFrame.
</p>
<p>
the ExecutionFrame is the main execution class. When it is created it
imports all ant libraries with ids that start with ant.*. All others are
available but must be explicitly imported with &lt;import&gt; tasks. When the
project is passed in, ExecutionFrames are created for any referenced
projects. This builds an ExecutionFrame hierarchy which parallels the
project hierarchy. Each &lt;ref&gt; uses a name to identify the referenced
project. All property and target references use these reference names to
identify the particular frame that hold the data. As an example, look at
this build file
</p>
<p>
<pre>
&lt;project default="test" basedir=".." doc:Hello="true"&gt;

&lt;ref project="test.ant" name="reftest"/&gt;

&lt;target name="test" depends="reftest:test2"&gt;
&lt;echo message="hello"/&gt;
&lt;/target&gt;

&lt;/project&gt;
</pre>
</p>
<p>
Notice the depends reference to the test2 target in the test.ant project
file. I am still using the ":" as a separator for refs. It doesn't
collide with XML namespaces so that should be OK.
</p>
<p>
Execution proceeds by determining the targets in the various frames
which need to be executed. The appropriate frame is requested to execute
the target's tasks and type instances. The imports for the frame are
consulted to determine what is the approrpiate library and class from
that library. A classloader is fetched, the class is instantiated,
introspected and then configured from the corresponding part of the
project model. Ant 1.x's IntrospectionHelper has been split into two -
the ClassIntrospector and the Reflector. When the task is being
configured, the context classloader is set. Similarly it is set when the
task is being executed. Types are handled similarly. When a type in
instantiated or a task executed, and they support the appropriate
interface, they will be passed a context through which they can access
the services of the core. Currently the context is an interface although
I have wondered if an abstract class may be better to handle expansion
of the services available over time.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Introspection and Polymorphism"><strong>Introspection and Polymorphism</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Introspection is not a lot different from Ant 1.x. After some thought I
have dropped the createXXX method to allow for polymorphic type support, discussed
below. setXXX methods, coupled with an approriate string to
type converter are used for attributes. addXXX methods are used for
nested elements. All of the value setting has been moved to a Reflector
object. Object creation for addXXX methods is no longer provided in the
reflector class, just the storage of the value. This allows support for
add methods defined in terms of interfaces. For example, the hacked Echo
task I am using has this definition
</p>
<p>
<pre>
/**
* testing
*
* @param runnable testing
*/
public void addRun(Runnable runnable) {
log("Adding runnable of type "
+ runnable.getClass().getName(), MessageLevel.MSG_WARN);
}
</pre>
</p>
<p>
So when mutant encounteres a nested element it does the following checks
</p>
<p>
Is the value specified by reference?
</p>
<p>
&lt;run ant:refid="test"/&gt;
</p>
<p>
Is it specified by as a polymorphic type?
</p>
<p>
&lt;run ant:type="thread"/&gt;
</p>
<p>
or is it just a normal run o' the mill nested element, which is
instantiated by a zero arg constructor.
</p>
<p>
Note the use of the ant namespace for the metadata. In essence the
nested element name &lt;run&gt; identifies the add method to be used, while
the refId or type elements specify the actual instance or type to be
used. The ant:type identifies an Ant datatype to be instantiated. If
neither is specified, the type that is expected by the identified
method, addRun in this case, is used to create an instance. In this case
that would fail.
</p>
<p>
Polymorphism, coupled with typedefs is one way, and a good way IMHO, of
solving the extensibility of tasks such as ejbjar.
</p>
<p>
OK, that is about the size of it. Let me finish with two complete build
files and the result of running mutant on them.
</p>
<h3>build.ant</h3>
<p>
<pre>
&lt;project default="test" basedir=".." doc:Hello="true"&gt;

&lt;ref project="test.ant" name="reftest"/&gt;

&lt;target name="test" depends="reftest:test2"&gt;
&lt;echo message="hello"/&gt;
&lt;/target&gt;

&lt;/project&gt;
</pre>
</p>
<h3>test.ant</h3>
<p>
<pre>
&lt;project default="test" basedir="." doc:Hello="true"&gt;
&lt;target name="test2"&gt;
&lt;thread ant:id="testit"/&gt;
&lt;echo message="hello2"&gt;
&lt;run ant:refid="testit"&gt;
&lt;/run&gt;
&lt;/echo&gt;

&lt;echo message="hello3"&gt;
&lt;run ant:type="thread"&gt;
&lt;/run&gt;
&lt;/echo&gt;
&lt;/target&gt;

&lt;/project&gt;
</pre>
</p>
<p>
If I run mutant via a simple script which has just one line
</p>
<p>
java -jar /home/conor/dev/mutant/dist/lib/start.jar $*
</p>
<p>
I get this
</p>
<p>
<pre>
test2:
[echo] Adding runnable of type java.lang.Thread
[echo] hello2
[echo] Adding runnable of type java.lang.Thread
[echo] hello3

test:
[echo] hello

BUILD SUCCESSFUL

Total time: 0 seconds
</pre>
</p>
<p>
Lets change the &lt;run&gt; definition to
</p>
<p>
&lt;run/&gt; in test.ant and the result becomes
</p>
<p>
<pre>
test2:
[echo] Adding runnable of type java.lang.Thread
[echo] hello2

BUILD FAILED

/home/conor/dev/mutant/test/test.ant:10:
No element can be created for nested element &lt;run&gt;.
Please provide a value by reference or specify the value type
</pre>
</p>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2000-2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 82
proposal/mutant/docs/design.html View File

@@ -1,82 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Developers</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>

<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./index.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
<li> <a href="./features.html">User Features</a>
</li>
<li> <a href="./developers.html">Task Developers</a>
</li>
<li> <a href="./design.html">Design Description</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Developers"><strong>Developers</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
This page will describe the design of Mutant's core.
</p>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2000-2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 82
proposal/mutant/docs/developers.html View File

@@ -1,82 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Developers</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>

<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./index.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
<li> <a href="./features.html">User Features</a>
</li>
<li> <a href="./developers.html">Task Developers</a>
</li>
<li> <a href="./design.html">Design Description</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Developers"><strong>Developers</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
This page will describe the operation of Mutant from a task developers perspective.
</p>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2000-2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 1112
proposal/mutant/docs/features.html
File diff suppressed because it is too large
View File


+ 0
- 867
proposal/mutant/docs/goals.html View File

@@ -1,867 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Mutant Goals</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>

<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./index.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
<li> <a href="./features.html">User Features</a>
</li>
<li> <a href="./developers.html">Task Developers</a>
</li>
<li> <a href="./design.html">Design Description</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Goals"><strong>Goals</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
This page describes the key goals that have shaped the development of
Mutant.
</p>
<p>
The first section identifies a set of issues with Ant1 that have cropped up as
Ant1 has evolved. The design implications of each issue are then summarized as a
Mutant requirement. I do not want to suggest that these problems are unsolvable
within the Ant1 design. Already I believe we have seen the Ant2 proposals
influencing people trying to extend Ant1. These issues may be solvable, although at
the risk of backward compatability impacts or further complication of the Ant1
codebase.
</p>
<p>
The second section covers a set of additional requirements that have emerged as
the whole concept of Ant2 has developed. Many of these came from the discussions
on the Ant-Dev mailing list.
</p>
<p>
The realisation of these requirements as they impact a user is on the
<a href="features.html">next page</a>. Th implications for task developers and
Ant developers are discussed in the following sections.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Ant1 Issues"><strong>Ant1 Issues</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Unrestricted core access"><strong>Unrestricted core access</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The interface between the Ant core and tasks is not controlled. It
allows tasks almost complete access to the internal data structures of the
core. This is poor encapsulation. Whilst most tasks do not need and do not
use this access, its existence nonetheless prevents changes being made to
the core without raising concerns about impacting backward compatability.
</p>
<p>
The uncontrolled nature of the task-core interface also makes it difficult
to reuse tasks and types in a different context without almost completely
duplicating the Ant core
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
A tightly defined interface between the core and the components (tasks and
types) will allow the core implementation to be changed without the risk
of impacting tasks. It will also allow components to be reused in other
contexts.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Lack of embedding support"><strong>Lack of embedding support</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Ant1 does not provide strong support for embedding Ant in other systems,
particularly a GUI or IDE. The development of Antidote highlighted this
difficultly. Antidote was forced to perform its own XML parsing so it could
build its own model of the build. There is no communication medium for a GUI to
communicate with the core. Without this capability any GUI will be limited to
simply editing the XML representation of the build.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
The definition of a project model, a Java-based object-model of a build
description would decouple Ant from the XML representation. This allows
other representations to be used. Such an object model also forms the basis
for communications between systems which want to embed Ant. An IDE could
manipulate this project object model directly and pass to the core for
processing without needing to convert to and from an external
representations such as XML.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Configuration done at Parse-Time"><strong>Configuration done at Parse-Time</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The original implementation of Ant1 performed all task configuration at the
time the XML description of the build was parsed (parse-time). This approach
could not handle dynamically created tasks very well since in some
instances the type of the task to be configured was not known at parse-time.
This limitation was overcome with the introduction of the UnknownElement and
RuntimeConfigurable classes. While these work well, they are confusing and at
times surprising to most Ant developers. Also some operations still occur at
parse-time, notably creation of nested elements of known types. This could be
overcome by going to a fully dynamic model but the fear of backward
incompatability constrains this change from occuring.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Execution-time configuration of tasks allows for the latest information to be
used for configuration. It is also necessary to support the concept of the
project model. The project model cannot contain execution-time information as it
does in Ant1
</p>

<p>
The decoupling of the parsing and exection phases, communicating through the
medium of the project model will allow the core to be modularized. The parsing
and execution phases can be separated and one replaced without impacting the
other.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Multiple execution"><strong>Multiple execution</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1, a task, once configured, may be used more than once - i.e. its
execute method may be called more than once. This occurs when the Ant
command line specifies the evaluation of two targets. If those targets have
overlapping dependencies, the tasks in those overlapping dependencies will
be executed twice. This arrangement requires task writers to preserve the
state configured by Ant during the execution of the task so that the next
execution has the correct configuration.
</p>
<p>
Many task writers are not aware of this requirement. Frequently the task's
state is changed during the execution method, which can lead to mysterious
falures during subsequent executions. This need to preserve the configuration
state makes writing tasks much harder.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Once a task is configured, it should be executed once. If the execution of
multiple targets is required, a new task instance should be created and
configured from the same project model. If reuse of task instances is desired
each instance must be reinitialized and reconfigured before use.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="No automatic deployment of tasks"><strong>No automatic deployment of tasks</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Ant1 has a set of well-known tasks (and types). A well-known task is one
for which a mapping between the taskname and its implementing class is
predefined in Ant. This mapping is provided by the two defaults.properties
files in Ant's code. These well-known tasks do not need to be taskdef'd to
make them available in a build file. Conversely tasks which are not in this
list need to be explicitly taskdef'd.
</p>
<p>
Note that this distinction is not the same as the core/optional
distinction found in Ant1. An Ant1 core task is notionally supported by Ant
without requiring any additional external libraries - it just requires the
classes available in the 1.1 JDK, in Ant and in the libraries Ant uses such
as the XML parser. An optional task is a task which requires JDK 1.2+
features or the support of an external library, such as jakarta-regexp.
</p>
<p>
The problem with this system is that there is no namespace management. If a
new task is added to Ant, it may invalidate buildfiles which are already
using that taskname via a taskdef. Actually the taskdef may continue to work or
it may not - it will depend on the nested elements that the task definitions
support (see above discussion of regarding cofiguration at parse-time)
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Tasks need to be deployed in libraries by either placing them in well known
directories of an Ant install or by telling Ant where to look for them. Removing
the central management of defined task names allows tasks libraries to be
developed and maintained independently of Ant much more easily.
</p>

<p>
Once centralised management of the task namespace is removed, there is,
however, the possibility of name collision. A mechanism is required to allow a
build file writer to select which particular tasks are assigned to which
tasknames.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Top level tasks"><strong>Top level tasks</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1 certain tasks may appear outside of any target. This is implemented as a
set of hardcoded conditions in the XML parsing phase. The execution and
configuration of these tasks does not involve the use of RuntimeConfigurable and
UnknownElement.
</p>
<p>
This hardcoding is not very inituitive. It is confusing to users who do not
know why only some tasks may be run outside of a target. Also as the list of
tasks that may be useful as a top-level task grows, further special cases must
be added to the code making the code harder to maintain.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
The number of special names should be kept to a minimum. Special cases should
be avoided as they are not inituitive.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Build file inclusion is cumbersome"><strong>Build file inclusion is cumbersome</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1, the inclusion of a set of build file definitions or targets is achieved
through the use of XML entities. This is just cumbersome.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
A simplified include mechanism is required to replace the entity based
inclusion of Ant1.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Classpath management"><strong>Classpath management</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Probably the greatest issue facing Ant1 today involves the management of the
classpath and the associated visibility of classes. Most optional tasks in Ant1
require the supporting classes for the task to be available on the system
classpath. For example, the JUnit task is only usable if the JUnit jar is on
the classpath. If it is not, Ant will complain about being unable to create the
junit task.
</p>
<p>
The usual solution when a user runs into this problem is to put the required jar
into the ANT_HOME/lib directory. This just adds the required jar to the system
classpath prior to starting Ant albeit without requiring the user to explicitly
set the classpath.
</p>
<p>
There are a number of issues with this approach. The classes on the
classpath share the same classloader as Ant's classes and Ant's support
libraries - particularly the XML parser. If a task wishes to use a specific XML
parser, it may conflict with Ant's own parser. If two tasks require different
versions of a supporting jar, these will conflict.
</p>
<p>
Many tasks make use of factory objects (dynamic class instantiation, dynamic
resource loading, etc). When the factory is in the system classpath it will not
be able to load resources available in a taskdef'd task's custom classpath due
to the delegating nature of classloaders. Such errors can be very confusing to
users. More recent code is likely to attempt use of a context classloader but
this is not set by Ant1 currently.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Do not require jars to be added to ANT_HOME/lib to enable tasks. Allow users to
specify the location of support jars on a per-library basis.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Extensibility"><strong>Extensibility</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The earliest versions Ant1 did not explicitly support any datatypes. The only
datatype, property, was actually created as a side-effect of running the
<code>&lt;property&gt;</code> task. If it were to be implemented today, property
would probably be known as a string datatype, perhaps associated with a
<code>&lt;load-properties&gt;</code> task. This is also the reason property
is one of those tasks which is allowed to exist outside of a target.
</p>
<p> As Ant1 evolved new types such as <code>&lt;path&gt;</code> and
<code>&lt;fileset&gt;</code> were added. The concept of datatypes has continued
to evolve to the point where users can now define new datatypes. It would be
expected that in addition to new types there will be many sub-types created,
such as new types of fileset. Ant1, however, does not strongly support such type
extensibility. When a subtype is created by extending an existing type, Ant1
requires it to be either used by reference or all tasks which accept the base
type need to be modified to support the new type. Use by reference is not always
possible. It will depend on whether the base type has been coded to support
references. </p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Support polymorphic behaviour, allowing a build file to pass a subtype to a
task which is defined to accept the base type. Allow task interfaces to be
defined in terms of interfaces.
</p>

<p>
Move reference processing to the core to make it more regular removing the
burden of type developers to explicitly support references.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Project object does too much"><strong>Project object does too much</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1 the Project object takes on too many roles including all of the
following:
</p>
<ul>
<li>Holds the project model built when parsing the build file</li>
<li>Holds the run-time state of the build through the properties and current
task definitions</li>
<li>Provides context for task execution. All tasks have a reference to their
project instance and use it to access core functions</li>
<li>Provides the implementation of common task operations</li>
<li>Build event management</li>
<li>Message logging</li>
<li>Global filter definitions</li>
<li>Java Version</li>
<li>Property replacement</li>
<li>Message Levels</li>
<li>Utility functions such as boolean conversion and path translation</li>
<li>Integration point for embedding Ant</li>
</ul>
<p> As a class, Project is not cohesive. Reuse of the Ant core functionality is
difficulty as all of these concerns bring in many other support classes.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Separate the various roles of Project into more cohesive classes.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Other Goals"><strong>Other Goals</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In addition to the issues which arise from Ant1 limitations, there are a number
of requirements which have emerged in the mailing list discussions about Ant2.
This isn't a complete list - just the ones I picked up for Mutant.
</p>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Limited project reuse"><strong>Limited project reuse</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p> In Ant1 the only way to reuse build file definitions is to use the
<code>&lt;ant&gt;</code> task. While useful, it is relatively coarse-grained. It
can also be tedious if you are trying to extend an existing project definition -
that is, adding new targets while retaining a user's ability to access the
existing targets. </p>
<p>
In addition to the extension of projects, it should be possible to compose
projects creating dependencies between the targets of the different projects,
and to access the data and definitions of one project by a controlling project
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Allow a project to extend and control other projects
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Ant1 Compatibility - Zero Friction"><strong>Ant1 Compatibility - Zero Friction</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
While it has always been accepted that there will be come backward compatibility
breaks in moving from Ant1 to Ant2, these should be minimized. If the changeover
from Ant1 to Ant2 is difficult, it may never happen. On the other hand, the
openness of the Ant1 interface means that some tasks will not work as expected -
the most difficult being the <code>&lt;script&gt;</code> task.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Achieve a practical level of compatability without degrading the integrity of
the core's interfaces. A practical level of compatability is intentionally a
vague measure but it would require the majority of projects in Gump to be built
without noticeable differences from Ant1
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="XML Configuration"><strong>XML Configuration</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1 configuration of Ant is achieved either through the execution of OS
dependent scripts by the launcher scripts or though properties files which have
the limited capability to set properties.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Provide an XML based configuration system with rich capabilities to configure
the operation of Ant.
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Aspects"><strong>Aspects</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
In Ant1 there are many things which are common to a group of tasks but adding
the capability to each task is repetitive and tedious. An example would be the
failonerror attribute which controls whether a task will cause the build to stop
when it fails. This started on just one task but has since been added to many
other tasks as users want more fine control over when their builds stop. Aspects
have been discussed as a mechanism for providing a single implementation of a
concept or control that can then be applied to tasks independently.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<p>
Investigate the use of an Aspect approach to provide common functionality
across tasks with a single implementation
</p>

</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 180
proposal/mutant/docs/index.html View File

@@ -1,180 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Mutant Introduction</title>
</head>

<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>

<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./index.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
<li> <a href="./features.html">User Features</a>
</li>
<li> <a href="./developers.html">Task Developers</a>
</li>
<li> <a href="./design.html">Design Description</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Introduction"><strong>Introduction</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
These pages describe the design and implementation of Mutant.
</p>
<p>
For some time, there has been the concept of Ant 2.0. a rearchitecting of
Ant designed to address the shortcomings in the design of Ant 1.x, while
drawing the experience gained in that development. This rearchitecting
would most likely be accompanied by at least some break in backward
compatability. Over time Ant 2.0 has come to be known as Ant2 and the current
Ant codebase is generally known as Ant1.
</p>
<p>
Mutant is my proposal, a revolution, for Ant2. Actually, I consider it more
an evolution of the design and implementation used for Ant1, but in Jakarta
parlance, being a separate codebase, it is termed a revolution.
</p>
<p>
There is no special significance in the name Mutant. I chose it because, as
a word, it is an extension of the word Ant and it also signifies a change
from the previous generation
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Other Proposals"><strong>Other Proposals</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Mutant is not the only proposed revolution for Ant2. Peter Donald has
developed another known as
<a href="http://jakarta.apache.org/ant/myrmidon">Myrmidon</a>
which presents a different view of how Ant2 could be realized. Other
people hold the view that Ant1 can continue to evolve and that there
is no need for rearchitecture of its codebase. I recommend you
investigate all these points of view.
</p>
<p>
As I write this, no decision has been taken as to which codebase will be
adopted for Ant2. It may not be Mutant and it could even be some entirely
new proposal. These pages do not compare and contrast Mutant with these
other proposals or points of view, at least not explicitly. They are just
intended to describe how Mutant is designed and implemented and why it is the
way it is.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Getting Started"><strong>Getting Started</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff">
<h1><font color="red">Caution</font></h1>

<p>
Mutant is not even an alpha release. While it is relatively stable, it is
subject to change. There are no backward compatability guarantees for any of
the classes, interfaces, build files, configuration, launch scripts, etc that
Mutant provides.
</p>

<p>In particular, some features in Mutant are experimental and may not, in the
long run, prove to be worthwhile.</p>


</td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
<a href="goals.html">Start</a> now by looking at the key requirements which have
shaped the design of Mutant.
</p>
<div align="right">
<p>Conor MacNeill</p>
</div>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 121
proposal/mutant/docs/intro.html View File

@@ -1,121 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!-- Content Stylesheet for Site -->

<!-- start the processing -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="author" value="Conor MacNeill">
<meta name="email" value="">
<title>Mutant Proposal - Mutant Introduction</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td colspan="2">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Mutant Proposal</strong></p>
<ul>
<li> <a href="./intro.html">Introduction</a>
</li>
<li> <a href="./goals.html">Design Goals</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Introduction"><strong>Introduction</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
These pages describe the design and implementation of mutant.
</p>
<p>
For some time, there has been the concept of Ant 2.0. a rearchitecting of
Ant designed to address the shortcomings in the design of Ant 1.x while
drawing the experience gained in that development. This rearchitecting
would most likely be accompanied by at least some break in backward
compatability. Indeed this fact was recognized by Duncan, the original
author of Ant when he proposed his AntEater revolution. Over time Ant 2.0
has come to be known as Ant2 and the current Ant codebase is generally
known as Ant1.
</p>
<p>
Mutant is my proposal, a revolution, for Ant2. Actually, I consider it more
an evolution of the design and implementation used for Ant1, but in Jakarta
parlance, being a separate codebase, it is termed a revolution.
</p>
<p>
There is no special significance in the name mutant. I chose it because, as
a word, it is an extension of the word ant and it also signifies a change
from the previos generation
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Other Proposals"><strong>Other Proposals</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Mutant is not the only proposed revolution for Ant2. Peter Donald, another
Ant committer, has developed another proposal known as Myrmidon, which you
should also investigate if you are interested in a different view of how
Ant2 should be realized. Other people hold the view that there is no need
for any rearchitecting and the Ant1 codebase can continue to evolve.
</p>
<p>
As I write this, no decision has been taken as to which codebase will be
adopted for Ant2. It may not be mutant or it could be some entirely new
proposal. This document does not compare and contrast mutant with these
other proposals or points of view, at least not explicitly. It is just
intended to describe and highlight how mutant is designed and implemented.
</p>
</blockquote>
</td></tr>
</table>
</td>
</tr>

<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 2000-2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->





+ 0
- 1
proposal/mutant/lib/ant1compat/readme.txt View File

@@ -1 +0,0 @@
Libraries required to build ant1 components go here

+ 0
- 1
proposal/mutant/lib/antlib/script/readme.txt View File

@@ -1 +0,0 @@
Please any jars in here which should be used when building the script antlib

BIN
proposal/mutant/lib/parser/xercesImpl.jar View File


BIN
proposal/mutant/lib/parser/xml-apis.jar View File


+ 0
- 49
proposal/mutant/src/conf/ant.policy View File

@@ -1,49 +0,0 @@
// Mutant Policy File
//
// Copyright (c) 2002 The Apache Software Foundation.
// All rights reserved.

// Need to explicitly grant to java.home to pick up tools.jar classes
grant codeBase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};

// full access is granted to the core
grant codeBase "file:${ant.home}/lib/core/-" {
permission java.security.AllPermission;
};

// grant full access to the command line front end.
// All operations can be controlled by setting the appropriate
// permissions on the front end. This will also affect core
// functions
grant codeBase "file:${ant.home}/lib/frontend/cli.jar" {
permission java.security.AllPermission;
};

// grant for the Ant1 compat jar. Other Ant libraries can be controlled
// individually.
grant codeBase "file:${ant.home}/lib/antlibs/ant1compat.jar" {
permission java.security.AllPermission;

// For backward compatibility the Ant1 compatabilioty is granted full
// permission. This can be reduced as desired to eliminate the ability to
// access the network.
//
// For example, the following permissions are required to build Mutant. Additional
// permissions are required depending on what tasks you want to enable.
// permission java.io.FilePermission "<<ALL FILES>>", "read, write, execute, delete";
// permission java.lang.RuntimePermission "accessDeclaredMembers";
// permission java.lang.RuntimePermission "createClassLoader";
// permission java.lang.RuntimePermission "getClassLoader";
// permission java.util.PropertyPermission "java.class.path", "read, write";
// permission java.util.PropertyPermission "java.home", "read";
// permission java.util.PropertyPermission "user.dir", "read";
// permission java.util.PropertyPermission "user.name", "read";
// permission java.util.PropertyPermission "sun.*", "read";
// permission java.util.PropertyPermission "java.*", "read";
// permission java.util.PropertyPermission "javac.*", "read";
// permission java.util.PropertyPermission "line.separator", "write";
// permission java.lang.RuntimePermission "accessClassInPackage.sun.*";
};


+ 0
- 115
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibDefinition.java View File

@@ -1,115 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;

/**
* This class represents a definition in an AntLibrary.
*
* @author Conor MacNeill
* @created 19 January 2002
*/
public class AntLibDefinition {
/** The type of element being defined int his definition */
private int definitionType;
/** The default name for the defintion */
private String definitionName;
/** The classname associated with the object */
private String definitionClassName;

/**
* Create a definition
*
* @param definitionName the default name of this definition when it is
* imported
* @param definitionClassName the name of the class which is being
* defined
* @param definitionType the type of the definition (taskdef, typedef,
* etc)
*/
public AntLibDefinition(int definitionType, String definitionName,
String definitionClassName) {
this.definitionName = definitionName;
this.definitionType = definitionType;
this.definitionClassName = definitionClassName;
}

/**
* Get the type of this definition
*
* @return the definition type
* @see AntLibrary for values
*/
public int getDefinitionType() {
return definitionType;
}

/**
* Get the default name for this definition
*
* @return the default name for this definition
*/
public String getDefinitionName() {
return definitionName;
}

/**
* Get the classname being defined
*
* @return the classname of this definition
*/
public String getClassName() {
return definitionClassName;
}
}


+ 0
- 134
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibException.java View File

@@ -1,134 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;

import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;

/**
* An AntLibException indicates a problem in an ant library
*
* @author Conor MacNeill
*/
public class AntLibException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public AntLibException(String msg) {
super(msg);
}


/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public AntLibException(String msg, Location location) {
super(msg, location);
}


/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public AntLibException(String msg, Throwable cause) {
super(msg, cause);
}


/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public AntLibException(String msg, Throwable cause, Location location) {
super(msg, cause, location);
}


/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public AntLibException(Throwable cause) {
super(cause);
}


/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public AntLibException(Throwable cause, Location location) {
super(cause, location);
}

}


+ 0
- 195
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibHandler.java View File

@@ -1,195 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import org.apache.ant.antcore.xml.ElementHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;

/**
* XML Element Handler for Ant library definitions
*
* @author Conor MacNeill
* @created 13 January 2002
*/
public class AntLibHandler extends ElementHandler {
/** The library identifier attribute name */
public static final String LIBID_ATTR = "libid";
/** The home attribute name */
public static final String HOME_ATTR = "home";
/**
* The name of the attribute which indicates if Ant's XML parser is to
* be made available
*/
public static final String REQXML_ATTR = "reqxml";
/** The extends attribute name */
public static final String EXTENDS_ATTR = "extends";
/** The name of the attribute which indicates tools jar is required */
public static final String REQTOOLS_ATTR = "reqtools";
/** The extends attribute name */
public static final String ISOLATED_ATTR = "isolated";


/** The list of allowed Attributes */
public static final String[] ALLOWED_ATTRIBUTES
= {LIBID_ATTR, HOME_ATTR, REQXML_ATTR, REQTOOLS_ATTR,
EXTENDS_ATTR, ISOLATED_ATTR};

/** The Ant Library definition being parsed. */
private AntLibrarySpec antLibrarySpec;

/**
* Gets the parsed antLibrary specification
*
* @return the parsed antLibrary
*/
public AntLibrarySpec getAntLibrarySpec() {
return antLibrarySpec;
}

/**
* Process the antlib element
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
antLibrarySpec = new AntLibrarySpec();

if (getAttribute(LIBID_ATTR) == null) {
throw new SAXParseException("antlib must have an libid sttribute",
getLocator());
}
antLibrarySpec.setLibraryId(getAttribute(LIBID_ATTR));
antLibrarySpec.setHome(getAttribute(HOME_ATTR));
antLibrarySpec.setExtendsLibraryId(getAttribute(EXTENDS_ATTR));
antLibrarySpec.setIsolated(getBooleanAttribute(ISOLATED_ATTR));
antLibrarySpec.setAntXML(getBooleanAttribute(REQXML_ATTR));
antLibrarySpec.setToolsJarRequired(getBooleanAttribute(REQTOOLS_ATTR));
}

/**
* Start a new element in the antlibrary.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {
try {
if (qualifiedName.equals("taskdef")
|| qualifiedName.equals("typedef")) {
DefinitionHandler defnHandler
= new DefinitionHandler(qualifiedName);
defnHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
antLibrarySpec.addDefinition(defnHandler.getDefinitionType(),
defnHandler.getName(), defnHandler.getClassName());
} else if (qualifiedName.equals("converter")) {
ClassNameHandler converterHandler = new ClassNameHandler();
converterHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
antLibrarySpec.addConverter(converterHandler.getClassName());
} else if (qualifiedName.equals("aspect")) {
ClassNameHandler aspectHandler = new ClassNameHandler();
aspectHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
antLibrarySpec.addAspect(aspectHandler.getClassName());
} else if (qualifiedName.equals("factory")) {
ClassNameHandler factoryHandler
= new ClassNameHandler();
factoryHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
String factoryClass = factoryHandler.getClassName();
antLibrarySpec.setFactory(factoryClass);
} else {
super.startElement(uri, localName, qualifiedName, attributes);
}
} catch (AntLibException e) {
throw new SAXParseException(e.getMessage(), getLocator(), e);
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
for (int i = 0; i < ALLOWED_ATTRIBUTES.length; ++i) {
if (attributeName.equals(ALLOWED_ATTRIBUTES[i])) {
return;
}
}
throwInvalidAttribute(attributeName);
}


}



+ 0
- 418
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java View File

@@ -1,418 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import java.io.FileNotFoundException;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.apache.ant.antcore.xml.ParseContext;
import org.apache.ant.antcore.xml.XMLParseException;
import org.apache.ant.common.util.CircularDependencyChecker;
import org.apache.ant.common.util.CircularDependencyException;
import org.apache.ant.init.AntEnvironment;
import org.apache.ant.init.LoaderUtils;

/**
* This class manages Ant Libraries. This class forms a global
* repository of loaded libraries so that only one copy of a library is
* used across all frames.
*
* @author Conor MacNeill
* @created 29 January 2002
*/
public class AntLibManager {
/**
* These are AntLibraries which have been loaded into the system
*/
private Map antLibraries = new HashMap();

/** The list of extensions which are examined for ant libraries */
public static final String[] ANTLIB_EXTENSIONS
= new String[]{".tsk", ".jar", ".zip"};

/** Flag which indicates whether non-file URLS are used */
private boolean remoteAllowed;

/** The Ant initialization config - location of vital components */
private AntEnvironment antEnv;

/**
* This map stores a list of additional paths for each library indexed by
* the libraryId
*/
private Map libPathsMap = new HashMap();

/**
* Constructor for the AntLibManager object
*
* @param antEnv the init config of the system.
* @param remoteAllowed true if remote libraries can be used and
* configured
*/
public AntLibManager(AntEnvironment antEnv, boolean remoteAllowed) {
this.remoteAllowed = remoteAllowed;
this.antEnv = antEnv;
}

/**
* Add all the Ant libraries that can be found at the given URL
*
* @param librarySpecs A map to which additional library specifications
* are added.
* @param libURL the URL from which Ant libraries are to be loaded
* @exception AntLibException if the library specs cannot be parsed
*/
public void addAntLibraries(Map librarySpecs, URL libURL)
throws AntLibException {
try {
URL[] libURLs = LoaderUtils.getLocationURLs(libURL,
libURL.toString(), ANTLIB_EXTENSIONS);

if (libURLs == null) {
return;
}

// parse each task library to get its library definition
for (int i = 0; i < libURLs.length; ++i) {
URL antLibraryURL = new URL("jar:" + libURLs[i]
+ "!/META-INF/antlib.xml");
try {
AntLibrarySpec antLibrarySpec
= parseLibraryDef(antLibraryURL);
if (antLibrarySpec != null) {
String libraryId = antLibrarySpec.getLibraryId();
if (librarySpecs.containsKey(libraryId)) {
AntLibrarySpec currentSpec
= (AntLibrarySpec) librarySpecs.get(libraryId);
throw new AntLibException("Found more than one "
+ "copy of library with id = " + libraryId
+ " (" + libURLs[i] + ") + existing library "
+ "at (" + currentSpec.getLibraryURL() + ")");
}
antLibrarySpec.setLibraryURL(libURLs[i]);
librarySpecs.put(libraryId, antLibrarySpec);
}
} catch (XMLParseException e) {
Throwable t = e.getCause();
// ignore file not found exceptions - means the
// jar does not provide META-INF/antlib.xml
if (t instanceof AntLibException) {
throw (AntLibException) t;
} else if (!(t instanceof FileNotFoundException)) {
throw new AntLibException("Unable to parse Ant "
+ "library " + libURLs[i], e);
}
}
}
} catch (MalformedURLException e) {
throw new AntLibException("Unable to load libraries from "
+ libURL, e);
}
}

/**
* Configures the Ant Libraries. Configuration of an Ant Library
* involves resolving any dependencies between libraries and then
* creating the class loaders for the library
*
* @param librarySpecs the loaded specifications of the Ant libraries
* @return A map of the newly configured libraries
* @exception AntLibException if a library cannot be configured from
* the given specification
*/
private Map configLibraries(Map librarySpecs)
throws AntLibException {

// check if any already defined
for (Iterator i = librarySpecs.keySet().iterator(); i.hasNext();) {
String libraryId = (String) i.next();
if (antLibraries.containsKey(libraryId)) {
AntLibrary currentVersion = getLibrary(libraryId);
// same location?
AntLibrarySpec spec
= (AntLibrarySpec) librarySpecs.get(libraryId);
URL specURL = spec.getLibraryURL();
if (!specURL.equals(currentVersion.getDefinitionURL())) {
throw new AntLibException("Ant Library \"" + libraryId
+ "\" is already loaded from "
+ currentVersion.getDefinitionURL()
+ " new version found at "
+ specURL);
}
}
}

Map newLibraries = new HashMap();
CircularDependencyChecker configuring
= new CircularDependencyChecker("configuring Ant libraries");
for (Iterator i = librarySpecs.keySet().iterator(); i.hasNext();) {
String libraryId = (String) i.next();
if (!antLibraries.containsKey(libraryId)) {
configLibrary(librarySpecs, libraryId,
configuring, newLibraries);
}
}

return newLibraries;
}

/**
* Load either a set of libraries or a single library.
*
* @param libLocationURL URL where libraries can be found
* @exception AntLibException if the libraries cannot be loaded
*
* @return a map containing the newly loaded libraries indexed by their
* library ids.
*/
public Map loadLibs(URL libLocationURL)
throws AntLibException {
if (!libLocationURL.getProtocol().equals("file")
&& !remoteAllowed) {
throw new AntLibException("The config library "
+ "location \"" + libLocationURL
+ "\" cannot be used because config does "
+ "not allow remote libraries");
}

Map librarySpecs = new HashMap();
addAntLibraries(librarySpecs, libLocationURL);
Map newLibraries = configLibraries(librarySpecs);

antLibraries.putAll(newLibraries);
return newLibraries;
}

/**
* Add a library path to the given library
*
* @param libraryId the id of the library to which the path is to be added
* @param libPath the path to be added
* @exception AntLibException if remote paths are not allowed by
* configuration
*/
public void addLibPath(String libraryId, URL libPath)
throws AntLibException {
if (!libPath.getProtocol().equals("file")
&& !remoteAllowed) {
throw new AntLibException("Remote libpaths are not"
+ " allowed: " + libPath);
}

List libPaths = (List) libPathsMap.get(libraryId);
if (libPaths == null) {
libPaths = new ArrayList();
libPathsMap.put(libraryId, libPaths);
}

List newPaths = new ArrayList();
newPaths.add(libPath);
if (libPath.getProtocol().equals("file")) {
File dir = new File(libPath.getFile());
if (dir.isDirectory()) {
try {
URL[] pathURLs = LoaderUtils.getLocationURLs(libPath,
null, ANTLIB_EXTENSIONS);
for (int i = 0; i < pathURLs.length; ++i) {
newPaths.add(pathURLs[i]);
}
} catch (MalformedURLException e) {
// ignore and just use what we were given
}
}
}

AntLibrary antLibrary = getLibrary(libraryId);
for (Iterator i = newPaths.iterator(); i.hasNext();) {
URL newPath = (URL) i.next();
libPaths.add(newPath);
if (antLibrary != null) {
antLibrary.addLibraryURL(newPath);
}
}
}

/**
* Configure a library from a specification and the Ant init config.
*
* @param librarySpecs the library specs from which this library is to
* be configured.
* @param libraryId the global identifier for the library
* @param configuring A circualr dependency chcker for library
* dependencies.
* @param newLibraries the new libraries being configured.
* @exception AntLibException if the library cannot be configured.
*/
private void configLibrary(Map librarySpecs, String libraryId,
CircularDependencyChecker configuring,
Map newLibraries)
throws AntLibException {

try {
configuring.visitNode(libraryId);

AntLibrarySpec librarySpec
= (AntLibrarySpec) librarySpecs.get(libraryId);
String extendsId = librarySpec.getExtendsLibraryId();
if (extendsId != null) {
if (!antLibraries.containsKey(extendsId) &&
!newLibraries.containsKey(extendsId)) {
if (!librarySpecs.containsKey(extendsId)) {
throw new AntLibException("Could not find library, "
+ extendsId + ", upon which library "
+ libraryId + " depends");
}
configLibrary(librarySpecs, extendsId,
configuring, newLibraries);
}
}

// now create the library for the specification
AntLibrary antLibrary = new AntLibrary(librarySpec);

// determine the URLs required for this task. These are the
// task URL itself, the XML parser URLs if required, the
// tools jar URL if required
List urlsList = new ArrayList();

if (librarySpec.getLibraryURL() != null) {
urlsList.add(librarySpec.getLibraryURL());
}
if (librarySpec.isToolsJarRequired()
&& antEnv.getToolsJarURL() != null) {
urlsList.add(antEnv.getToolsJarURL());
}

if (librarySpec.usesAntXML()) {
URL[] parserURLs = antEnv.getParserURLs();
for (int i = 0; i < parserURLs.length; ++i) {
urlsList.add(parserURLs[i]);
}
}

for (Iterator i = urlsList.iterator(); i.hasNext();) {
antLibrary.addLibraryURL((URL) i.next());
}
if (extendsId != null) {
AntLibrary extendsLibrary = getLibrary(extendsId);
if (extendsLibrary == null) {
extendsLibrary = (AntLibrary) newLibraries.get(extendsId);
}

antLibrary.setExtendsLibrary(extendsLibrary);
}
antLibrary.setParentLoader(antEnv.getCommonLoader());
newLibraries.put(libraryId, antLibrary);

if (libPathsMap != null) {
List libPaths = (List) libPathsMap.get(libraryId);
if (libPaths != null) {
for (Iterator j = libPaths.iterator(); j.hasNext();) {
URL pathURL = (URL) j.next();
antLibrary.addLibraryURL(pathURL);
}
}
}
configuring.leaveNode(libraryId);
} catch (CircularDependencyException e) {
throw new AntLibException(e);
}
}


/**
* Read an Ant library definition from a URL
*
* @param antlibURL the URL of the library definition
* @return the AntLibrary specification read from the library XML
* definition
* @exception XMLParseException if the library cannot be parsed
*/
private AntLibrarySpec parseLibraryDef(URL antlibURL)
throws XMLParseException {
ParseContext context = new ParseContext();
AntLibHandler libHandler = new AntLibHandler();

context.parse(antlibURL, "antlib", libHandler);

return libHandler.getAntLibrarySpec();
}


/**
* Get a loaded library by its id.
*
* @param libraryId the library's global id
*
* @return the requested library or null if it has not been loaded
*/
public AntLibrary getLibrary(String libraryId) {
return (AntLibrary) antLibraries.get(libraryId);
}

/**
* Get all the library ids of the currently loaded libraries.
*
* @return an iterator over the library identifier strings.
*/
public Iterator getLibraryIds() {
return antLibraries.keySet().iterator();
}
}


+ 0
- 301
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java View File

@@ -1,301 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.util.AntException;

/**
* This class represents the Ant library.
*
* @author Conor MacNeill
* @created 14 January 2002
*/
public class AntLibrary implements ComponentLibrary {
/**
* This is the globally unique name of this library. It uses the same
* conventions as the Java package space - i.e. reverse order DNS names
* This name is used when importing tasks from this library
*/
private String libraryId;

/** THe URL of the antlib.xml library spec which defines this library */
private URL definitionURL;

/**
* The URLs to use when contructing a classloader for the components in
* this library.
*/
private List libraryURLs = new ArrayList();

/** The list of converter classnames defined in this library */
private List converterClassNames = new ArrayList();

/** The list of aspect classnames defined in this library */
private List aspectClassNames = new ArrayList();

/** The class name of this library's factory class, if any */
private String factoryClassName;

/** The parent classloader to use when contructing classloaders */
private ClassLoader parentLoader;

/** The library which this library extends, if any */
private AntLibrary extendsLibrary;

/** Indicates if each Task Instance should use its own classloader */
private boolean isolated = false;

/** The classloader for this library if it can be reused */
private ClassLoader loader = null;

/** The definitions in the library */
private Map definitions = null;

/**
* Constructor for the AntLibrary object
*
* @param spec the specification from which this library is created.
*/
public AntLibrary(AntLibrarySpec spec) {
this.libraryId = spec.getLibraryId();
this.definitions = spec.getDefinitions();
this.isolated = spec.isIsolated();
this.converterClassNames.addAll(spec.getConverters());
this.aspectClassNames.addAll(spec.getAspects());
this.factoryClassName = spec.getFactory();
this.definitionURL = spec.getLibraryURL();
}

/**
* Sets the Library which this library extends
*
* @param extendsLibrary The new ExtendsLibrary value
*/
public void setExtendsLibrary(AntLibrary extendsLibrary) {
this.extendsLibrary = extendsLibrary;
}

/**
* Sets the ParentLoader of the AntLibrary
*
* @param parentLoader The new ParentLoader value
*/
public void setParentLoader(ClassLoader parentLoader) {
this.parentLoader = parentLoader;
}

/**
* Gets the libraryId of the AntLibrary
*
* @return the libraryId value
*/
public String getLibraryId() {
return libraryId;
}

/**
* Gets the ClassLoader of the AntLibrary
*
* @return The ClassLoader value
*/
public ClassLoader getClassLoader() {
if (isolated) {
return createLoader();
} else if (loader == null) {
loader = createLoader();
}
return loader;
}

/**
* Gets the definitions (taskdefs and typedefs) of the AntLibrary
*
* @return an iterator over the definition names
*/
public Iterator getDefinitionNames() {
return definitions.keySet().iterator();
}

/**
* Get the definition of a particular component
*
* @param definitionName the name of the component within the library
* @return an AntLibDefinition instance with information about the
* component's definition
*/
public AntLibDefinition getDefinition(String definitionName) {
return (AntLibDefinition) definitions.get(definitionName);
}

/**
* Gets the converter class names of the AntLibrary
*
* @return an iterator over a list of String class names
*/
public Iterator getConverterClassNames() {
return converterClassNames.iterator();
}

/**
* Gets the aspect class names of the AntLibrary
*
* @return an iterator over a list of String class names
*/
public Iterator getAspectClassNames() {
return aspectClassNames.iterator();
}

/**
* Get the URL to where the library was loaded from
*
* @return the library's URL
*/
public URL getDefinitionURL() {
return definitionURL;
}


/**
* Gat an instance of a factory object for creating objects in this
* library.
*
* @param context the context to use for the factory creation if
* required
* @return an instance of the factory, or null if this library does not
* support a factory
* @exception AntException if the factory cannot be created
*/
public AntLibFactory getFactory(AntContext context)
throws AntException {
try {
AntLibFactory libFactory = null;
if (factoryClassName != null) {
Class factoryClass = Class.forName(factoryClassName,
true, getClassLoader());
libFactory
= (AntLibFactory) factoryClass.newInstance();
libFactory.init(context);
}
return libFactory;
} catch (ClassNotFoundException e) {
throw new AntLibException("Unable to create factory "
+ factoryClassName + " for the \"" + libraryId
+ "\" Ant library", e);
} catch (NoClassDefFoundError e) {
throw new AntLibException("Could not load a dependent class ("
+ e.getMessage() + ") to create the factory "
+ factoryClassName + " for the \"" + libraryId
+ "\" Ant library", e);
} catch (InstantiationException e) {
throw new AntLibException("Unable to instantiate factory "
+ factoryClassName + " for the \"" + libraryId
+ "\" Ant library", e);
} catch (IllegalAccessException e) {
throw new AntLibException("Unable to access factory "
+ factoryClassName + " for the \"" + libraryId
+ "\" Ant library", e);
}
}

/**
* Indicate whether this library has any converters defined
*
* @return true if any converters have been defined
*/
public boolean hasConverters() {
return !converterClassNames.isEmpty();
}

/**
* Indicate whether this library has any aspects defined
*
* @return true if any aspects have been defined
*/
public boolean hasAspects() {
return !aspectClassNames.isEmpty();
}

/**
* Add a library to path to this AntLibrary definition
*
* @param libraryURL the URL to the library to be added
*/
public void addLibraryURL(URL libraryURL) {
libraryURLs.add(libraryURL);
}


/**
* Create classloader which can be used to load the classes of this ant
* library
*
* @return the classloader for this ant library
*/
private ClassLoader createLoader() {
ClassLoader ourParent
= extendsLibrary == null ? parentLoader
: extendsLibrary.getClassLoader();
return new URLClassLoader((URL[]) libraryURLs.toArray(new URL[0]),
ourParent);
}

}


+ 0
- 334
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrarySpec.java View File

@@ -1,334 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* This class represents the specification of an Ant library. It is merely
* the internal representation of the antlib XML definition. An instance of
* this class is used to contruct an AntLibrary instance.
*
* @author Conor MacNeill
* @created 13 January 2002
*/
public class AntLibrarySpec {
/**
* This is the globally unique name of this library. It uses the same
* conventions as the Java package space - i.e. reverse order DNS names
* This name is used when importing tasks from this library
*/
private String libraryId;

/**
* This string identifies the location where the library is maintained.
* It is usually a URL to the location from which the library may be
* downloaded or purchased
*/
private String libraryHome;

/** The list of converter classnames defined in this library */
private List converterClassNames = new ArrayList();

/** The list of aspect classnames defined in this library */
private List aspectClassNames = new ArrayList();

/** The name of the factory class for this library */
private String factoryClassName;

/**
* This is the optional id of another Ant library upon which this
* library depends.
*/
private String extendsLibraryId;

/** This is the URL from which this library has been loaded */
private URL libraryURL;

/** This is the list of definitions */
private Map definitions = new HashMap();

/** Indicates if each Task Instance should use its own classloader */
private boolean isolated = false;

/** Flag which indicates if tools.jar is required */
private boolean toolsJarRequired = false;

/**
* This flag indicates that this task processes XML and wishes to use
* the XML parser packaged with Ant
*/
private boolean requiresAntXMLParser = false;

/**
* Set the library that this library extends, if any
*
* @param extendsLibraryId The new ExtendsLibraryId value
*/
public void setExtendsLibraryId(String extendsLibraryId) {
this.extendsLibraryId = extendsLibraryId;
}

/**
* Sets the name of the factory class of the AntLibrarySpec
*
* @param className the new factory classname
*/
public void setFactory(String className) {
this.factoryClassName = className;
}

/**
* Indicate that this library requires a separate classloader per task
* instance
*
* @param isolated The new Isolated value
*/
public void setIsolated(boolean isolated) {
this.isolated = isolated;
}

/**
* Sets the home of the AntLibrary
*
* @param home The new home value
*/
public void setHome(String home) {
this.libraryHome = libraryHome;
}

/**
* Sets the libraryId of the AntLibrary
*
* @param libraryId The new libraryId value
*/
public void setLibraryId(String libraryId) {
this.libraryId = libraryId;
}


/**
* Indicate that this library uses the Sun tools.jar
*
* @param toolsJarRequired The new ToolsJarRequired value
*/
public void setToolsJarRequired(boolean toolsJarRequired) {
this.toolsJarRequired = toolsJarRequired;
}

/**
* Sets the libraryURL of the AntLibrary
*
* @param libraryURL The new libraryURL value
*/
public void setLibraryURL(URL libraryURL) {
this.libraryURL = libraryURL;
}

/**
* Indicates that this library uses Ant's XML parser libraries
*
* @param requiresAntXMLParser true if this library uses Ant's XML
* parser libraries
*/
public void setAntXML(boolean requiresAntXMLParser) {
this.requiresAntXMLParser = requiresAntXMLParser;
}

/**
* Get the list of converter classnames defined in this library spec
*
* @return the converter classnames list
*/
public List getConverters() {
return converterClassNames;
}


/**
* Get the list of aspect classnames defined in this library spec
*
* @return the aspect classnames list
*/
public List getAspects() {
return aspectClassNames;
}

/**
* Gets the factory classname of the AntLibrarySpec
*
* @return the factory classname
*/
public String getFactory() {
return factoryClassName;
}

/**
* Indicate whether this AntLibrary requires the Sun tools.jar
*
* @return The ToolsJarRequired value
*/
public boolean isToolsJarRequired() {
return toolsJarRequired;
}

/**
* Get the id of the library that this library extends if any.
*
* @return The ExtendsLibraryId value
*/
public String getExtendsLibraryId() {
return extendsLibraryId;
}

/**
* Indicate if this library required an classloader per instance
*
* @return true if a separate classloader should be used per instance.
*/
public boolean isIsolated() {
return isolated;
}


/**
* Gets the libraryId of the AntLibrary
*
* @return The libraryId value
*/
public String getLibraryId() {
return libraryId;
}

/**
* Gets the libraryURL of the AntLibrary
*
* @return The libraryURL value
*/
public URL getLibraryURL() {
return libraryURL;
}


/**
* Gets the definitions of the AntLibrarySpec
*
* @return the definitions map
*/
public Map getDefinitions() {
return definitions;
}

/**
* Add a converter to this library spec
*
* @param className the name of the converter class
*/
public void addConverter(String className) {
converterClassNames.add(className);
}

/**
* Add an aspect to this the library spec
*
* @param className the name of the aspect class
*/
public void addAspect(String className) {
aspectClassNames.add(className);
}

/**
* Indicates if this library requires Ant's XML parser
*
* @return true if this library requires Ant's XML parser
*/
public boolean usesAntXML() {
return requiresAntXMLParser;
}

/**
* Adds a definition to the Ant Library
*
* @param name the name of the library definition
* @param classname the name of the class implementing the element
* @param definitionTypeName the name of the definition type. This is
* converted to its symbolic value
* @exception AntLibException if the definition has already been defined
*/
public void addDefinition(String definitionTypeName, String name,
String classname)
throws AntLibException {
if (definitions.containsKey(name)) {
throw new AntLibException("More than one definition "
+ "in library for " + name);
}
int definitionType = 0;

if (definitionTypeName.equals("typedef")) {
definitionType = AntLibrary.TYPEDEF;
} else if (definitionTypeName.equals("taskdef")) {
definitionType = AntLibrary.TASKDEF;
} else {
throw new AntLibException("Unknown type of definition "
+ definitionTypeName);
}
definitions.put(name,
new AntLibDefinition(definitionType, name, classname));
}

}


+ 0
- 109
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/ClassNameHandler.java View File

@@ -1,109 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;

import org.apache.ant.antcore.xml.ElementHandler;
import org.xml.sax.SAXParseException;

/**
* Handler for elements which specify a class
*
* @author Conor MacNeill
*/
public class ClassNameHandler extends ElementHandler {
/** The classname attribute name */
public static final String CLASSNAME_ATTR = "classname";

/**
* Gets the className of the Converter
*
* @return the className value
*/
public String getClassName() {
return getAttribute(CLASSNAME_ATTR);
}

/**
* Process the definition element
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
if (getClassName() == null) {
throw new SAXParseException(CLASSNAME_ATTR + " must be "
+ "specified for a converter", getLocator());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
if (!attributeName.equals(CLASSNAME_ATTR)) {
throwInvalidAttribute(attributeName);
}
}
}



+ 0
- 106
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/ComponentLibrary.java View File

@@ -1,106 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.util.AntException;

/**
* A Component Library supplies components to the Ant core.
*
* @author Conor MacNeill
* @created 8 February 2002
*/
public interface ComponentLibrary {
/** constant indicating a taskdef definition */
public static final int TASKDEF = 1;
/** constant indicating a typedef definition */
public static final int TYPEDEF = 2;

/**
* Gets the ClassLoader of the AntLibrary
*
* @return The ClassLoader value
*/
ClassLoader getClassLoader();

/**
* Gat an instance of a factory object for creating objects in this
* library.
*
* @param context the context to use for the factory creation if
* required
* @return an instance of the factory, or null if this library does not
* support a factory
* @exception AntException if the factory cannot be created
*/
AntLibFactory getFactory(AntContext context) throws AntException;

/**
* Gets the libraryId of the AntLibrary
*
* @return the libraryId value
*/
String getLibraryId();

/**
* Get the definition of a particular component
*
* @param definitionName the name of the component within the library
* @return an AntLibDefinition instance with information about the
* component's definition
*/
AntLibDefinition getDefinition(String definitionName);
}


+ 0
- 144
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DefinitionHandler.java View File

@@ -1,144 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;

import org.apache.ant.antcore.xml.ElementHandler;
import org.xml.sax.SAXParseException;

/**
* Handler for definition within an Ant Library
*
* @author Conor MacNeill
* @created 13 January 2002
*/
public class DefinitionHandler extends ElementHandler {
/** The name attribute name */
public static final String NAME_ATTR = "name";

/** The classname attribute name */
public static final String CLASSNAME_ATTR = "classname";

/** the type of the definition */
private String definitionType;

/**
* Create a definition handler to handle a specific type of definition
*
* @param definitionType the type of the definition being handled
*/
public DefinitionHandler(String definitionType) {
this.definitionType = definitionType;
}

/**
* Get the type of definition being handled
*
* @return the type of the definition
*/
public String getDefinitionType() {
return definitionType;
}

/**
* Gets the name of the TaskdefHandler
*
* @return the name value
*/
public String getName() {
return getAttribute(NAME_ATTR);
}

/**
* Gets the className of the TaskdefHandler
*
* @return the className value
*/
public String getClassName() {
return getAttribute(CLASSNAME_ATTR);
}

/**
* Process the definition element
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
if (getName() == null || getClassName() == null) {
throw new SAXParseException("name and classname must be "
+ "specified for a " + definitionType, getLocator());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
if (!attributeName.equals(NAME_ATTR) &&
!attributeName.equals(CLASSNAME_ATTR)) {
throwInvalidAttribute(attributeName);
}
}
}



+ 0
- 166
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DynamicLibrary.java View File

@@ -1,166 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.antlib;
import java.util.HashMap;
import java.util.Map;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;

/**
* A dynamic library is created at runtime to hold newly defined components.
*
* @author Conor MacNeill
* @created 8 February 2002
*/
public class DynamicLibrary implements ComponentLibrary {
/** The name profix for naming dynamic libraries */
public static final String DYNAMIC_LIB_PREFIX = "_internal";
/** A static field used to uniquely name dynamic libraries */
private static int dynamicIdCounter = 0;

/**
* the factory this dynamic library will use to create instances of its
* components
*/
private AntLibFactory factory;
/**
* the classloader that will be used to create new instances of the
* library's components
*/
private ClassLoader loader;
/** the library's unique id */
private String libraryId;
/**
* the component definitions of this library. This map contains
* AntLibDefinition instances indexed on the definition names.
*/
private Map definitions = new HashMap();


/**
* Constructor for the DynamicLibrary object
*
* @param factory the factory to use to create instances. May be null
* @param loader the loader to use to load the instance classes
*/
public DynamicLibrary(AntLibFactory factory, ClassLoader loader) {
int dynamicId = 0;
synchronized (DynamicLibrary.class) {
dynamicId = dynamicIdCounter;
dynamicIdCounter++;
}
this.libraryId = DYNAMIC_LIB_PREFIX + dynamicId;
this.loader = loader;
this.factory = factory;
}

/**
* Gets the ClassLoader of the AntLibrary
*
* @return The ClassLoader value
*/
public ClassLoader getClassLoader() {
return loader;
}

/**
* Gat an instance of a factory object for creating objects in this
* library.
*
* @param context the context to use for the factory creation if
* required
* @return an instance of the factory, or null if this library does not
* support a factory
*/
public AntLibFactory getFactory(AntContext context) {
return factory;
}

/**
* Gets the libraryId of the AntLibrary
*
* @return the libraryId value
*/
public String getLibraryId() {
return libraryId;
}

/**
* Get the definition of a particular component
*
* @param definitionName the name of the component within the library
* @return an AntLibDefinition instance with information about the
* component's definition
*/
public AntLibDefinition getDefinition(String definitionName) {
return (AntLibDefinition) definitions.get(definitionName);
}

/**
* Add a new component definition to this library
*
* @param componentType the type of the component
* @param componentName the name of the component
* @param componentClassName the component's class
*/
public void addComponent(int componentType, String componentName,
String componentClassName) {
AntLibDefinition newDefinition
= new AntLibDefinition(componentType, componentName,
componentClassName);

definitions.put(componentName, newDefinition);
}
}


+ 0
- 222
proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java View File

@@ -1,222 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.config;
import java.util.Iterator;
import org.apache.ant.common.model.BuildElement;

/**
* An AntConfig is the java class representation of the antconfig.xml files
* used to configure Ant.
*
* @author Conor MacNeill
* @created 20 January 2002
*/
public class AntConfig {
/** Indicates if remote libraries may be used */
private boolean remoteLibs = false;

/** Indicates if remote projects may be used */
private boolean remoteProjects = false;

/** Indicates if unset properties are ignored */
private boolean unsetProperties = true;

/**
* Global Configuration tasks. These are run only once.
*/
private BuildElement globalTasks;

/**
* Frame tasks - these are run in each new frame.
*/
private BuildElement frameTasks;

/**
* Indicate if unset properties are OK.
*
* @return true if unset properties will not cause an exception
*/
public boolean isUnsetPropertiesAllowed() {
return unsetProperties;
}

/**
* Indicate if the use of remote library's is allowe dby this config.
*
* @return true if this config allows the use of remote libraries,
*/
public boolean isRemoteLibAllowed() {
return remoteLibs;
}

/**
* Indicate if this config allows the execution of a remote project
*
* @return true if remote projects are allowed
*/
public boolean isRemoteProjectAllowed() {
return remoteProjects;
}

/**
* Get the global configuration tasks
*
* @return an iterator over the set of config tasks.
*/
public Iterator getGlobalTasks() {
if (globalTasks == null) {
return null;
}
return globalTasks.getNestedElements();
}

/**
* Get the per-frame configuration tasks
*
* @return an iterator over the set of config tasks.
*/
public Iterator getFrameTasks() {
if (frameTasks == null) {
return null;
}
return frameTasks.getNestedElements();
}

/**
* Add a global config task.
*
* @param globalTasks a collection of tasks to be executed as part of
* the configuration process.
*/
public void addGlobalTasks(BuildElement globalTasks) {
this.globalTasks = globalTasks;
}

/**
* Add a per-frame config task.
*
* @param frameTasks a collection of tasks to be executed as part of the
* setup of each new frame.
*/
public void addFrameTasks(BuildElement frameTasks) {
this.frameTasks = frameTasks;
}

/**
* Allow remote libraries to be used
*
* @param allowRemoteLibs true if remote libraries may be used.
*/
public void allowRemoteLibs(boolean allowRemoteLibs) {
this.remoteLibs = allowRemoteLibs;
}

/**
* Allow remote projects to be used
*
* @param allowRemoteProjects true if remote projects may be executed.
*/
public void allowRemoteProjects(boolean allowRemoteProjects) {
this.remoteProjects = allowRemoteProjects;
}

/**
* Allow properties to be used even when they have not been set
*
* @param allowUnsetProperties true if un set properties should not
* cause an exception
*/
public void allowUnsetProperties(boolean allowUnsetProperties) {
this.unsetProperties = allowUnsetProperties;
}

/**
* Merge in another configuration. The configuration being merged in
* takes precedence
*
* @param otherConfig the other AntConfig to be merged.
*/
public void merge(AntConfig otherConfig) {
remoteLibs = otherConfig.remoteLibs;
remoteProjects = otherConfig.remoteProjects;
unsetProperties = otherConfig.unsetProperties;
globalTasks = combineTasks(globalTasks, otherConfig.globalTasks);
frameTasks = combineTasks(frameTasks, otherConfig.frameTasks);
}

/**
* Combine two task collections
*
* @param lhs the lefthand collection
* @param rhs the right hand collection
*
* @return the combined collection of tasks
*/
private BuildElement combineTasks(BuildElement lhs, BuildElement rhs) {
if (rhs == null) {
return lhs;
}

if (lhs == null) {
return rhs;
}

for (Iterator i = rhs.getNestedElements(); i.hasNext();) {
lhs.addNestedElement((BuildElement) i.next());
}

return lhs;
}
}


+ 0
- 169
proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfigHandler.java View File

@@ -1,169 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.config;
import org.apache.ant.antcore.xml.ElementHandler;
import org.apache.ant.antcore.modelparser.BuildElementHandler;
import org.apache.ant.common.model.BuildElement;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;

/**
* XML Element Handler for Ant config files
*
* @author Conor MacNeill
* @created 20 January 2002
*/
public class AntConfigHandler extends ElementHandler {
/** The allowRemoteProject attribute name */
public static final String REMOTE_PROJECT_ATTR = "allow-remote-project";

/** The allowRemoteLibrary attribute name */
public static final String REMOTE_LIBRARY_ATTR = "allow-remote-library";

/** The allowReportProject attribute name */
public static final String UNSET_PROPS_ATTR = "allow-unset-properties";

/** The global tasks element */
public static final String GLOBAL_TASKS_ELEMENT = "global-tasks";

/** The per-frame tasks element */
public static final String PERFRAME_TASKS_ELEMENT = "project-tasks";

/** The list of allowed Attributes */
public static final String[] ALLOWED_ATTRIBUTES
= {REMOTE_PROJECT_ATTR, REMOTE_LIBRARY_ATTR, UNSET_PROPS_ATTR};
/**
* The config object which is contructed from the XML representation of
* the config
*/
private AntConfig config;

/**
* Get the Ant Config read in by this handler
*
* @return the AntConfig instance
*/
public AntConfig getAntConfig() {
return config;
}

/**
* Process the antlib element
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
config = new AntConfig();
config.allowRemoteLibs(getBooleanAttribute(REMOTE_LIBRARY_ATTR));
config.allowRemoteProjects(getBooleanAttribute(REMOTE_PROJECT_ATTR));
boolean allowUnsetProperties = true;
if (getAttribute(UNSET_PROPS_ATTR) != null) {
allowUnsetProperties = getBooleanAttribute(UNSET_PROPS_ATTR);
}
config.allowUnsetProperties(allowUnsetProperties);
}

/**
* Start a new element in the ant config.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {

// configs support two task collections as elements
BuildElementHandler buildElementHandler = new BuildElementHandler();
buildElementHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
BuildElement element = buildElementHandler.getBuildElement();
if (element.getType().equals(GLOBAL_TASKS_ELEMENT)) {
config.addGlobalTasks(element);
} else if (element.getType().equals(PERFRAME_TASKS_ELEMENT)) {
config.addFrameTasks(element);
} else {
throw new SAXParseException("<antconfig> does not support the <"
+ element.getType() + "> element", getLocator());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
for (int i = 0; i < ALLOWED_ATTRIBUTES.length; ++i) {
if (attributeName.equals(ALLOWED_ATTRIBUTES[i])) {
return;
}
}
throwInvalidAttribute(attributeName);
}
}



+ 0
- 176
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/AttributeSetter.java View File

@@ -1,176 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.ant.common.antlib.Converter;
import org.apache.ant.common.util.AntException;

/**
* AttributeSetters are created at introspection time for each
* setter method a class provides and for which a conversion from a
* String value is available.
*
* @author Conor MacNeill
* @created 19 January 2002
*/
public class AttributeSetter {
/** The method that will perform the setting */
private Method method;

/**
* A converter to convert the string value to a value to be given to
* the setter method
*/
private Converter converter;

/**
* A constructor used to create the string value to an object to be used
* by the setter
*/
private Constructor valueConstructor;

/** The depth of the setter in the class hierarchy */
private int depth;

/**
* Create a setter which just uses string values
*
* @param method the method to be invoked.
* @param depth the depth of this method declaraion in the class hierarchy.
*/
public AttributeSetter(Method method, int depth) {
this.method = method;
this.depth = depth;
}

/**
* Create a setter which just uses string values
*
* @param method the method to be invoked.
* @param depth the depth of this method declaraion in the class hierarchy.
* @param converter a converter to convert string values into instances of
* the type expected by the method.
*/
public AttributeSetter(Method method, int depth, Converter converter) {
this(method, depth);
this.converter = converter;
}

/**
* Create a setter which just uses string values
*
* @param method the method to be invoked.
* @param depth the depth of this method declaraion in the class hierarchy.
* @param valueConstructor an object constructor used to convert string
* values into instances of the type expected by the method.
*/
public AttributeSetter(Method method, int depth,
Constructor valueConstructor) {
this(method, depth);
this.valueConstructor = valueConstructor;
}

/**
* Set the attribute value on an object
*
* @param obj the object on which the set method is to be invoked
* @param stringValue the string representation of the value
* @exception InvocationTargetException if the method cannot be
* invoked
* @exception IllegalAccessException if the method cannot be invoked
* @exception AntException if the conversion of the value
* fails
*/
void set(Object obj, String stringValue)
throws InvocationTargetException, IllegalAccessException,
AntException {

Object value = null;
if (converter != null) {
Class type = getType();
value = converter.convert(stringValue, type);
} else if (valueConstructor != null) {
try {
value = valueConstructor.newInstance(new String[]{stringValue});
} catch (InstantiationException e) {
throw new ExecutionException(e);
}
} else {
value = stringValue;
}

method.invoke(obj, new Object[]{value});
}

/**
* Get the declaration depth of this setter.
*
* @return the attribute setter's declaration depth.
*/
public int getDepth() {
return depth;
}

/**
* Get the type expected by this setter's method
*
* @return a Class instance being the type this setter's method accepts.
*/
public Class getType() {
return method.getParameterTypes()[0];
}
}


+ 0
- 257
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/BuildEventSupport.java View File

@@ -1,257 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.event.BuildEvent;
import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.model.ModelElement;
import org.apache.ant.common.util.DemuxOutputReceiver;
import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.util.AntException;

/**
* BuildEventSupport is used by classes which which to send build events to
* the BuildListeners
*
* @author Conor MacNeill
* @created 15 January 2002
*/
public class BuildEventSupport implements DemuxOutputReceiver {
/**
* The listeners attached to the object which contains this support
* object
*/
private ArrayList listeners = new ArrayList();

/** Records the latest task to be executed on a thread (Thread to Task). */
private Map threadTasks = new HashMap();

/**
* Gets the listeners of the BuildEventSupport
*
* @return the listeners value
*/
public List getListeners() {
return (List) listeners.clone();
}

/**
* Add a listener
*
* @param listener the listener to be added
*/
public void addBuildListener(BuildListener listener) {
listeners.add(listener);
}

/**
* Remove a listener
*
* @param listener the listener to be removed
*/
public void removeBuildListener(BuildListener listener) {
listeners.remove(listener);
}

/**
* Fire a build started event
*
* @param element the build element with which the event is associated
*/
public void fireBuildStarted(ModelElement element) {
BuildEvent event = new BuildEvent(element, BuildEvent.BUILD_STARTED);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.buildStarted(event);
}
}

/**
* Fir a build finished event
*
* @param element the build element with which the event is associated
* @param cause an exception if there was a failure in the build
*/
public void fireBuildFinished(ModelElement element,
Throwable cause) {
BuildEvent event = new BuildEvent(element, BuildEvent.BUILD_FINISHED,
cause);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.buildFinished(event);
}
}

/**
* fire a target started event
*
* @param element the build element with which the event is associated
*/
public void fireTargetStarted(ModelElement element) {
BuildEvent event = new BuildEvent(element, BuildEvent.TARGET_STARTED);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.targetStarted(event);
}
}

/**
* fire a target finished event
*
* @param element the build element with which the event is associated
* @param cause an exception if there was a failure in the target's task
*/
public void fireTargetFinished(ModelElement element,
Throwable cause) {
BuildEvent event = new BuildEvent(element, BuildEvent.TARGET_FINISHED,
cause);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.targetFinished(event);
}
}

/**
* fire a task started event
*
* @param task the task with which the event is associated
*/
public void fireTaskStarted(Task task) {
synchronized (this) {
threadTasks.put(Thread.currentThread(), task);
}
BuildEvent event = new BuildEvent(task, BuildEvent.TASK_STARTED);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.taskStarted(event);
}
}

/**
* fire a task finished event
*
* @param task the task with which the event is associated
* @param cause an exception if there was a failure in the task
*/
public void fireTaskFinished(Task task,
Throwable cause) {
System.out.flush();
System.err.flush();
synchronized (this) {
threadTasks.remove(Thread.currentThread());
}
BuildEvent event = new BuildEvent(task, BuildEvent.TASK_FINISHED,
cause);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.taskFinished(event);
}
}

/**
* Send a message event
*
* @param source the build element with which the event is associated
* @param message the message to be sent
* @param priority the priority of the message
*/
public void fireMessageLogged(Object source,
String message, int priority) {
BuildEvent event = new BuildEvent(source, message, priority);
List listeners = getListeners();
for (Iterator i = listeners.iterator(); i.hasNext();) {
BuildListener listener = (BuildListener) i.next();
listener.messageLogged(event);
}
}

/**
* Demultiplexes output so that each task receives the appropriate
* messages. If the current thread is not currently executing a task,
* the message is logged directly.
*
* @param line Message to handle. Should not be <code>null</code>.
* @param isError Whether the text represents an error (<code>true</code>
* ) or information (<code>false</code>).
*/
public void threadOutput(String line, boolean isError) {
Task task = (Task) threadTasks.get(Thread.currentThread());
if (task != null) {
try {
if (isError) {
task.handleSystemErr(line);
} else {
task.handleSystemOut(line);
}
return;
} catch (AntException e) {
// ignore just log as a non-task message
}
}
fireMessageLogged(this, line,
isError ? MessageLevel.ERROR : MessageLevel.INFO);
}
}


+ 0
- 171
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ClassIntrospector.java View File

@@ -1,171 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.HashMap;

/**
* Introspects a class and builds a reflector for setting values on
* instances of the class
*
* @author Conor MacNeill
* @created 19 January 2002
*/
public class ClassIntrospector {
/** The reflector that this introspector populates */
private Reflector reflector;

/**
* A Map which maps the classnames to their depth in the class hiearchy,
* with the current class being depth=0
*/
private Map classDepth = new HashMap();

/**
* Determine the class hierarchy depths for the given class.
*
* @param bean the class for which the class depths will be determined.
*/
private void getDepths(Class bean) {
Class currentClass = bean;
int index = 0;
while (currentClass != null) {
classDepth.put(currentClass, new Integer(index++));
currentClass = currentClass.getSuperclass();
}
}
/**
* Create a introspector for the bean
*
* @param bean the class which is introspected
* @param converters a collection of converters for converting values
* from strings
*/
public ClassIntrospector(final Class bean, Map converters) {
reflector = new Reflector();
getDepths(bean);

Method[] methods = bean.getMethods();
for (int i = 0; i < methods.length; i++) {
final Method m = methods[i];
final String name = m.getName();
Class returnType = m.getReturnType();
Class[] args = m.getParameterTypes();

if (name.equals("addText")
&& returnType.equals(Void.TYPE)
&& args.length == 1
&& args[0].equals(String.class)) {
reflector.setAddTextMethod(m);
} else if (name.startsWith("set")
&& name.length() > 3
&& returnType.equals(Void.TYPE)
&& args.length == 1
&& !args[0].isArray()) {
Integer depth = (Integer) classDepth.get(m.getDeclaringClass());
reflector.addAttributeMethod(m, depth.intValue(),
getPropertyName(name, "set"), converters);
} else if (name.startsWith("addConfigured")
&& name.length() > 13
&& returnType.equals(Void.TYPE)
&& args.length == 1
&& !args[0].equals(String.class)
&& !args[0].isArray()
&& !args[0].isPrimitive()) {
reflector.addElementMethod(m,
getPropertyName(name, "addConfigured"));
} else if (name.startsWith("add")
&& name.length() > 3
&& returnType.equals(Void.TYPE)
&& args.length == 1
&& !args[0].equals(String.class)
&& !args[0].isArray()
&& !args[0].isPrimitive()) {
reflector.addElementMethod(m, getPropertyName(name, "add"));
} else if (name.startsWith("create")
&& name.length() > 6
&& !returnType.isArray()
&& !returnType.isPrimitive()
&& args.length == 0) {
reflector.addCreateMethod(m, getPropertyName(name, "create"));
}
}
}

/**
* Gets the reflector associed with the class we are introspecting
*
* @return the reflector
*/
public Reflector getReflector() {
return reflector;
}

/**
* extract the name of a property from a method name - subtracting a
* given prefix.
*
* @param methodName the name of the method
* @param prefix the prefix to be ignored
* @return the property name
*/
private String getPropertyName(String methodName, String prefix) {
int start = prefix.length();
return methodName.substring(start).toLowerCase();
}
}


+ 0
- 1048
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
File diff suppressed because it is too large
View File


+ 0
- 66
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Constants.java View File

@@ -1,66 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;

/**
* Core constants
*
* @author Conor MacNeill
* @created 20 February 2002
*/
public abstract class Constants {
/** The prefix for library ids that are automatically imported */
public static final String ANT_LIB_PREFIX = "ant.";
}


+ 0
- 525
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreDataService.java View File

@@ -1,525 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.model.Project;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.DataValue;
import org.apache.ant.common.util.PropertyUtils;

/**
* This is the core's implementation of the DataService service interface. It
* gives Ant libraries access to property values maintained in the Frame.
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class CoreDataService implements DataService {

/** The Frame this service instance is working for */
private Frame frame;

/** all properties to be unset without throwing an exception */
private boolean allowUnsetProperties;

/**
* The context of this execution. This contains all data object's created
* by tasks that have been executed
*/
private Map dataValues = new HashMap();

/**
* The property overrides for the referenced frames. This map is indexed
* by the reference names of the frame. Each entry is another Map of
* property values indexed by their relative name.
*/
private Map overrides = new HashMap();

/**
* Constructor
*
* @param frame the frame containing this context
* @param allowUnsetProperties true if the reference to an unset property
* should not throw an exception
*/
protected CoreDataService(Frame frame,
boolean allowUnsetProperties) {
this.frame = frame;
this.allowUnsetProperties = allowUnsetProperties;
}

/**
* Get the Data service of a frame
*
* @param frame the frame whose data service is required.
* @return the frame's data service.
* @exception ExecutionException if the frame's data service cannot be
* retrieved.
*/
private DataService getFrameDataService(Frame frame)
throws ExecutionException {
return (DataService) frame.getCoreService(DataService.class);
}

/**
* Update a DataValue in a repository.
*
* The value is only updated if it is a higher priority than any existing
* values or the same priority and the mutable flag is set.
*
* @param repository the repository containing the values.
* @param key the key under which the value is to be stored.
* @param value the data vale instance
* @param mutable true if a value of equal priority can be overwritten.
*/
private void updateValue(Map repository, String key,
DataValue value, boolean mutable) {
int priority = value.getPriority();
DataValue currentDataValue = (DataValue) repository.get(key);
if (currentDataValue != null) {
int currentPriority = currentDataValue.getPriority();
if (currentPriority > priority
|| (currentPriority == priority && !mutable)) {
frame.log("Ignoring override for data value " + key,
MessageLevel.VERBOSE);
return;
}
}
repository.put(key, value);
}

/**
* Set a value in this frame or any of its imported frames.
*
* @param name the name of the value
* @param value the actual value
* @param mutable if true, existing values can be changed
* @exception AntException if the value cannot be set.
*/
public void setDataValue(String name, DataValue value, boolean mutable)
throws AntException {
Frame containingFrame = frame.getContainingFrame(name);

if (containingFrame == null) {
setOverrideProperty(name, value, mutable);
return;
}

String localName = frame.getNameInFrame(name);
if (containingFrame == frame) {
updateValue(dataValues, localName, value, mutable);
} else {
DataService actualDataService = getFrameDataService(containingFrame);
actualDataService.setDataValue(localName, value, mutable);
}
}

/**
* When a frame has not yet been referenced, this method is used to set
* the initial properties for the frame when it is introduced.
*
* @param name the name of the value
* @param value the actual value
* @param mutable if true, existing values can be changed
* @exception ExecutionException if attempting to override a property in
* the current frame.
*/
private void setOverrideProperty(String name, DataValue value,
boolean mutable)
throws ExecutionException {
int refIndex = name.indexOf(Project.REF_DELIMITER);
if (refIndex == -1) {
throw new ExecutionException("Property overrides can only be set"
+ " for properties in referenced projects - not "
+ name);
}

String firstFrameName = name.substring(0, refIndex);

String relativeName
= name.substring(refIndex + Project.REF_DELIMITER.length());

Map frameOverrides = (Map) overrides.get(firstFrameName);
if (frameOverrides == null) {
frameOverrides = new HashMap();
overrides.put(firstFrameName, frameOverrides);
}

updateValue(frameOverrides, relativeName, value, mutable);
}


/**
* Get a data value
*
* @param name the name of the data value
* @return the current object associated with the name or null if no value
* is currently associated with the name
* @exception AntException if the value cannot be retrieved.
*/
public Object getDataValue(String name) throws AntException {
Frame containingFrame = frame.getContainingFrame(name);

if (containingFrame == null) {
return getOverrideProperty(name);
}
if (containingFrame == frame) {
DataValue dataValue = (DataValue) dataValues.get(name);
if (dataValue == null) {
return null;
}
return dataValue.getValue();
} else {
String localName = frame.getNameInFrame(name);
DataService actualDataService = getFrameDataService(containingFrame);
return actualDataService.getDataValue(localName);
}
}

/**
* Indicate if a data value has been set
*
* @param name the name of the data value - may contain reference
* delimiters
* @return true if the value exists
* @exception AntException if the data value cannot be accessed.
*/
public boolean isDataValueSet(String name) throws AntException {
Frame containingFrame = frame.getContainingFrame(name);

if (containingFrame == null) {
return isOverrideSet(name);
}
if (containingFrame == frame) {
return dataValues.containsKey(name);
} else {
String localName = frame.getNameInFrame(name);
DataService actualDataService = getFrameDataService(containingFrame);
return actualDataService.isDataValueSet(localName);
}
}

/**
* Get all the data values from the frame and any referenced frames. This
* is an expensive operation since it must clone all of the property
* stores in all frames
*
* @return a Map containing the frames data values indexed by their full
* name.
* @exception AntException if the values cannot be retrieved.
*/
public Map getAllDataValues() throws AntException {
Map allValues = new HashMap();
mergeDataValues(allValues, dataValues);

// add in values from sub frames
for (Iterator i = frame.getRefNames(); i.hasNext();) {
String refName = (String) i.next();
Frame refFrame = frame.getReferencedFrame(refName);

DataService refDataService = getFrameDataService(refFrame);
Map refValues = refDataService.getAllDataValues();
Iterator j = refValues.keySet().iterator();

while (j.hasNext()) {
String name = (String) j.next();
DataValue value = (DataValue) refValues.get(name);
updateValue(allValues, refName + Project.REF_DELIMITER + name,
value, false);
}
}

// add in values from overrides which have not yet been activated
for (Iterator i = overrides.keySet().iterator(); i.hasNext();) {
String refName = (String) i.next();
Map refOverrides = (Map) overrides.get(refName);
for (Iterator j = refOverrides.keySet().iterator(); j.hasNext();) {
String name = (String) j.next();
DataValue value = (DataValue) refOverrides.get(name);
updateValue(allValues, refName + Project.REF_DELIMITER + name,
value, false);
}
}

return allValues;
}


/**
* Replace ${} style constructions in the given value with the string
* value of the corresponding data values in the frame
*
* @param value the string to be scanned for property references.
* @return the string with all property references replaced
* @exception AntException if any of the properties do not exist
*/
public String replacePropertyRefs(String value)
throws AntException {
if (value == null) {
return null;
}

List fragments = new ArrayList();
List propertyRefs = new ArrayList();
PropertyUtils.parsePropertyString(value, fragments, propertyRefs);

StringBuffer sb = new StringBuffer();
Iterator i = fragments.iterator();
Iterator j = propertyRefs.iterator();
while (i.hasNext()) {
String fragment = (String) i.next();
if (fragment == null) {
String propertyName = (String) j.next();
if (!isDataValueSet(propertyName)) {
if (!allowUnsetProperties) {
throw new ExecutionException("Property \""
+ propertyName + "\" has not been set");
}
fragment = "${" + propertyName + "}";
} else {
fragment = getDataValue(propertyName).toString();
}
}
sb.append(fragment);
}

return sb.toString();
}

/**
* Replace ${} style constructions in the given value with the string
* value of the objects in the given map. Any values which are not found
* are left unchanged.
*
* @param value the string to be scanned for property references.
* @param replacementValues the collection of replacement values
* @return the string with all property references replaced
* @exception AntException if any of the properties do not exist
*/
public String replacePropertyRefs(String value, Map replacementValues)
throws AntException {
if (value == null) {
return null;
}

List fragments = new ArrayList();
List propertyRefs = new ArrayList();
PropertyUtils.parsePropertyString(value, fragments, propertyRefs);

StringBuffer sb = new StringBuffer();
Iterator i = fragments.iterator();
Iterator j = propertyRefs.iterator();
while (i.hasNext()) {
String fragment = (String) i.next();
if (fragment == null) {
String propertyName = (String) j.next();
if (!replacementValues.containsKey(propertyName)) {
fragment = "${" + propertyName + "}";
} else {
fragment
= replacementValues.get(propertyName).toString();
}
}
sb.append(fragment);
}

return sb.toString();
}

/**
* Get the data value overrides associated with a given reference name.
*
* @param refName The name of the reference for which overriding datavalues
* are required.
* @return The map of named DataValue instances.
*/
protected Map getOverrides(String refName) {
return (Map) overrides.get(refName);
}

/**
* Remove the override values associated with a given reference name.
*
* @param refName The name of the reference for which overriding datavalues
* are required.
*/
protected void removeOverrides(String refName) {
overrides.remove(refName);
}

/**
* Get a value which exists in the frame property overrides awaiting the
* frame to be introduced.
*
* @param name the name of the value
* @return the value of the property or null if the property does not
* exist.
* @exception ExecutionException if attempting to get an override in the
* current frame.
*/
private Object getOverrideProperty(String name) throws ExecutionException {
int refIndex = name.indexOf(Project.REF_DELIMITER);
if (refIndex == -1) {
throw new ExecutionException("Property overrides can only be"
+ " returned for properties in referenced projects - not "
+ name);
}

String firstFrameName = name.substring(0, refIndex);

String relativeName
= name.substring(refIndex + Project.REF_DELIMITER.length());

Map frameOverrides = (Map) overrides.get(firstFrameName);
if (frameOverrides == null) {
return null;
}

return frameOverrides.get(relativeName);
}

/**
* Get a value which exists in the frame property overrides awaiting the
* frame to be introduced.
*
* @param name the name of the value
* @return the value of the property or null if the property does not
* exist.
* @exception ExecutionException if attempting to check an override in the
* current frame.
*/
private boolean isOverrideSet(String name) throws ExecutionException {
int refIndex = name.indexOf(Project.REF_DELIMITER);
if (refIndex == -1) {
throw new ExecutionException("Property overrides can only be"
+ " returned for properties in referenced projects - not "
+ name);
}

String firstFrameName = name.substring(0, refIndex);

String relativeName
= name.substring(refIndex + Project.REF_DELIMITER.length());

Map frameOverrides = (Map) overrides.get(firstFrameName);
if (frameOverrides == null) {
return false;
}

return frameOverrides.containsKey(relativeName);
}


/**
* Add a collection of properties to this frame with a given priority.
*
* @param properties the collection of property values, indexed by their
* names
* @param priority the priority at which the values are added.
* @exception AntException if the values cannot be added.
*/
protected void addProperties(Map properties, int priority)
throws AntException {
addDataValues(DataValue.makeDataValues(properties, priority));
}

/**
* Add a set of data values.
*
* @param dataValues a collection of DataValue instances named
* @exception AntException if the values cannot be added.
*/
protected void addDataValues(Map values) throws AntException {
mergeDataValues(dataValues, values);
}

/**
* Merge one set of values into another
*
* @param values the values to which the new values are added
* @param newValues the values to be added in.
*/
public void mergeDataValues(Map values, Map newValues) {
mergeDataValues(values, newValues, DataValue.PRIORITY_BASE);
}

/**
* Merge in values which are of a given priority or higher.
*
* @param values the values to which the new values are added
* @param newValues the values to be added in.
* @param threshold The require data value priority for a value to be
* merged.
*/
public void mergeDataValues(Map values, Map newValues, int threshold) {
if (newValues == null) {
return;
}

for (Iterator i = newValues.keySet().iterator(); i.hasNext();) {
String name = (String) i.next();
DataValue value = (DataValue) newValues.get(name);
if (value.getPriority() >= threshold) {
updateValue(values, name, value, false);
}
}
}
}


+ 0
- 99
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreEventService.java View File

@@ -1,99 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.service.EventService;

/**
* Core implementation of the event service
*
* @author Conor MacNeill
* @created 7 February 2002
*/
public class CoreEventService implements EventService {
/** The Frame this service instance is working for */
private Frame frame;

/**
* Constructor
*
* @param frame the frame for which this instance is providing service
*/
protected CoreEventService(Frame frame) {
this.frame = frame;
}

/**
* Add a build listener to the current frame
*
* @param listener the lister which will receive build events
* @exception ExecutionException if the listener cannot be added
*/
public void addBuildListener(BuildListener listener)
throws ExecutionException {
frame.addBuildListener(listener);
}

/**
* Remove a listener from the current frame
*
* @param listener the listener to be removed
* @exception ExecutionException if the listener could not be removed
*/
public void removeBuildListener(BuildListener listener)
throws ExecutionException {
frame.removeBuildListener(listener);
}
}


+ 0
- 311
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreExecService.java View File

@@ -1,311 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
import org.apache.ant.antcore.modelparser.XMLProjectParser;
import org.apache.ant.antcore.xml.XMLParseException;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.model.Project;
import org.apache.ant.common.model.BuildElement;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.init.InitUtils;
import org.apache.ant.common.model.NamespaceValueCollection;
import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.util.AntException;

/**
* This is the core's implementation of the Execution Service.
*
* @author Conor MacNeill
* @created 8 February 2002
*/
public class CoreExecService implements ExecService {

/** The Frame this service instance is working for */
private Frame frame;

/**
* Constructor
*
* @param frame the frame containing this context
*/
protected CoreExecService(Frame frame) {
this.frame = frame;
}


/**
* Execute a task. The task should have already been initialised by the
* core. This is checked
*
* @param task the task to be executed
* @exception AntException if there is an execution problem
*/
public void executeTask(Task task) throws AntException {
ExecutionContext execContext = getTaskExecutionContext(task);

BuildElement model = execContext.getModel();
NamespaceValueCollection namespaceValues = null;
if (model != null) {
namespaceValues = model.getNamespaceAttributes();
}
frame.executeTask(task, namespaceValues);
}

/**
* Retrieve the execution context from a task and verify that the context
* is valid.
*
* @param task the task.
* @return the task's execution context.
*
* @exception ExecutionException if the task's context is not valid.
*/
private ExecutionContext getTaskExecutionContext(Task task)
throws ExecutionException {
AntContext context = task.getAntContext();

if (!(context instanceof ExecutionContext)) {
throw new ExecutionException("The Task was not configured with an"
+ " appropriate context");
}
return (ExecutionContext) context;
}

/**
* Execute a task with a set of aspect values. Normally aspect values come
* from a build model but not all tasks will be created from a build model.
* Some may be created dynamically and configured programatically. This
* method allows aspect values to provided for execution of such tasks since
* by their nature, aspect values are not part of the task configuration.
*
* @param task the task to be executed
* @param aspectValues the aspect attribute values.
* @exception AntException if there is an execution problem
*/
public void executeTask(Task task, NamespaceValueCollection aspectValues)
throws AntException {
ExecutionContext execContext = getTaskExecutionContext(task);

frame.executeTask(task, aspectValues);
}

/**
* Get the base directory for this execution of this frame
*
* @return the base directory
*/
public File getBaseDir() {
return frame.getBaseDir();
}

/**
* Set the basedir for the current execution
*
* @param baseDir the new base directory for this execution of Ant
*
* @exception AntException if the baseDir cannot be set to the given value.
*/
public void setBaseDir(File baseDir) throws AntException {
frame.setBaseDir(baseDir);
}


/**
* get the name of the project associated with this execution.
*
* @return the project's name
*/
public String getProjectName() {
return frame.getProjectName();
}


/**
* Handle subbuild output.
*
* @param subbuildKey the core's key for managing the subbuild.
* @param line the content produce by the current thread.
* @param isErr true if this content is from the thread's error stream.
* @exception ExecutionException if the subbuild cannot be found.
*/
public void handleBuildOutput(Object subbuildKey, String line,
boolean isErr) throws ExecutionException {
Frame subFrame = (Frame) subbuildKey;
subFrame.threadOutput(line, isErr);
}


/**
* Force initialisation of a particular ant library in the context of the
* given subbuild.
*
* @param key the build key.
* @param libraryId the id of the library to be initialized.
* @exception AntException if the build cannot be run
*/
public void initializeBuildLibrary(Object key, String libraryId)
throws AntException {
Frame subFrame = (Frame) key;
subFrame.initializeLibrary(libraryId);
}

/**
* Add a listener to a subbuild
*
* @param key the key identifying the build previously setup
* @param listener the listener to add to the build.
*
* @exception ExecutionException if the build cannot be found.
*/
public void addBuildListener(Object key, BuildListener listener)
throws ExecutionException {
Frame subFrame = (Frame) key;
subFrame.addBuildListener(listener);
}


/**
* Run a build which have been previously setup
*
* @param targets A list of targets to be run
* @param key Description of the Parameter
* @exception AntException if the build cannot be run
*/
public void runBuild(Object key, List targets) throws AntException {
Frame subFrame = (Frame) key;
subFrame.runBuild(targets);
}


/**
* Parse an XML file into a build model.
*
* @param xmlBuildFile The file containing the XML build description.
* @return A Project model for the build.
* @exception ExecutionException if the build cannot be parsed
*/
public Project parseXMLBuildFile(File xmlBuildFile)
throws ExecutionException {
try {
// Parse the build file into a project
XMLProjectParser parser = new XMLProjectParser();

return parser.parseBuildFile(InitUtils.getFileURL(xmlBuildFile));
} catch (MalformedURLException e) {
throw new ExecutionException(e);
} catch (XMLParseException e) {
throw new ExecutionException(e);
}
}


/**
* Create a project reference.
*
* @param referenceName the name under which the project will be
* referenced.
* @param model the project model.
* @param initialData the project's initial data load.
* @exception AntException if the project cannot be referenced.
*/
public void createProjectReference(String referenceName, Project model,
Map initialData)
throws AntException {
frame.createProjectReference(referenceName, model, initialData);
}


/**
* Setup a sub-build.
*
* @param model the project model to be used for the build
* @param dataValues the initial data values to be used in the build
* @param addListeners true if the current frame's listeners should be
* added to the created Frame
* @return Description of the Return Value
* @exception AntException if the subbuild cannot be run
*/
public Object setupBuild(Project model, Map dataValues,
boolean addListeners)
throws AntException {
Frame newFrame = frame.createFrame(model);
if (addListeners) {
frame.addListeners(newFrame);
}
newFrame.initialize(dataValues);

return newFrame;
}


/**
* Setup a sub-build using the current frame's project model
*
* @param dataValues the initial properties to be used in the build
* @param addListeners true if the current frame's listeners should be
* added to the created Frame
* @return Description of the Return Value
* @exception AntException if the subbuild cannot be run
*/
public Object setupBuild(Map dataValues, boolean addListeners)
throws AntException {
return setupBuild(frame.getProject(), dataValues, addListeners);
}
}


+ 0
- 97
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java View File

@@ -1,97 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.io.File;
import org.apache.ant.common.service.FileService;
import org.apache.ant.common.util.FileUtils;
import org.apache.ant.common.util.AntException;

/**
* The core's implementation of the File Service. The File Service is used
* by Ant Library components to perform operations on the local file system
*
* @author Conor MacNeill
* @created 27 January 2002
*/
public class CoreFileService implements FileService {
/** The Frame this service instance is working for */
private Frame frame;

/** General file utilities */
private FileUtils fileUtils = FileUtils.newFileUtils();

/**
* Constructor
*
* @param frame the frame containing this context
*/
protected CoreFileService(Frame frame) {
this.frame = frame;
}

/**
* Resolve a file according to the base directory of the project
* associated with this context
*
* @param fileName the file name to be resolved.
* @return the file resolved to the project's base dir
* @exception AntException if the file cannot be resolved.
*/
public File resolveFile(String fileName) throws AntException {
File base = frame.getBaseDir();
return fileUtils.resolveFile(fileUtils.normalize(base.getPath()),
fileName);
}
}


+ 0
- 87
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreInputService.java View File

@@ -1,87 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import org.apache.ant.common.service.InputService;
import org.apache.ant.common.input.InputRequest;

/**
* The core's implementation of the Input Service.
*
* @author Conor MacNeill
* @created 30 April 2002
*/
public class CoreInputService implements InputService {
/** The Frame this service instance is working for */
private Frame frame;

/**
* Constructor
*
* @param frame the frame containing this context
*/
protected CoreInputService(Frame frame) {
this.frame = frame;
}

/**
* Handle an input request
*
* @param request an input request
* @exception ExecutionException if the request cannot be handled
*/
public void handleInput(InputRequest request) throws ExecutionException {
// XXX
}
}


+ 0
- 190
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/DeferredSetter.java View File

@@ -1,190 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import org.apache.ant.common.antlib.DeferredTask;

/**
* An implementation of the Setter interface for configuring instances of
* the DeferredTask interface
*
* @author Conor MacNeill
* @created 11 February 2002
*/
public class DeferredSetter implements Setter {
/**
* Set an attribute value on an object
*
* @param obj the object on which the value is being set
* @param attributeName the name of the attribute
* @param value the string represenation of the attribute's value
* @exception ExecutionException if the object does not support the
* attribute or the object has a problem setting the value
*/
public void setAttribute(Object obj, String attributeName,
String value) throws ExecutionException {
DeferredTask task = (DeferredTask) obj;
task.setAttribute(attributeName, value);
}


/**
* Get the type of the given nested element
*
* @param elementName the nested element whose type is desired
* @return the class instance representing the type of the element adder
*/
public Class getType(String elementName) {
return null;
}

/**
* Adds PCDATA to the element
*
* @param obj the instance whose content is being provided
* @param text the required content
* @exception ExecutionException if the object does not support
* contentor the object has a problem setting the content
*/
public void addText(Object obj, String text)
throws ExecutionException {
DeferredTask task = (DeferredTask) obj;
task.addText(text);
}

/**
* Add an element to the given object
*
* @param obj The object to which the element is being added
* @param elementName the name of the element
* @param value the object to be added - the nested element
* @exception ExecutionException if the object does not support content
* or the object has a problem setting the content
*/
public void addElement(Object obj, String elementName, Object value)
throws ExecutionException {
DeferredTask task = (DeferredTask) obj;
task.addElement(elementName, value);
}

/**
* Create a nested element using the object's element factory method.
*
* @param container the object in which the nested element is required.
* @param elementName the name of the nested element
* @return the new instance of the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
public Object createElement(Object container, String elementName)
throws ExecutionException {
throw new ExecutionException("Deferred Tasks do not support "
+ "creation of nested elements");
}

/**
* Indicate if the class assocated with this reflector supports the
* addition of text content.
*
* @return true if the class supports an addText method
*/
public boolean supportsText() {
return true;
}

/**
* Indicate if the class assocated with this reflector supports the
* given attribute
*
* @param attributeName the name of the attribute
* @return true if the given attribute is supported
*/
public boolean supportsAttribute(String attributeName) {
return true;
}

/**
* Determine if the class associated with this reflector supports a
* particular nested element via a create factory method
*
* @param elementName the name of the element
* @return true if the class supports creation of that element
*/
public boolean supportsNestedCreator(String elementName) {
return false;
}

/**
* Determine if the class associated with this reflector supports a
* particular nested element via an add method
*
* @param elementName the name of the element
* @return true if the class supports addition of that element
*/
public boolean supportsNestedAdder(String elementName) {
return true;
}

/**
* Determine if the class associated with this reflector supports a
* particular nested element
*
* @param elementName the name of the element
* @return true if the class supports the given type of nested element
*/
public boolean supportsNestedElement(String elementName) {
return true;
}

}


+ 0
- 182
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionContext.java View File

@@ -1,182 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.ExecutionComponent;
import org.apache.ant.common.util.Location;
import org.apache.ant.common.model.BuildElement;

/**
* This is the core's implementation of the AntContext for all core objects.
* Specific subclasses handle types and tasks
*
* @author Conor MacNeill
* @created 20 January 2002
*/
public class ExecutionContext implements AntContext {
/** The Frame containing this context */
private Frame frame;

/** the event support instance used to manage build events */
private BuildEventSupport eventSupport;

/** The build model associated with this context. */
private BuildElement model;

/** the execution component associated with the context, if any */
private ExecutionComponent component;

/**
* the loader used to load this context. Note that this is not
* necessarily the loader which is used to load the component as loading
* may have been delegated to a parent loader.
*/
private ClassLoader loader;

/**
* Initilaise this context's environment
*
* @param frame the frame containing this context
* @param component the component associated with this context - may be null
* @param model the build model associated with this component if any.
*/
protected ExecutionContext(Frame frame, ExecutionComponent component,
BuildElement model) {
this.frame = frame;
this.eventSupport = frame.getEventSupport();
this.model = model;
this.component = component;
}

/**
* Get an implementation of one of the core's service interfaces
*
* @param serviceInterfaceClass the interface class for which an
* implementation is required
* @return the core's implementation of the interface.
* @exception ExecutionException if there is a problem finding the
* interface
*/
public Object getCoreService(Class serviceInterfaceClass)
throws ExecutionException {
return frame.getCoreService(serviceInterfaceClass);
}


/**
* Gets the location associated with the ExecutionContext
*
* @return the location in the build model associated with this context.
*/
public Location getLocation() {
if (model == null) {
return Location.UNKNOWN_LOCATION;
}
return model.getLocation();
}

/**
* Log a message as a build event
*
* @param message the message to be logged
* @param level the priority level of the message
*/
public void log(String message, int level) {
Object source = component;
if (source == null) {
source = frame.getProject();
if (source == null) {
source = frame;
}
}
eventSupport.fireMessageLogged(source, message, level);
}

/**
* Sets the classLoader of the ExecutionContext
*
* @param loader the new classLoader value
*/
protected void setClassLoader(ClassLoader loader) {
this.loader = loader;
}

/**
* Gets the loader for this context
*
* @return the context's loader
*/
public ClassLoader getClassLoader() {
return loader;
}

/**
* Gets the executionComponent of the ExecutionContext
*
* @return the executionComponent value
*/
protected ExecutionComponent getExecutionComponent() {
return component;
}

/**
* Get the build model associated with this context.
*
* @return the build model or null if there is no build model.
*/
public BuildElement getModel() {
return model;
}
}


+ 0
- 136
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionException.java View File

@@ -1,136 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;

import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;

/**
* An ExecutionException indicates a problem while executing tasks in a
* build
*
* @author Conor MacNeill
* @created 20 January 2002
*/
public class ExecutionException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public ExecutionException(String msg) {
super(msg);
}


/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public ExecutionException(String msg, Location location) {
super(msg, location);
}


/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public ExecutionException(String msg, Throwable cause) {
super(msg, cause);
}


/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public ExecutionException(String msg, Throwable cause, Location location) {
super(msg, cause, location);
}


/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public ExecutionException(Throwable cause) {
super(cause);
}


/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public ExecutionException(Throwable cause, Location location) {
super(cause, location);
}

}


+ 0
- 1085
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
File diff suppressed because it is too large
View File


+ 0
- 128
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java View File

@@ -1,128 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;

import org.apache.ant.antcore.antlib.AntLibDefinition;
import org.apache.ant.antcore.antlib.ComponentLibrary;

/**
* This class is used to maintain information about imports
*
* @author Conor MacNeill
* @created 16 January 2002
*/
public class ImportInfo {
/** the component library from which the import is made */
private ComponentLibrary library;
/** the library definition information */
private AntLibDefinition libDefinition;

/**
* ImportInfo records what has been imported from an Ant Library
*
* @param library The library from which the import was made
* @param libDefinition the library definition information
*/
public ImportInfo(ComponentLibrary library,
AntLibDefinition libDefinition) {
this.library = library;
this.libDefinition = libDefinition;
}

/**
* Get the classname that has been imported
*
* @return the classname that was imported.
*/
public String getClassName() {
return libDefinition.getClassName();
}

/**
* Get the library from which the import was made
*
* @return the library from which the import was made
*/
public ComponentLibrary getComponentLibrary() {
return library;
}

/**
* Get the type of the definition that was imported
*
* @return the type of definition
*/
public int getDefinitionType() {
return libDefinition.getDefinitionType();
}

/**
* Get the name of the component within its library.
*
* @return the name of the component within its library
*/
public String getLocalName() {
return libDefinition.getDefinitionName();
}

/**
* Get the definition of the imported component.
*
* @return the component's library definition.
*/
public AntLibDefinition getDefinition() {
return libDefinition;
}
}


+ 0
- 486
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Reflector.java View File

@@ -1,486 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.ant.common.antlib.Converter;
import org.apache.ant.common.util.AntException;

/**
* A reflector is used to set attributes and add nested elements to an
* instance of an object using reflection. It is the result of class
* introspection.
*
* @author Conor MacNeill
* @created 19 January 2002
*/
public class Reflector implements Setter {

/**
* An element adder is used to add an instance of an element to an of an
* object. The object being added will have been fully configured by Ant
* prior to calling this method.
*
* @author Conor MacNeill
* @created 19 January 2002
*/
private interface ElementAdder {
/**
* Add an object to the this container object
*
* @param container the object to which the element is the be added
* @param obj an instance of the nested element
* @exception InvocationTargetException if the method cannot be
* invoked
* @exception IllegalAccessException if the method cannot be invoked
*/
void add(Object container, Object obj)
throws InvocationTargetException, IllegalAccessException;
}

/**
* Element Creator's a factory method provided by an Ant Library
* Component for creating its own nested element instances. These
* methods are now deprecated. It is better to use the add style methods
* and support polymorphic interfaces.
*
* @author Conor MacNeill
* @created 31 January 2002
*/
private interface ElementCreator {
/**
* Create a nested element object for the given container object
*
* @param container the object in which the nested element is to be
* created.
* @return the nested element.
* @exception InvocationTargetException if the create method fails
* @exception IllegalAccessException if the create method cannot be
* accessed
* @exception InstantiationException if the nested element instance
* cannot be created.
*/
Object create(Object container)
throws InvocationTargetException, IllegalAccessException,
InstantiationException;
}


/** The method used to add content to the element */
private Method addTextMethod;

/** the list of attribute setters indexed by their property name */
private Map attributeSetters = new HashMap();

/**
* A list of the Java class or interface accetpted by each element adder
* indexed by the element name
*/
private Map elementTypes = new HashMap();

/** the collection of element adders indexed by their element names */
private Map elementAdders = new HashMap();

/** the collection of element creators indexed by their element names */
private Map elementCreators = new HashMap();

/**
* Set an attribute value on an object
*
* @param obj the object on which the value is being set
* @param attributeName the name of the attribute
* @param value the string represenation of the attribute's value
* @exception AntException if the object does not support the
* attribute or the object has a problem setting the value
*/
public void setAttribute(Object obj, String attributeName,
String value)
throws AntException {
String name = attributeName.toLowerCase();
AttributeSetter as
= (AttributeSetter) attributeSetters.get(name);
if (as == null) {
throw new ExecutionException("Class " + obj.getClass().getName()
+ " doesn't support the \"" + attributeName + "\" attribute");
}
try {
as.set(obj, value);
} catch (IllegalAccessException e) {
// impossible as getMethods should only return public methods
throw new ExecutionException(e);
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
if (t instanceof ExecutionException) {
throw (ExecutionException) t;
}
throw new ExecutionException(t);
}
}

/**
* Set the method used to add content to the element
*
* @param addTextMethod the new addTextMethod value
*/
public void setAddTextMethod(Method addTextMethod) {
this.addTextMethod = addTextMethod;
}

/**
* Get the type of the given nested element
*
* @param elementName the nested element whose type is desired
* @return the class instance representing the type of the element adder
*/
public Class getType(String elementName) {
return (Class) elementTypes.get(elementName);
}

/**
* Adds PCDATA to the element
*
* @param obj the instance whose content is being provided
* @param text the required content
* @exception ExecutionException if the object does not support
* contentor the object has a problem setting the content
*/
public void addText(Object obj, String text)
throws ExecutionException {

if (addTextMethod == null) {
throw new ExecutionException("Class " + obj.getClass().getName() +
" doesn't support content");
}
try {
addTextMethod.invoke(obj, new String[]{text});
} catch (IllegalAccessException ie) {
// impossible as getMethods should only return public methods
throw new ExecutionException(ie);
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
if (t instanceof ExecutionException) {
throw (ExecutionException) t;
}
throw new ExecutionException(t);
}
}

/**
* Add an element to the given object
*
* @param obj The object to which the element is being added
* @param elementName the name of the element
* @param value the object to be added - the nested element
* @exception ExecutionException if the object does not support content
* or the object has a problem setting the content
*/
public void addElement(Object obj, String elementName, Object value)
throws ExecutionException {
String name = elementName.toLowerCase();
ElementAdder adder = (ElementAdder) elementAdders.get(name);
if (adder == null) {
throw new ExecutionException("Class " + obj.getClass().getName()
+ " doesn't support the \"" + elementName
+ "\" nested element");
}
try {
adder.add(obj, value);
} catch (IllegalAccessException ie) {
// impossible as getMethods should only return public methods
throw new ExecutionException(ie);
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
if (t instanceof ExecutionException) {
throw (ExecutionException) t;
}
throw new ExecutionException(t);
}

}

/**
* Create a nested element using the object's element factory method.
*
* @param container the object in which the nested element is required.
* @param elementName the name of the nested element
* @return the new instance of the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
public Object createElement(Object container, String elementName)
throws ExecutionException {

ElementCreator creator
= (ElementCreator) elementCreators.get(elementName.toLowerCase());
if (creator == null) {
throw new ExecutionException("Class "
+ container.getClass().getName()
+ " doesn't support the \"" + elementName
+ "\" nested element");
}

try {
return creator.create(container);
} catch (IllegalAccessException e) {
// impossible as getMethods should only return public methods
throw new ExecutionException(e);
} catch (InstantiationException e) {
// impossible as getMethods should only return public methods
throw new ExecutionException(e);
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof ExecutionException) {
throw (ExecutionException) t;
}
throw new ExecutionException(t);
}
}

/**
* Indicate if the class assocated with this reflector supports the
* addition of text content.
*
* @return true if the class supports an addText method
*/
public boolean supportsText() {
return addTextMethod != null;
}

/**
* Indicate if the class assocated with this reflector supports the
* given attribute
*
* @param attributeName the name of the attribute
* @return true if the given attribute is supported
*/
public boolean supportsAttribute(String attributeName) {
return attributeSetters.containsKey(attributeName.toLowerCase());
}

/**
* Determine if the class associated with this reflector supports a
* particular nested element via a create factory method
*
* @param elementName the name of the element
* @return true if the class supports creation of that element
*/
public boolean supportsNestedCreator(String elementName) {
return elementCreators.containsKey(elementName.toLowerCase());
}

/**
* Determine if the class associated with this reflector supports a
* particular nested element via an add method
*
* @param elementName the name of the element
* @return true if the class supports addition of that element
*/
public boolean supportsNestedAdder(String elementName) {
return elementAdders.containsKey(elementName.toLowerCase());
}

/**
* Add an attribute setter for the given property. The setter will only
* be added if it does not override a higher priorty setter
*
* @param attributeName the name of the attribute that the setter operates
* upon.
* @param setter the AttribnuteSetter instance to use.
*/
private void addAttributeSetter(String attributeName,
AttributeSetter setter) {
String name = attributeName.toLowerCase();
AttributeSetter currentSetter
= (AttributeSetter) attributeSetters.get(name);
if (currentSetter != null) {
// there is a setter, is it lower down in the class hierarchy
int currentDepth = currentSetter.getDepth();
if (currentDepth < setter.getDepth()) {
return;
} else if (currentDepth == setter.getDepth()) {
// now check the types
Class currentType = currentSetter.getType();
if (currentType != String.class) {
return;
}
}
}
attributeSetters.put(name, setter);
}


/**
* Determine if the class associated with this reflector supports a
* particular nested element
*
* @param elementName the name of the element
* @return true if the class supports the given type of nested element
*/
public boolean supportsNestedElement(String elementName) {
return supportsNestedAdder(elementName)
|| supportsNestedCreator(elementName);
}

/**
* Add a method to the reflector for setting an attribute value
*
* @param m the method, obtained by introspection.
* @param depth the depth of this method's declaration in the class
* hierarchy
* @param propertyName the property name the method will set.
* @param converters A map of converter classes used to convert strings
* to different types.
*/
public void addAttributeMethod(Method m, int depth,
String propertyName, Map converters) {
Class type = m.getParameterTypes()[0];

if (converters != null && converters.containsKey(type)) {
// we have a converter to use to convert the String
// value into something the set method expects.
Converter converter = (Converter) converters.get(type);
addConvertingSetter(m, depth, propertyName, converter);
return;
}

if (type.equals(String.class)) {
addAttributeSetter(propertyName, new AttributeSetter(m, depth));
return;
}

try {
final Constructor c =
type.getConstructor(new Class[]{java.lang.String.class});
addAttributeSetter(propertyName, new AttributeSetter(m, depth, c));
return;
} catch (NoSuchMethodException nme) {
// ignore
}

if (converters != null) {
// desparate by now - try top find a converter which handles a super
// class of this type and which supports subclass instantiation
for (Iterator i = converters.keySet().iterator(); i.hasNext();) {
Class converterType = (Class) i.next();
if (converterType.isAssignableFrom(type)) {
// could be a candidate
Converter converter
= (Converter) converters.get(converterType);
if (converter.canConvertSubType(type)) {
addConvertingSetter(m, depth, propertyName, converter);
return;
}
}
}
}
}

/**
* Add an element adder method to the list of element adders in the
* reflector
*
* @param m the adder method
* @param elementName The name of the element for which this adder works
*/
public void addElementMethod(final Method m, String elementName) {
final Class type = m.getParameterTypes()[0];
elementTypes.put(elementName, type);
elementAdders.put(elementName.toLowerCase(),
new ElementAdder() {
public void add(Object container, Object obj)
throws InvocationTargetException, IllegalAccessException {
m.invoke(container, new Object[]{obj});
}
});
}


/**
* Add a create factory method.
*
* @param m the create method
* @param elementName the name of the nested element the create method
* supports.
*/
public void addCreateMethod(final Method m, String elementName) {
elementCreators.put(elementName.toLowerCase(),
new ElementCreator() {
public Object create(Object container)
throws InvocationTargetException, IllegalAccessException {
return m.invoke(container, new Object[]{});
}
});
}

/**
* Add an attribute setter with an associated converter
*
* @param m the attribute setter method
* @param depth the depth of this method's declaration in the class
* hierarchy
* @param propertyName the name of the attribute this method supports
* @param converter the converter to be used to construct the value
* expected by the method.
*/
private void addConvertingSetter(Method m, int depth,
String propertyName, Converter converter) {
addAttributeSetter(propertyName,
new AttributeSetter(m, depth, converter));
}
}


+ 0
- 166
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Setter.java View File

@@ -1,166 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import org.apache.ant.common.util.AntException;

/**
* The Setter interface is used by the Ant core to set values and nested
* elements in objects being configured.
*
* @author Conor MacNeill
* @created 11 February 2002
*/
public interface Setter {
/**
* Set an attribute value on an object
*
* @param obj the object on which the value is being set
* @param attributeName the name of the attribute
* @param value the string represenation of the attribute's value
* @exception AntException if the object does not support the
* attribute or the object has a problem setting the value
*/
void setAttribute(Object obj, String attributeName,
String value)
throws AntException;

/**
* Get the type of the given nested element
*
* @param elementName the nested element whose type is desired
* @return the class instance representing the type of the element adder
*/
Class getType(String elementName);

/**
* Adds PCDATA to the element
*
* @param obj the instance whose content is being provided
* @param text the required content
* @exception ExecutionException if the object does not support
* contentor the object has a problem setting the content
*/
void addText(Object obj, String text)
throws ExecutionException;

/**
* Add an element to the given object
*
* @param obj The object to which the element is being added
* @param elementName the name of the element
* @param value the object to be added - the nested element
* @exception ExecutionException if the object does not support content
* or the object has a problem setting the content
*/
void addElement(Object obj, String elementName, Object value)
throws ExecutionException;

/**
* Create a nested element using the object's element factory method.
*
* @param container the object in which the nested element is required.
* @param elementName the name of the nested element
* @return the new instance of the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
Object createElement(Object container, String elementName)
throws ExecutionException;

/**
* Indicate if the class assocated with this reflector supports the
* addition of text content.
*
* @return true if the class supports an addText method
*/
boolean supportsText();

/**
* Indicate if the class assocated with this reflector supports the
* given attribute
*
* @param attributeName the name of the attribute
* @return true if the given attribute is supported
*/
boolean supportsAttribute(String attributeName);

/**
* Determine if the class associated with this reflector supports a
* particular nested element via a create factory method
*
* @param elementName the name of the element
* @return true if the class supports creation of that element
*/
boolean supportsNestedCreator(String elementName);

/**
* Determine if the class associated with this reflector supports a
* particular nested element via an add method
*
* @param elementName the name of the element
* @return true if the class supports addition of that element
*/
boolean supportsNestedAdder(String elementName);

/**
* Determine if the class associated with this reflector supports a
* particular nested element
*
* @param elementName the name of the element
* @return true if the class supports the given type of nested element
*/
boolean supportsNestedElement(String elementName);

}


+ 0
- 122
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/TaskAdapter.java View File

@@ -1,122 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.execution;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.event.MessageLevel;

/**
* Use introspection to "adapt" an arbitrary Bean (not extending Task, but
* with similar patterns).
*
* @author Conor MacNeill
* @created 16 January 2002
*/
public class TaskAdapter extends AbstractTask {

/** The real object that is performing the work */
private Object worker;

/** the execute method of the real object */
private Method executeMethod = null;

/**
* Create an adapter for an arbitraty bean
*
* @param taskType the name of the task
* @param worker an instance of the actual object that does the work
* @exception ExecutionException if the worker object does not support
* an execute method
*/
public TaskAdapter(String taskType, Object worker)
throws ExecutionException {
this.worker = worker;
try {
Class workerClass = worker.getClass();
executeMethod = workerClass.getMethod("execute", new Class[0]);
if (executeMethod == null) {
throw new ExecutionException("No execute method in the class"
+ " for the <" + taskType + "> task.");
}
} catch (NoSuchMethodException e) {
throw new ExecutionException(e);
}
}


/**
* Standard Task execute method. This invokes the execute method of the
* worker instance
*
* @exception ExecutionException if the proxied object throws an exception
*/
public void execute() throws ExecutionException {
try {
executeMethod.invoke(worker, null);
} catch (InvocationTargetException e) {
log("Error in " + worker.getClass(), MessageLevel.ERROR);
Throwable t = e.getTargetException();
if (t instanceof ExecutionException) {
throw (ExecutionException) t;
} else {
throw new ExecutionException(t);
}
} catch (Throwable t) {
log("Error in " + worker.getClass(), MessageLevel.ERROR);
throw new ExecutionException(t);
}
}
}


+ 0
- 129
proposal/mutant/src/java/antcore/org/apache/ant/antcore/frontend/FrontendException.java View File

@@ -1,129 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.frontend;

import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;

/**
* An exception in the frontend set up of an Ant run
*
* @author Conor MacNeill
*/
public class FrontendException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public FrontendException(String msg) {
super(msg);
}

/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public FrontendException(String msg, Location location) {
super(msg, location);
}

/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public FrontendException(String msg, Throwable cause) {
super(msg, cause);
}

/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public FrontendException(String msg, Throwable cause,
Location location) {
super(msg, cause, location);
}

/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public FrontendException(Throwable cause) {
super(cause);
}

/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public FrontendException(Throwable cause, Location location) {
super(cause, location);
}
}


+ 0
- 137
proposal/mutant/src/java/antcore/org/apache/ant/antcore/frontend/FrontendUtils.java View File

@@ -1,137 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.frontend;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.ant.antcore.config.AntConfig;
import org.apache.ant.antcore.config.AntConfigHandler;
import org.apache.ant.antcore.xml.ParseContext;
import org.apache.ant.antcore.xml.XMLParseException;
import org.apache.ant.init.InitUtils;
import org.apache.ant.common.constants.Namespace;

/**
* Frontend Utilities methods and constants.
*
* @author Conor MacNeill
* @created 16 April 2002
*/
public class FrontendUtils {
/** The default build file name */
public static final String DEFAULT_BUILD_FILENAME = "build.ant";

/** The default build file name */
public static final String DEFAULT_ANT1_FILENAME = "build.xml";


/**
* Get the AntConfig from the given config area if it is available
*
* @param configArea the config area from which the config may be read
* @return the AntConfig instance representing the config info read in
* from the config area. May be null if the AntConfig is not present
* @exception FrontendException if the URL for the config file cannotbe
* formed.
*/
public static AntConfig getAntConfig(File configArea)
throws FrontendException {
File configFile = new File(configArea, "antconfig.xml");

try {
return getAntConfigFile(configFile);
} catch (FileNotFoundException e) {
// ignore if files are not present
return null;
}
}


/**
* Read in a config file
*
* @param configFile the file containing the XML config
* @return the parsed config object
* @exception FrontendException if the config cannot be parsed
* @exception FileNotFoundException if the file cannot be found.
*/
public static AntConfig getAntConfigFile(File configFile)
throws FrontendException, FileNotFoundException {
try {
URL configFileURL = InitUtils.getFileURL(configFile);

ParseContext context = new ParseContext();

AntConfigHandler configHandler = new AntConfigHandler();

context.parse(configFileURL, "antconfig", configHandler);

return configHandler.getAntConfig();
} catch (MalformedURLException e) {
throw new FrontendException("Unable to form URL to read "
+ "config from " + configFile, e);
} catch (XMLParseException e) {
if (e.getCause() instanceof FileNotFoundException) {
throw (FileNotFoundException) e.getCause();
}

throw new FrontendException("Unable to parse config file from "
+ configFile, e, e.getLocation());
}
}

}


+ 0
- 146
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/BuildElementHandler.java View File

@@ -1,146 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;
import java.util.Iterator;

import org.apache.ant.common.model.BuildElement;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;

/**
* A BuildElementHandler parses the task elements of a build. Task elements
* include tasks themselves plus all their nested elements to any depth.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class BuildElementHandler extends ModelElementHandler {
/** The task element being parsed by this handler. */
private BuildElement buildElement;

/**
* Get the task element being parsed by this handler.
*
* @return the BuildElement being parsed.
*/
public BuildElement getBuildElement() {
return buildElement;
}

/**
* Create a task element handler to parse a task element
*
* @param elementName the name of the element - always target
*/
public void processElement(String elementName) {
buildElement
= new BuildElement(getLocation(), elementName);
setModelElement(buildElement);

for (Iterator i = getAttributes(); i.hasNext();) {
String attributeName = (String) i.next();
buildElement.addAttribute(attributeName,
getAttribute(attributeName));
}
addNamespaceAttributes();
}


/**
* Process a nested element of this task element. All nested elements of
* a buildElement are themselves buildElements.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {

// everything within a task element is also a task element
BuildElementHandler nestedHandler
= new BuildElementHandler();
nestedHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(), qualifiedName);
buildElement.addNestedElement(nestedHandler.getBuildElement());
}


/**
* This method is called when this element is finished being processed.
* This is a template method allowing subclasses to complete any
* necessary processing.
*/
protected void finish() {
String content = getContent();
if (content != null && content.trim().length() != 0) {
buildElement.addText(getContent());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
*/
protected void validateAttribute(String attributeName,
String attributeValue) {
// do nothing - all attributes are OK by default.
}
}


+ 0
- 139
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/IncludeHandler.java View File

@@ -1,139 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;

import java.net.MalformedURLException;
import java.net.URL;
import org.apache.ant.common.model.Project;
import org.apache.ant.antcore.xml.ElementHandler;
import org.apache.ant.antcore.xml.XMLParseException;
import org.xml.sax.SAXParseException;

/**
* The include handler is used to read in included projects or fragments
* into a project.
*
* @author Conor MacNeill
* @created 11 January 2002
*/
public class IncludeHandler extends ElementHandler {
/** The attribute name which identifies the fragment to be included */
public static final String SYSTEMID_ATTR = "fragment";

/** The including project */
private Project project;


/**
* Create an IncludeHandler.
*
* @param project the project into which the include fragment is to be
* placed
*/
public IncludeHandler(Project project) {
this.project = project;
}


/**
* Process the element.
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {

String includeSystemId = getAttribute(SYSTEMID_ATTR);
if (includeSystemId == null) {
throw new SAXParseException("Attribute " + SYSTEMID_ATTR +
" is required in an <include> element", getLocator());
}

// create a new parser to read this project relative to the
// project's URI
try {
URL includeURL = new URL(getElementSource(), includeSystemId);
ProjectHandler includedProjectHandler = new ProjectHandler(project);
getParseContext().parse(includeURL,
new String[]{"project", "fragment"},
includedProjectHandler);
} catch (MalformedURLException e) {
throw new SAXParseException("Unable to include " + includeSystemId
+ ": " + e.getMessage(), getLocator());
} catch (XMLParseException e) {
throw new SAXParseException("Error parsing included project "
+ includeSystemId + ": " + e.getMessage(), getLocator());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
if (!attributeName.equals(SYSTEMID_ATTR)) {
throwInvalidAttribute(attributeName);
}
}
}



+ 0
- 103
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ModelElementHandler.java View File

@@ -1,103 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;
import org.apache.ant.antcore.xml.ElementHandler;

import org.apache.ant.common.model.ModelElement;
import java.util.Iterator;
import org.apache.ant.common.util.AttributeCollection;

/**
* A BuildElementHandler parses the task elements of a build. Task elements
* include tasks themselves plus all their nested elements to any depth.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public abstract class ModelElementHandler extends ElementHandler {
/** The model element being parsed by this handler. */
private ModelElement modelElement;


/**
* Set the model element being handled by this handler
*
* @param modelElement The new modelElement value
*/
protected void setModelElement(ModelElement modelElement) {
this.modelElement = modelElement;
}


/** Set the end location of the element. */
protected void finish() {
if (modelElement != null) {
modelElement.setEndLocation(getLocation());
}
}

/**
* Add all attributes which belong to namespaces rather than the default
* namespace for the build files.
*/
protected void addNamespaceAttributes() {
for (Iterator i = getNamespaces(); i.hasNext();) {
String uri = (String) i.next();
AttributeCollection namespaceValues = getNamespaceAttributes(uri);
modelElement.addNamespaceAttributes(uri, namespaceValues);
}
}

}


+ 0
- 65
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/NoProjectReadException.java View File

@@ -1,65 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;

/**
* A NoProjectReadException is used to indicate that a project was not read
* from the particular source. This will happen if the source is empty.
*
* @author Conor MacNeill
* @created 15 January 2002
*/
public class NoProjectReadException extends Exception {
}


+ 0
- 202
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/ProjectHandler.java View File

@@ -1,202 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;
import org.apache.ant.common.model.ModelException;
import org.apache.ant.common.model.Project;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;

/**
* Element to parse the project element. The project handler creates a
* number of different handlers to which it delegates processing of child
* elements.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class ProjectHandler extends ModelElementHandler {
/** The basedir attribute tag */
public static final String BASEDIR_ATTR = "basedir";

/** The name attribute */
public static final String NAME_ATTR = "name";

/** The default attribute name */
public static final String DEFAULT_ATTR = "default";

/** The name of the element used to define includes */
public static final String INCLUDE_ELEMENT = "ant:include";

/** The name of the element used to define references */
public static final String TARGET_ELEMENT = "target";

/** The project being parsed. */
private Project project;

/** Constructor parsing a new project */
public ProjectHandler() {
project = null;
}

/**
* Constructor for including a project or fragment into an existing
* project
*
* @param project The project to be configured by the handler
*/
public ProjectHandler(Project project) {
this.project = project;
}

/**
* Get the project that has been parsed from the element
*
* @return the project that has been parsed from the build source
* @throws NoProjectReadException thrown if no project was read in.
*/
public Project getProject()
throws NoProjectReadException {
if (project == null) {
throw new NoProjectReadException();
}
return project;
}


/**
* Process the project element
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
if (project == null) {
project = new Project(getElementSource(), getLocation());
setModelElement(project);

project.setDefaultTarget(getAttribute(DEFAULT_ATTR));
project.setBase(getAttribute(BASEDIR_ATTR));
project.setName(getAttribute(NAME_ATTR));
addNamespaceAttributes();
}
}


/**
* Start a new element in the project. Project currently handles the
* following elements
* <ul>
* <li> ref</li>
* <li> include</li>
* <li> target</li>
* </ul>
* Everything else is treated as a task.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {

if (qualifiedName.equals(INCLUDE_ELEMENT)) {
IncludeHandler includeHandler = new IncludeHandler(project);
includeHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
} else if (qualifiedName.equals(TARGET_ELEMENT)) {
TargetHandler targetHandler = new TargetHandler();
targetHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes,
getElementSource(), qualifiedName);
try {
project.addTarget(targetHandler.getTarget());
} catch (ModelException e) {
throw new SAXParseException(e.getMessage(), getLocator(), e);
}
} else {
// everything else is a task
BuildElementHandler buildElementHandler = new BuildElementHandler();
buildElementHandler.start(getParseContext(), getXMLReader(),
this, getLocator(), attributes, getElementSource(),
qualifiedName);
project.addTask(buildElementHandler.getBuildElement());
}
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
if (!attributeName.equals(BASEDIR_ATTR) &&
!attributeName.equals(NAME_ATTR) &&
!attributeName.equals(DEFAULT_ATTR)) {
throwInvalidAttribute(attributeName);
}
}
}



+ 0
- 164
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/TargetHandler.java View File

@@ -1,164 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;
import java.util.StringTokenizer;

import org.apache.ant.common.model.Target;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;

/**
* Element handler for the target element
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class TargetHandler extends ModelElementHandler {
/** The name attribute */
public static final String NAME_ATTR = "name";

/** The depends attribute name */
public static final String DEPENDS_ATTR = "depends";

/** The depends attribute name */
public static final String DESC_ATTR = "description";

/** The if attribute name */
public static final String IF_ATTR = "if";

/** The unless attribute name */
public static final String UNLESS_ATTR = "unless";

/** The target being configured. */
private Target target;

/**
* Get the target parsed by this handler.
*
* @return the Target model object parsed by this handler.
*/
public Target getTarget() {
return target;
}


/**
* Process the target element.
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the
* element
*/
public void processElement(String elementName)
throws SAXParseException {
target = new Target(getLocation(), getAttribute(NAME_ATTR));
setModelElement(target);
target.setDescription(getAttribute(DESC_ATTR));
addNamespaceAttributes();

String depends = getAttribute(DEPENDS_ATTR);
if (depends != null) {
StringTokenizer tokenizer = new StringTokenizer(depends, ",");
while (tokenizer.hasMoreTokens()) {
String dependency = tokenizer.nextToken().trim();
target.addDependency(dependency);
}
}
target.setIfCondition(getAttribute(IF_ATTR));
target.setUnlessCondition(getAttribute(UNLESS_ATTR));
}


/**
* Process an element within this target. All elements within the target
* are treated as tasks.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {
// everything is a task
BuildElementHandler taskHandler = new BuildElementHandler();
taskHandler.start(getParseContext(), getXMLReader(), this, getLocator(),
attributes, getElementSource(), qualifiedName);
target.addTask(taskHandler.getBuildElement());
}

/**
* Validate that the given attribute and value are valid.
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
if (!attributeName.equals(NAME_ATTR)
&& !attributeName.equals(DEPENDS_ATTR)
&& !attributeName.equals(DESC_ATTR)
&& !attributeName.equals(IF_ATTR)
&& !attributeName.equals(UNLESS_ATTR)) {
throwInvalidAttribute(attributeName);
}
}
}



+ 0
- 94
proposal/mutant/src/java/antcore/org/apache/ant/antcore/modelparser/XMLProjectParser.java View File

@@ -1,94 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.modelparser;
import java.net.URL;

import org.apache.ant.common.util.Location;
import org.apache.ant.common.model.Project;
import org.apache.ant.antcore.xml.ParseContext;
import org.apache.ant.antcore.xml.XMLParseException;
import org.apache.ant.common.constants.Namespace;

/**
* Parses an Ant project model from an XML source using a SAX Parser.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class XMLProjectParser {
/**
* Parse a build file from the given URL.
*
* @param buildSource the URL from where the build source may be read.
* @return a project model representing the project
* @exception XMLParseException if there is an problem parsing the XML
* representation
*/
public Project parseBuildFile(URL buildSource)
throws XMLParseException {
try {
ParseContext context = new ParseContext();

ProjectHandler projectHandler = new ProjectHandler();

context.parse(buildSource, "project", projectHandler);

return projectHandler.getProject();
} catch (NoProjectReadException e) {
throw new XMLParseException("No project defined in build source ",
e, new Location(buildSource.toString()));
}
}
}


+ 0
- 411
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ElementHandler.java View File

@@ -1,411 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.xml;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.ant.common.util.AttributeCollection;

import org.apache.ant.common.util.Location;
import org.apache.ant.common.util.PropertyUtils;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

/**
* An Element Handler is a handler which handles a single element by becoming
* the handler for the parser while processing the element. Any sub elements
* must be delegated to separate handlers. When this element is finished,
* control returns to the parent handler.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public abstract class ElementHandler extends DefaultHandler {
/** The parsing context for parsing this element */
private ParseContext context;

/**
* Locator used to identify where in the build source particular elements
* occur.
*/
private Locator locator;

/** The actual XML parser used to parse the build source */
private XMLReader reader;

/** The parent element handler */
private ContentHandler parent;

/** The URL from which we are reading source */
private URL source;

/** The name of this element */
private String elementName;

/** The attributes read from this element */
private AttributeCollection elementAttributes;

/**
* This map contains a set of attribute collections for each namespace
* encountered.
*/
private Map namespaces;

/** The content of this element */
private String content;

/**
* Get the source which contains this element
*
* @return the URL from which this element is being read
*/
public URL getElementSource() {
return source;
}

/**
* Get an interator over the namespace URIs encountered in the processing
* of the element
*
* @return an iterator over the namespace URIs.
*/
public Iterator getNamespaces() {
return namespaces.keySet().iterator();
}

/**
* Get the collection of namespace attributes for a given namespace.
*
* @param uri the URI of the namespace from which the attribute collection
* is required.
* @return an attribute collection if any attributes of the requested
* namespace have beebn encountered - otherwise null.
*/
public AttributeCollection getNamespaceAttributes(String uri) {
return (AttributeCollection) namespaces.get(uri);
}

/**
* Gets the attributeValue attribute of the ElementHandler object
*
* @param attributeName th name of the attribute
* @return The corresponding attribute value or null if the attribute wa
* snot defined.
*/
public String getAttribute(String attributeName) {
return elementAttributes.getAttribute(attributeName);
}

/**
* Get an attribute as a boolean value
*
* @param attributeName the name of the attribute
* @return the attribute value as a boolean
*/
protected boolean getBooleanAttribute(String attributeName) {
return PropertyUtils.toBoolean(getAttribute(attributeName));
}

/**
* Get an iterator to this elements attributes
*
* @return an iterator over the attribute names
*/
public Iterator getAttributes() {
return elementAttributes.getAttributeNames();
}

/**
* Gets the content of the element
*
* @return The content value
*/
public String getContent() {
return content;
}


/**
* Start this element handler.
*
* @param parent the element handler for the element which contains this
* one.
* @param locator the locator is used to get location information from
* elements.
* @param attributes the element's attributes.
* @param source the URL from which the XML source is being parsed.
* @param xmlReader the parser being used
* @param context the parser context for this element
* @param elementName the actual element Name for this element in the XML
* @exception SAXParseException if there is a problem parsing the element
*/
public final void start(ParseContext context, XMLReader xmlReader,
ContentHandler parent, Locator locator,
Attributes attributes, URL source,
String elementName)
throws SAXParseException {
this.context = context;
this.reader = xmlReader;
this.parent = parent;
this.locator = locator;
this.source = source;
this.elementName = elementName;
processAttributes(attributes);
processElement(elementName);
reader.setContentHandler(this);
}


/**
* Process an element. This resolves any namespaces against prefixes
* declared in the ParseContext.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a problem parsng the subelement
*/
public final void startElement(String uri, String localName,
String qualifiedName, Attributes attributes)
throws SAXParseException {
addNestedElement(uri, localName, qualifiedName, attributes);
}

/**
* By default an element handler does not support nested elements. This
* method will always throw an exception. Subclasses should override this
* method to support their own nested elements
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a problem parsng the subelement
*/
protected void addNestedElement(String uri, String localName,
String qualifiedName,
Attributes attributes)
throws SAXParseException {
throw new SAXParseException("<" + elementName + "> does not support a <"
+ qualifiedName + "> nested element", getLocator());
}


/**
* Handle the end of this element by making the parent element handler the
* current content handler
*
* @param localName The local name (without prefix).
* @param namespaceURI The Namespace URI.
* @param qName the qualified name of the element
*/
public final void endElement(String namespaceURI, String localName,
String qName) {
finish();
reader.setContentHandler(parent);
}

/**
* Record content of this element
*
* @param buf the buffer containing the content to be added
* @param start start position in the buffer
* @param end end position in the buffer
* @exception SAXParseException if there is a parsing error.
* @see org.xml.sax.ContentHandler.characters()
*/
public void characters(char[] buf, int start, int end)
throws SAXParseException {
if (content == null) {
content = "";
}
content += new String(buf, start, end);
}


/**
* Get the current parsing location
*
* @return a location instance representing the current parse position
*/
protected Location getLocation() {
return new Location(locator.getSystemId(), locator.getLineNumber(),
locator.getColumnNumber());
}


/**
* Get the XML Reader being used to parse the XML.
*
* @return the XML Reader.
*/
protected XMLReader getXMLReader() {
return reader;
}


/**
* Get the parsing context
*
* @return the parsing context of this element
*/
protected ParseContext getParseContext() {
return context;
}


/**
* Get the locator used to locate elements in the XML source as they are
* parsed.
*
* @return the locator object which can be used to determine an elements
* location within the XML source
*/
protected Locator getLocator() {
return locator;
}


/**
* Process the element.
*
* @param elementName the name of the element
* @exception SAXParseException if there is a problem parsing the element
*/
protected abstract void processElement(String elementName)
throws SAXParseException;

/**
* Process all of the attributes of the element into maps, one for aspects
* and one for other attributes
*
* @param attributes The SAX attributes collection for the element
* @exception SAXParseException if there is a problem reading the
* attributes
*/
protected final void processAttributes(Attributes attributes)
throws SAXParseException {
namespaces = new HashMap();
elementAttributes = new AttributeCollection();
int length = attributes.getLength();
for (int i = 0; i < length; ++i) {
String localName = attributes.getLocalName(i);
String qName = attributes.getQName(i);
String uri = attributes.getURI(i);
if (uri != null && uri.trim().length() == 0) {
uri = null;
}

String attributeValue = attributes.getValue(i);
if (uri != null) {
AttributeCollection namespaceAttributes
= (AttributeCollection) namespaces.get(uri);
if (namespaceAttributes == null) {
namespaceAttributes = new AttributeCollection();
namespaces.put(uri, namespaceAttributes);
}

namespaceAttributes.putAttribute(localName, attributeValue);
} else {
validateAttribute(localName, attributeValue);
elementAttributes.putAttribute(localName, attributeValue);
}
}
}

/**
* Validate that the given attribute and value are valid. By default all
* attributes are considered invalid. This method should be overrider by
* subclasses to allow specific attributes
*
* @param attributeName The name of the attributes
* @param attributeValue The value of the attributes
* @exception SAXParseException if the attribute is not allowed on the
* element.
*/
protected void validateAttribute(String attributeName,
String attributeValue)
throws SAXParseException {
throwInvalidAttribute(attributeName);
}

/**
* Throws an invalid attribute exception
*
* @param attributeName The name of the invalid attribute
* @exception SAXParseException always - indicating attribute is invalid
*/
protected final void throwInvalidAttribute(String attributeName)
throws SAXParseException {
throw new SAXParseException("The attribute '" + attributeName
+ "' is not " + "supported by the <" + elementName
+ "> element", getLocator());
}


/**
* This method is called when this element is finished being processed.
* This is a template method allowing subclasses to complete any necessary
* processing.
*/
protected void finish() {
}
}


+ 0
- 183
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/ParseContext.java View File

@@ -1,183 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.xml;

import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import java.net.URL;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.ant.common.util.Location;
import org.apache.ant.common.util.CircularDependencyChecker;
import org.apache.ant.common.util.CircularDependencyException;
import org.apache.ant.common.util.AntException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;

/**
* Holds the current parsing context.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class ParseContext {
/** These are namespace to URIs which need not be declared in the XML */
private Map knownNamespaces = new HashMap();

/**
* Used to check if we are trying to parse a build file within its own
* context.
*/
private CircularDependencyChecker checker
= new CircularDependencyChecker("parsing XML");

/** The factory used to create SAX parsers. */
private SAXParserFactory parserFactory;

/**
* Initialize a parse context.
*
* This method creates the Parser Factory for which it sets the
* context classloader.
*/
public ParseContext() {
Thread thread = Thread.currentThread();
ClassLoader currentContextLoader = thread.getContextClassLoader();
try {
ClassLoader thisLoader = this.getClass().getClassLoader();
thread.setContextClassLoader(thisLoader);
parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
} finally {
thread.setContextClassLoader(currentContextLoader);
}
}

/**
* Parse a URL using the given root handler
*
* @param source The URL to the source to be parsed
* @param rootElementName The required root element name
* @param rootElementHandler The handler for the root element
* @exception XMLParseException if the element cannot be parsed
*/
public void parse(URL source, String rootElementName,
ElementHandler rootElementHandler)
throws XMLParseException {
parse(source, new String[]{rootElementName}, rootElementHandler);
}


/**
* Parse a URL using the given root handler
*
* @param source The URL to the source to be parsed
* @param rootElementNames The allowable root element names
* @param rootElementHandler The handler for the root element
* @exception XMLParseException if the element cannot be parsed
*/
public void parse(URL source, String[] rootElementNames,
ElementHandler rootElementHandler)
throws XMLParseException {
try {
checker.visitNode(source);

// create a parser for this source
SAXParser saxParser = null;

Thread thread = Thread.currentThread();
ClassLoader currentContextLoader = thread.getContextClassLoader();
try {
ClassLoader thisLoader = this.getClass().getClassLoader();
thread.setContextClassLoader(thisLoader);
saxParser = parserFactory.newSAXParser();
} finally {
thread.setContextClassLoader(currentContextLoader);
}

XMLReader xmlReader = saxParser.getXMLReader();

// create a root handler for this
RootHandler rootHandler = new RootHandler(this, source, xmlReader,
rootElementNames, rootElementHandler);
saxParser.parse(source.toString(), rootHandler);

checker.leaveNode(source);
} catch (ParserConfigurationException e) {
throw new XMLParseException(e);
} catch (SAXParseException e) {
Location location = new Location(e.getSystemId(),
e.getLineNumber(), e.getColumnNumber());
if (e.getException() != null) {
Throwable nestedException = e.getException();
if (nestedException instanceof AntException) {
location = ((AntException) nestedException).getLocation();
}
throw new XMLParseException(nestedException, location);
} else {
throw new XMLParseException(e, location);
}
} catch (SAXException e) {
throw new XMLParseException(e);
} catch (IOException e) {
throw new XMLParseException(e);
} catch (CircularDependencyException e) {
throw new XMLParseException(e);
}
}
}


+ 0
- 154
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/RootHandler.java View File

@@ -1,154 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.xml;

import java.net.URL;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

/**
* Handle the root of an XML parse. This class recognizes the root document
* element and then passes control to the handler for that root element.
*
* @author Conor MacNeill
* @created 9 January 2002
*/
public class RootHandler extends DefaultHandler {
/** The parsing context for this document */
private ParseContext context;

/**
* Locator used to identify where in the build source particular
* elements occur.
*/
private Locator locator;

/** The actual XML parser used to parse the build source */
private XMLReader reader;

/** The URL from which the XML source is being read. */
private URL sourceURL;

/** The allowed names of the root element in this document */
private String[] allowedRootNames;

/** The handler for the root element */
private ElementHandler rootElementHandler;


/**
* Handler to handle the document root.
*
* @param context The Parser context for this parse operation
* @param sourceURL URL of the source containing the XML definition
* @param reader XML parser
* @param allowedRootNames An array of allowed element names
* @param rootElementHandler The element handler for the root element
*/
public RootHandler(ParseContext context, URL sourceURL, XMLReader reader,
String[] allowedRootNames,
ElementHandler rootElementHandler) {
this.context = context;
this.sourceURL = sourceURL;
this.reader = reader;
this.allowedRootNames = allowedRootNames;
this.rootElementHandler = rootElementHandler;
}


/**
* Set the locator to use when parsing elements. This is passed onto
* child elements.
*
* @param locator the locator for locating elements in the build source.
*/
public void setDocumentLocator(Locator locator) {
this.locator = locator;
}


/**
* Start a new element in the root. This must be an allowed root element.
* All other elements are invalid.
*
* @param uri The Namespace URI.
* @param localName The local name (without prefix).
* @param qualifiedName The qualified name (with prefix)
* @param attributes The attributes attached to the element.
* @throws SAXParseException if there is a parsing problem.
*/
public void startElement(String uri, String localName, String qualifiedName,
Attributes attributes)
throws SAXParseException {
boolean allowed = false;
for (int i = 0; i < allowedRootNames.length; ++i) {
if (qualifiedName.equals(allowedRootNames[i])) {
allowed = true;
break;
}
}

if (allowed) {
rootElementHandler.start(context, reader, this,
locator, attributes, sourceURL, qualifiedName);
} else {
throw new SAXParseException("<" + qualifiedName
+ "> element was not expected as the root element", locator);
}
}
}


+ 0
- 130
proposal/mutant/src/java/antcore/org/apache/ant/antcore/xml/XMLParseException.java View File

@@ -1,130 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antcore.xml;

import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;

/**
* An XMLParseException is thrown when there is an error parsing the XML
* representation of an Ant build file.
*
* @author Conor MacNeill
* @created 11 January 2002
*/
public class XMLParseException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public XMLParseException(String msg) {
super(msg);
}

/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public XMLParseException(String msg, Location location) {
super(msg, location);
}

/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public XMLParseException(String msg, Throwable cause) {
super(msg, cause);
}

/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public XMLParseException(String msg, Throwable cause, Location location) {
super(msg, cause, location);
}

/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public XMLParseException(Throwable cause) {
super(cause);
}

/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public XMLParseException(Throwable cause, Location location) {
super(cause, location);
}
}


+ 0
- 194
proposal/mutant/src/java/antlibs/ant1compat/antlib.xml View File

@@ -1,194 +0,0 @@
<antlib libid="ant.ant1compat"
home="http://jakarta.apache.org/ant"
reqxml="true" reqtools="true"
extends="ant.system">

<factory classname="org.apache.tools.ant.Ant1Factory"/>

<converter classname="org.apache.tools.ant.Ant1Converter"/>

<!-- taskdefs -->
<taskdef name="WsdlToDotnet" classname="org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet"/>
<taskdef name="antlr" classname="org.apache.tools.ant.taskdefs.optional.ANTLR"/>
<taskdef name="antstructure" classname="org.apache.tools.ant.taskdefs.AntStructure"/>
<taskdef name="apply" classname="org.apache.tools.ant.taskdefs.Transform"/>
<taskdef name="available" classname="org.apache.tools.ant.taskdefs.Available"/>
<taskdef name="basename" classname="org.apache.tools.ant.taskdefs.Basename"/>
<taskdef name="blgenclient" classname="org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient"/>
<taskdef name="buildnumber" classname="org.apache.tools.ant.taskdefs.BuildNumber"/>
<taskdef name="bunzip2" classname="org.apache.tools.ant.taskdefs.BUnzip2"/>
<taskdef name="bzip2" classname="org.apache.tools.ant.taskdefs.BZip2"/>
<taskdef name="cab" classname="org.apache.tools.ant.taskdefs.optional.Cab"/>
<taskdef name="cccheckin" classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckin"/>
<taskdef name="cccheckout" classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckout"/>
<taskdef name="ccmcheckin" classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin"/>
<taskdef name="ccmcheckintask" classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault"/>
<taskdef name="ccmcheckout" classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout"/>
<taskdef name="ccmcreatetask" classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask"/>
<taskdef name="ccmreconfigure" classname="org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure"/>
<taskdef name="ccuncheckout" classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCUnCheckout"/>
<taskdef name="ccupdate" classname="org.apache.tools.ant.taskdefs.optional.clearcase.CCUpdate"/>
<taskdef name="checksum" classname="org.apache.tools.ant.taskdefs.Checksum"/>
<taskdef name="chmod" classname="org.apache.tools.ant.taskdefs.Chmod"/>
<taskdef name="concat" classname="org.apache.tools.ant.taskdefs.Concat"/>
<taskdef name="condition" classname="org.apache.tools.ant.taskdefs.ConditionTask"/>
<taskdef name="copy" classname="org.apache.tools.ant.taskdefs.Copy"/>
<taskdef name="csc" classname="org.apache.tools.ant.taskdefs.optional.dotnet.CSharp"/>
<taskdef name="cvs" classname="org.apache.tools.ant.taskdefs.Cvs"/>
<taskdef name="cvschangelog" classname="org.apache.tools.ant.taskdefs.cvslib.ChangeLogTask"/>
<taskdef name="cvspass" classname="org.apache.tools.ant.taskdefs.CVSPass"/>
<taskdef name="cvstagdiff" classname="org.apache.tools.ant.taskdefs.cvslib.CvsTagDiff"/>
<taskdef name="ddcreator" classname="org.apache.tools.ant.taskdefs.optional.ejb.DDCreator"/>
<taskdef name="delete" classname="org.apache.tools.ant.taskdefs.Delete"/>
<taskdef name="depend" classname="org.apache.tools.ant.taskdefs.optional.depend.Depend"/>
<taskdef name="dependset" classname="org.apache.tools.ant.taskdefs.DependSet"/>
<taskdef name="dirname" classname="org.apache.tools.ant.taskdefs.Dirname"/>
<taskdef name="ear" classname="org.apache.tools.ant.taskdefs.Ear"/>
<taskdef name="echo" classname="org.apache.tools.ant.taskdefs.Echo"/>
<taskdef name="echoproperties" classname="org.apache.tools.ant.taskdefs.optional.EchoProperties"/>
<taskdef name="ejbc" classname="org.apache.tools.ant.taskdefs.optional.ejb.Ejbc"/>
<taskdef name="ejbjar" classname="org.apache.tools.ant.taskdefs.optional.ejb.EjbJar"/>
<taskdef name="exec" classname="org.apache.tools.ant.taskdefs.ExecTask"/>
<taskdef name="execon" classname="org.apache.tools.ant.taskdefs.ExecuteOn"/>
<taskdef name="fail" classname="org.apache.tools.ant.taskdefs.Exit"/>
<taskdef name="filter" classname="org.apache.tools.ant.taskdefs.Filter"/>
<taskdef name="fixcrlf" classname="org.apache.tools.ant.taskdefs.FixCRLF"/>
<taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP"/>
<taskdef name="genkey" classname="org.apache.tools.ant.taskdefs.GenerateKey"/>
<taskdef name="get" classname="org.apache.tools.ant.taskdefs.Get"/>
<taskdef name="gunzip" classname="org.apache.tools.ant.taskdefs.GUnzip"/>
<taskdef name="gzip" classname="org.apache.tools.ant.taskdefs.GZip"/>
<taskdef name="icontract" classname="org.apache.tools.ant.taskdefs.optional.IContract"/>
<taskdef name="ilasm" classname="org.apache.tools.ant.taskdefs.optional.dotnet.Ilasm"/>
<taskdef name="input" classname="org.apache.tools.ant.taskdefs.Input"/>
<taskdef name="iplanet-ejbc" classname="org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask"/>
<taskdef name="jar" classname="org.apache.tools.ant.taskdefs.Jar"/>
<taskdef name="jarlib-available" classname="org.apache.tools.ant.taskdefs.optional.extension.JarLibAvailableTask"/>
<taskdef name="jarlib-display" classname="org.apache.tools.ant.taskdefs.optional.extension.JarLibDisplayTask"/>
<taskdef name="jarlib-manifest" classname="org.apache.tools.ant.taskdefs.optional.extension.JarLibManifestTask"/>
<taskdef name="jarlib-resolve" classname="org.apache.tools.ant.taskdefs.optional.extension.JarLibResolveTask"/>
<taskdef name="java" classname="org.apache.tools.ant.taskdefs.Java"/>
<taskdef name="javac" classname="org.apache.tools.ant.taskdefs.Javac"/>
<taskdef name="javacc" classname="org.apache.tools.ant.taskdefs.optional.javacc.JavaCC"/>
<taskdef name="javadoc" classname="org.apache.tools.ant.taskdefs.Javadoc"/>
<taskdef name="javah" classname="org.apache.tools.ant.taskdefs.optional.Javah"/>
<taskdef name="jdepend" classname="org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask"/>
<taskdef name="jjtree" classname="org.apache.tools.ant.taskdefs.optional.javacc.JJTree"/>
<taskdef name="jlink" classname="org.apache.tools.ant.taskdefs.optional.jlink.JlinkTask"/>
<taskdef name="jpcoverage" classname="org.apache.tools.ant.taskdefs.optional.sitraka.Coverage"/>
<taskdef name="jpcovreport" classname="org.apache.tools.ant.taskdefs.optional.sitraka.CovReport"/>
<taskdef name="jspc" classname="org.apache.tools.ant.taskdefs.optional.jsp.JspC"/>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator"/>
<taskdef name="loadfile" classname="org.apache.tools.ant.taskdefs.LoadFile"/>
<taskdef name="loadproperties" classname="org.apache.tools.ant.taskdefs.LoadProperties"/>
<taskdef name="mail" classname="org.apache.tools.ant.taskdefs.email.EmailTask"/>
<taskdef name="manifest" classname="org.apache.tools.ant.taskdefs.Manifest"/>
<taskdef name="maudit" classname="org.apache.tools.ant.taskdefs.optional.metamata.MAudit"/>
<taskdef name="mimemail" classname="org.apache.tools.ant.taskdefs.optional.net.MimeMail"/>
<taskdef name="mkdir" classname="org.apache.tools.ant.taskdefs.Mkdir"/>
<taskdef name="mmetrics" classname="org.apache.tools.ant.taskdefs.optional.metamata.MMetrics"/>
<taskdef name="move" classname="org.apache.tools.ant.taskdefs.Move"/>
<taskdef name="mparse" classname="org.apache.tools.ant.taskdefs.optional.metamata.MParse"/>
<taskdef name="native2ascii" classname="org.apache.tools.ant.taskdefs.optional.Native2Ascii"/>
<taskdef name="netrexxc" classname="org.apache.tools.ant.taskdefs.optional.NetRexxC"/>
<taskdef name="p4add" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Add"/>
<taskdef name="p4change" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Change"/>
<taskdef name="p4counter" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Counter"/>
<taskdef name="p4edit" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Edit"/>
<taskdef name="p4have" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Have"/>
<taskdef name="p4label" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Label"/>
<taskdef name="p4submit" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Submit"/>
<taskdef name="p4sync" classname="org.apache.tools.ant.taskdefs.optional.perforce.P4Sync"/>
<taskdef name="patch" classname="org.apache.tools.ant.taskdefs.Patch"/>
<taskdef name="pathconvert" classname="org.apache.tools.ant.taskdefs.PathConvert"/>
<taskdef name="property" classname="org.apache.tools.ant.taskdefs.Property"/>
<taskdef name="propertyfile" classname="org.apache.tools.ant.taskdefs.optional.PropertyFile"/>
<taskdef name="pvcs" classname="org.apache.tools.ant.taskdefs.optional.pvcs.Pvcs"/>
<taskdef name="record" classname="org.apache.tools.ant.taskdefs.Recorder"/>
<taskdef name="renameext" classname="org.apache.tools.ant.taskdefs.optional.RenameExtensions"/>
<taskdef name="replace" classname="org.apache.tools.ant.taskdefs.Replace"/>
<taskdef name="replaceregexp" classname="org.apache.tools.ant.taskdefs.optional.ReplaceRegExp"/>
<taskdef name="rmic" classname="org.apache.tools.ant.taskdefs.Rmic"/>
<taskdef name="rpm" classname="org.apache.tools.ant.taskdefs.optional.Rpm"/>
<taskdef name="script" classname="org.apache.tools.ant.taskdefs.optional.Script"/>
<taskdef name="serverdeploy" classname="org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy"/>
<taskdef name="setproxy" classname="org.apache.tools.ant.taskdefs.optional.net.SetProxy"/>
<taskdef name="signjar" classname="org.apache.tools.ant.taskdefs.SignJar"/>
<taskdef name="sleep" classname="org.apache.tools.ant.taskdefs.Sleep"/>
<taskdef name="soscheckin" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckin"/>
<taskdef name="soscheckout" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSCheckout"/>
<taskdef name="sosget" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSGet"/>
<taskdef name="soslabel" classname="org.apache.tools.ant.taskdefs.optional.sos.SOSLabel"/>
<taskdef name="sound" classname="org.apache.tools.ant.taskdefs.optional.sound.SoundTask"/>
<taskdef name="splash" classname="org.apache.tools.ant.taskdefs.optional.splash.SplashTask"/>
<taskdef name="sql" classname="org.apache.tools.ant.taskdefs.SQLExec"/>
<taskdef name="stcheckin" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin"/>
<taskdef name="stcheckout" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout"/>
<taskdef name="stlabel" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamLabel"/>
<taskdef name="stlist" classname="org.apache.tools.ant.taskdefs.optional.starteam.StarTeamList"/>
<taskdef name="style" classname="org.apache.tools.ant.taskdefs.XSLTProcess"/>
<taskdef name="stylebook" classname="org.apache.tools.ant.taskdefs.optional.StyleBook"/>
<taskdef name="tar" classname="org.apache.tools.ant.taskdefs.Tar"/>
<taskdef name="taskdef" classname="org.apache.tools.ant.taskdefs.Taskdef"/>
<taskdef name="telnet" classname="org.apache.tools.ant.taskdefs.optional.net.TelnetTask"/>
<taskdef name="tempfile" classname="org.apache.tools.ant.taskdefs.TempFile"/>
<taskdef name="test" classname="org.apache.tools.ant.taskdefs.optional.Test"/>
<taskdef name="touch" classname="org.apache.tools.ant.taskdefs.Touch"/>
<taskdef name="translate" classname="org.apache.tools.ant.taskdefs.optional.i18n.Translate"/>
<taskdef name="tstamp" classname="org.apache.tools.ant.taskdefs.Tstamp"/>
<taskdef name="typedef" classname="org.apache.tools.ant.taskdefs.Typedef"/>
<taskdef name="unjar" classname="org.apache.tools.ant.taskdefs.Expand"/>
<taskdef name="untar" classname="org.apache.tools.ant.taskdefs.Untar"/>
<taskdef name="unwar" classname="org.apache.tools.ant.taskdefs.Expand"/>
<taskdef name="unzip" classname="org.apache.tools.ant.taskdefs.Expand"/>
<taskdef name="uptodate" classname="org.apache.tools.ant.taskdefs.UpToDate"/>
<taskdef name="vajexport" classname="org.apache.tools.ant.taskdefs.optional.ide.VAJExport"/>
<taskdef name="vajimport" classname="org.apache.tools.ant.taskdefs.optional.ide.VAJImport"/>
<taskdef name="vajload" classname="org.apache.tools.ant.taskdefs.optional.ide.VAJLoadProjects"/>
<taskdef name="vssadd" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSADD"/>
<taskdef name="vsscheckin" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKIN"/>
<taskdef name="vsscheckout" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT"/>
<taskdef name="vsscp" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCP"/>
<taskdef name="vsscreate" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSCREATE"/>
<taskdef name="vssget" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSGET"/>
<taskdef name="vsshistory" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSHISTORY"/>
<taskdef name="vsslabel" classname="org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL"/>
<taskdef name="waitfor" classname="org.apache.tools.ant.taskdefs.WaitFor"/>
<taskdef name="war" classname="org.apache.tools.ant.taskdefs.War"/>
<taskdef name="wljspc" classname="org.apache.tools.ant.taskdefs.optional.jsp.WLJspc"/>
<taskdef name="wlrun" classname="org.apache.tools.ant.taskdefs.optional.ejb.WLRun"/>
<taskdef name="wlstop" classname="org.apache.tools.ant.taskdefs.optional.ejb.WLStop"/>
<taskdef name="wsdltodotnet" classname="org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet"/>
<taskdef name="xmlproperty" classname="org.apache.tools.ant.taskdefs.XmlProperty"/>
<taskdef name="xmlvalidate" classname="org.apache.tools.ant.taskdefs.optional.XMLValidateTask"/>
<taskdef name="xslt" classname="org.apache.tools.ant.taskdefs.XSLTProcess"/>
<taskdef name="zip" classname="org.apache.tools.ant.taskdefs.Zip"/>

<!-- Deprecated tasks -->
<taskdef name="copydir" classname="org.apache.tools.ant.taskdefs.Copydir"/>
<taskdef name="copyfile" classname="org.apache.tools.ant.taskdefs.Copyfile"/>
<taskdef name="deltree" classname="org.apache.tools.ant.taskdefs.Deltree"/>
<taskdef name="rename" classname="org.apache.tools.ant.taskdefs.Rename"/>
<taskdef name="starteam" classname="org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut"/>

<!-- typedefs -->
<typedef name="classfileset" classname="org.apache.tools.ant.types.optional.depend.ClassfileSet"/>
<typedef name="description" classname="org.apache.tools.ant.types.Description"/>
<typedef name="dirset" classname="org.apache.tools.ant.types.DirSet"/>
<typedef name="extension" classname="org.apache.tools.ant.taskdefs.optional.extension.ExtensionAdapter"/>
<typedef name="extensionSet" classname="org.apache.tools.ant.taskdefs.optional.extension.ExtensionSet"/>
<typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/>
<typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
<typedef name="filterchain" classname="org.apache.tools.ant.types.FilterChain"/>
<typedef name="filterreader" classname="org.apache.tools.ant.types.AntFilterReader"/>
<typedef name="filterset" classname="org.apache.tools.ant.types.FilterSet"/>
<typedef name="libfileset" classname="org.apache.tools.ant.taskdefs.optional.extension.LibFileSet"/>
<typedef name="mapper" classname="org.apache.tools.ant.types.Mapper"/>
<typedef name="path" classname="org.apache.tools.ant.types.Path"/>
<typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/>
<typedef name="regexp" classname="org.apache.tools.ant.types.RegularExpression"/>
<typedef name="selector" classname="org.apache.tools.ant.types.selectors.SelectSelector"/>
<typedef name="substitution" classname="org.apache.tools.ant.types.Substitution"/>
<typedef name="xmlcatalog" classname="org.apache.tools.ant.types.XMLCatalog"/>
</antlib>

+ 0
- 129
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1CompatException.java View File

@@ -1,129 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

import org.apache.ant.common.util.Location;
import org.apache.ant.common.util.AntException;

/**
* An exception in the Ant1 compatability layer.
*
* @author Conor MacNeill
*/
public class Ant1CompatException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public Ant1CompatException(String msg) {
super(msg);
}

/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public Ant1CompatException(String msg, Location location) {
super(msg, location);
}

/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public Ant1CompatException(String msg, Throwable cause) {
super(msg, cause);
}

/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public Ant1CompatException(String msg, Throwable cause,
Location location) {
super(msg, cause, location);
}

/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public Ant1CompatException(Throwable cause) {
super(cause);
}

/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public Ant1CompatException(Throwable cause, Location location) {
super(cause, location);
}
}


+ 0
- 136
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Converter.java View File

@@ -1,136 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

import org.apache.ant.common.antlib.AbstractConverter;
import org.apache.ant.common.antlib.ConverterException;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path;

/**
* A converter to convert to the types supported by the Ant1 Ant library
*
* @author Conor MacNeill
* @created 1 February 2002
*/
public class Ant1Converter extends AbstractConverter {

/** The project instance for this converter */
private Project project;

/**
* Constructor for the Ant1Converter object
*
* @param project the project for this converter. It is used in the
* conversion of some of the supported types.
*/
public Ant1Converter(Project project) {
this.project = project;
}

/**
* Get the list of classes this converter is able to convert to.
*
* @return an array of Class objects representing the classes this
* converter handles.
*/
public Class[] getTypes() {
return new Class[]{Path.class, EnumeratedAttribute.class};
}

/**
* Convert a string from the value given to an instance of the given
* type.
*
* @param value The value to be converted
* @param type the desired type of the converted object
* @return the value of the converted object
* @exception ConverterException if the conversion cannot be made
*/
public Object convert(String value, Class type) throws ConverterException {
if (type.equals(Path.class)) {
return new Path(project, value);
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) {
try {
EnumeratedAttribute ea
= (EnumeratedAttribute) type.newInstance();
ea.setValue(value);
return ea;
} catch (InstantiationException e) {
throw new ConverterException(e);
} catch (IllegalAccessException e) {
throw new ConverterException(e);
}

} else {
throw new ConverterException("This converter does not handle "
+ type.getName());
}
}

/**
* This method allows a converter to indicate whether it can create the
* given type which is a sub-type of one of the converter's main types
* indicated in getTypes. Most converters can return false here.
*
* @param subType the sub-type
* @return true if this converter can convert a string representation to
* the given subclass of one of its main class
*/
public boolean canConvertSubType(Class subType) {
return EnumeratedAttribute.class.isAssignableFrom(subType);
}

}


+ 0
- 212
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java View File

@@ -1,212 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.StandardLibFactory;
import org.apache.ant.common.service.EventService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.init.LoaderUtils;
import java.lang.reflect.InvocationTargetException;
/**
* The factory object for the Ant1 compatability Ant library
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class Ant1Factory extends StandardLibFactory {
/**
* A Project instance associated with the factory - used in the creation
* of tasks and types
*/
private Project project;
/** The Ant context for this factory */
private AntContext context;

/**
* Initialise the factory
*
* @param context the context for this factory to use to access core
* services.
* @exception AntException if the factory cannot be initialised.
*/
public void init(AntContext context) throws AntException {
if (project != null) {
return;
}

this.context = context;
// set the system classpath. In Ant2, the system classpath will not
// in general, have any useful information. For Ant1 compatability
// we set it now to include the Ant1 facade classes
System.setProperty("java.class.path", getAnt1Classpath());

project = new Project(this);
project.init(context);

EventService eventService =
(EventService) context.getCoreService(EventService.class);
eventService.addBuildListener(project);
}


/**
* Create an instance of the given component class
*
* @param componentClass the class for which an instance is required
* @param localName the name within the library under which the task is
* defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception Ant1CompatException if there is a problem creating the task
*/
public Object createComponent(Class componentClass, String localName)
throws InstantiationException, IllegalAccessException,
Ant1CompatException {
try {
java.lang.reflect.Constructor constructor = null;
// DataType can have a "no arg" constructor or take a single
// Project argument.
Object component = null;
try {
constructor = componentClass.getConstructor(new Class[0]);
component = constructor.newInstance(new Object[0]);
} catch (NoSuchMethodException nse) {
constructor
= componentClass.getConstructor(new Class[]{Project.class});
component = constructor.newInstance(new Object[]{project});
}

if (component instanceof ProjectComponent) {
((ProjectComponent) component).setProject(project);
}
return component;
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
String msg = "Could not create component of type: "
+ componentClass.getName() + " due to " + t;
throw new Ant1CompatException(msg, t);
} catch (NoSuchMethodException e) {
throw new Ant1CompatException("Unable to find an appropriate "
+ "constructor for component " + componentClass.getName(), e);
}
}

/**
* Create an instance of the given class
*
* @param requiredClass the class for which an instance is
* required
* @return a instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception Ant1CompatException if there is a problem creating the
* converter
*/
public Object createInstance(Class requiredClass)
throws InstantiationException, IllegalAccessException,
Ant1CompatException {

java.lang.reflect.Constructor c = null;

Object instance = null;
try {
try {
c = requiredClass.getConstructor(new Class[0]);
instance = c.newInstance(new Object[0]);
} catch (NoSuchMethodException nse) {
c = requiredClass.getConstructor(new Class[]{Project.class});
instance = c.newInstance(new Object[]{project});
}

return instance;
} catch (java.lang.reflect.InvocationTargetException ite) {
Throwable t = ite.getTargetException();
String msg = "Could not create instance of type: "
+ requiredClass.getName() + " due to " + t;
throw new Ant1CompatException(msg, t);
} catch (NoSuchMethodException e) {
throw new Ant1CompatException("Unable to find an appropriate "
+ "constructor for class " + requiredClass.getName(), e);
}
}

/**
* Register an element which has been created as the result of calling a
* create method.
*
* @param createdElement the element that the component created
* @exception AntException if there is a problem registering the
* element
*/
public void registerCreatedElement(Object createdElement)
throws AntException {
if (createdElement instanceof ProjectComponent) {
ProjectComponent component = (ProjectComponent) createdElement;
component.setProject(project);
}
}

/**
* Get an Ant1 equivalent classpath
*
* @return an Ant1 suitable classpath
*/
String getAnt1Classpath() {
ClassLoader classLoader = getClass().getClassLoader();
String path = LoaderUtils.getClasspath(classLoader);
return path;
}
}


+ 0
- 95
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1InputHandler.java View File

@@ -1,95 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

import org.apache.ant.common.service.InputService;
import org.apache.ant.common.util.AntException;
import org.apache.tools.ant.input.InputHandler;
import org.apache.tools.ant.input.InputRequest;

/**
* Uses the core's input service to handle input
*
* @author Conor MacNeill
* @created 30 April 2002
*/
public class Ant1InputHandler implements InputHandler {
/** Core's input service instance */
private InputService inputService;

/**
* Constructor for the Ant1InputHandler
*
* @param inputService the core's input service instance to which input
* requests will be delgated.
*/
public Ant1InputHandler(InputService inputService) {
this.inputService = inputService;
}

/**
* Pass input request into the core service
*
* @param request the input request
* @exception BuildException if there is a problem handling the request.
*/
public void handleInput(InputRequest request) throws BuildException {
try {
inputService.handleInput(request);
} catch (AntException e) {
throw new BuildException(e);
}
}
}


+ 0
- 1525
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
File diff suppressed because it is too large
View File


+ 0
- 146
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/ProjectComponent.java View File

@@ -1,146 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.util.AntException;

/**
* ProjectComponent facade
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public abstract class ProjectComponent {
/** The project in which the project component operates */
protected Project project;
/** The core context for this component */
private AntContext context;
/** The type of the component bneing created */
private String componentType;

/**
* Sets the project of the ProjectComponent
*
* @param project the project object with which this component is
* associated
*/
public void setProject(Project project) {
this.project = project;
}

/**
* Gets the project of the ProjectComponent
*
* @return the project
*/
public Project getProject() {
return project;
}

/**
* Gets the componentType of the ProjectComponent
*
* @return the componentType value
*/
public String getComponentType() {
return componentType;
}


/**
* Get the context associated with this component
*
* @return the AntContext
*/
public AntContext getAntContext() {
return context;
}

/**
* Initialise this component
*
* @param context the core context for this component
* @param componentType the component type of this component
* @exception AntException if the component cannot be initialized
*/
public void init(AntContext context, String componentType)
throws AntException {
this.context = context;
this.componentType = componentType;

}

/**
* Log a message as a build event
*
* @param message the message to be logged
* @param level the priority level of the message
*/
public void log(String message, int level) {
if (context != null) {
context.log(message, level);
}
}

/**
* Log a message as a build event
*
* @param message the message to be logged
*/
public void log(String message) {
log(message, Project.MSG_INFO);
}
}


+ 0
- 150
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/ProjectHelper.java View File

@@ -1,150 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;
import java.util.Hashtable;
import java.util.Vector;
import java.io.File;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.PropertyUtils;

/**
* Ant1 ProjectHelper facade
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class ProjectHelper {
/**
* This method will parse a string containing ${value} style property
* values into two lists. The first list is a collection of text
* fragments, while the other is a set of string property names null
* entries in the first list indicate a property reference from the
* second list.
*
* @param value the string to be parsed
* @param fragments the fragments parsed out of the string
* @param propertyRefs the property refs to be replaced
*/
public static void parsePropertyString(String value, Vector fragments,
Vector propertyRefs) {
try {
PropertyUtils.parsePropertyString(value, fragments, propertyRefs);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Replace ${} style constructions in the given value with the string
* value of the corresponding data types.
*
* @param value the string to be scanned for property references.
* @param project the project object which contains the property values
* @return the string with the property references replaced with their
* project values
* @exception BuildException if there is a problem replacing the
* property values.
*/
public static String replaceProperties(Project project, String value)
throws BuildException {
try {
AntContext context = project.getContext();
DataService dataService
= (DataService) context.getCoreService(DataService.class);
return dataService.replacePropertyRefs(value);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Replace ${} style constructions in the given value with the string
* value of the corresponding data types.
*
* @param value the string to be scanned for property references.
* @param project the project object
* @param keys the collection of property values to use
* @return the string with the property references replaced with their
* project values
*/
public static String replaceProperties(Project project, String value,
Hashtable keys) {
try {
AntContext context = project.getContext();
DataService dataService
= (DataService) context.getCoreService(DataService.class);
return dataService.replacePropertyRefs(value, keys);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Old method to build a project.
*
* @param project The project to configure. Must not be <code>null</code>.
* @param buildFile An XML file giving the project's configuration.
* Must not be <code>null</code>.
*
* @exception BuildException always
* @deprecated
*/
public static void configureProject(Project project, File buildFile)
throws BuildException {
project.configure(buildFile);
}
}


+ 0
- 191
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -1,191 +0,0 @@
/*
* 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;

import org.xml.sax.AttributeList;

/**
* Implementation shell of the corresponding Ant1 class
*
* @author Conor MacNeill
* @created 26 June 2002
*/
public class RuntimeConfigurable {

/**
* Sole constructor creating a wrapper for the specified object.
*
* @param proxy The element to configure. Must not be <code>null</code>.
* @param elementTag The tag name generating this element. Should not be
* <code>null</code>.
*/
public RuntimeConfigurable(Object proxy, String elementTag) {
}

/**
* Sets the element to configure. This is used when the real type of an
* element isn't known at the time of wrapper creation.
*
* @param proxy The element to configure. Must not be <code>null</code>.
*/
void setProxy(Object proxy) {
}

/**
* Sets the attributes for the wrapped element.
*
* @param attributes List of attributes defined in the XML for this
* element. May be <code>null</code>.
*/
public void setAttributes(AttributeList attributes) {
}

/**
* Returns the list of attributes for the wrapped element.
*
* @return An AttributeList representing the attributes defined in the XML
* for this element. May be <code>null</code>.
*/
public AttributeList getAttributes() {
return null;
}

/**
* Adds a child element to the wrapped element.
*
* @param child The child element wrapper to add to this one. Must not be
* <code>null</code>.
*/
public void addChild(RuntimeConfigurable child) {
}

/**
* Returns the child wrapper at the specified position within the list.
*
* @param index The index of the child to return.
* @return The child wrapper at position <code>index</code> within the
* list.
*/
RuntimeConfigurable getChild(int index) {
return null;
}

/**
* Adds characters from #PCDATA areas to the wrapped element.
*
* @param data Text to add to the wrapped element. Should not
* be <code>null</code>.
*/
public void addText(String data) {
}

/**
* Adds characters from #PCDATA areas to the wrapped element.
*
* @param buf A character array of the text within the element. Must not
* be <code>null</code>.
* @param start The start element in the array.
* @param count The number of characters to read from the array.
*/
public void addText(char[] buf, int start, int count) {
}

/**
* Returns the tag name of the wrapped element.
*
* @return The tag name of the wrapped element. This is unlikely to be
* <code>null</code>, but may be.
*/
public String getElementTag() {
return null;
}

/**
* Configures the wrapped element and all its children. The attributes and
* text for the wrapped element are configured, and then each child is
* configured and added. Each time the wrapper is configured, the
* attributes and text for it are reset. If the element has an
* <code>id</code> attribute, a reference is added to the project as well.
*
* @param p The project containing the wrapped element. Must not be
* <code>null</code>.
* @exception BuildException if the configuration fails, for instance due
* to invalid attributes or children, or text being added to an
* element which doesn't accept it.
*/
public void maybeConfigure(Project p) throws BuildException {
maybeConfigure(p, true);
}

/**
* Configures the wrapped element. The attributes and text for the wrapped
* element are configured. Each time the wrapper is configured, the
* attributes and text for it are reset. If the element has an
* <code>id</code> attribute, a reference is added to the project as well.
*
* @param p The project containing the wrapped element. Must not be
* <code>null</code>.
* @param configureChildren Whether to configure child elements as well.
* if true, child elements will be configured after the wrapped
* element.
* @exception BuildException if the configuration fails, for instance due
* to invalid attributes or children, or text being added to an
* element which doesn't accept it.
*/
public void maybeConfigure(Project p, boolean configureChildren)
throws BuildException {
}

}


+ 0
- 106
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Target.java View File

@@ -1,106 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

/**
* Ant1 Target facade.
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class Target {
/** The project to which this target belongs */
private Project project;

/** The name of this target */
private String name;

/**
* Construct a Target that is part of the project
*
* @param project the target's project
*/
public Target(Project project) {
this.project = project;
}

/**
* set the name of the target
*
* @param name the new name value
*/
public void setName(String name) {
this.name = name;
}

/**
* get the project to which this target belongs
*
* @return the target's project.
*/
public Project getProject() {
return project;
}

/**
* Gets the name of the Target
*
* @return the target's name
*/
public String getName() {
return name;
}

}


+ 0
- 322
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java View File

@@ -1,322 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.AntException;

/**
* Ant1 Task facade
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public abstract class Task extends ProjectComponent
implements org.apache.ant.common.antlib.Task {
/** the name of this task */
protected String taskName;
/** The target with which this target is associated */
protected Target target = null;
/** The type of this target */
protected String taskType = null;
/** The description of this task */
protected String description = null;
/** The location within the build file of this project component */
protected Location location;

/**
* 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 {}

/**
* Set the name to use in logging messages.
*
* @param name the name to use in logging messages.
*/
public void setTaskName(String name) {
this.taskName = name;
}


/**
* Sets the target object of this task.
*
* @param target Target in whose scope this task belongs.
*/
public void setOwningTarget(Target target) {
this.target = target;
}


/**
* Has this task been marked invalid?
*
* @since Ant 1.5
*/
protected final boolean isInvalid() {
return false;
}

public void maybeConfigure() throws BuildException {
// XXX
throw new BuildException("Not supported");
}

/**
* 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() {
// XXX
throw new BuildException("Not supported");
}

/**
* Sets a description of the current action. It will be usefull in
* commenting what we are doing.
*
* @param desc the new description value
*/
public void setDescription(String desc) {
description = desc;
}

/**
* Get the name to use in logging messages.
*
* @return the name to use in logging messages.
*/
public String getTaskName() {
return taskName;
}


/**
* Get the Target to which this task belongs
*
* @return the task's target.
*/
public Target getOwningTarget() {
return target;
}

/**
* Gets the description of the Task
*
* @return the task's description
*/
public String getDescription() {
return description;
}

/**
* Gets the location of the ProjectComponent's associated model element
* in the build file
*
* @return the location of the associated model element
*/
public Location getLocation() {
return location;
}


/**
* Add a nested task to this Ant1 task.
*
* @param task The task to be added
* @exception AntException if the task cannot be added.
*/
public void addNestedTask(org.apache.ant.common.antlib.Task task)
throws AntException {

if (!(this instanceof TaskContainer)) {
throw new BuildException("Can't add tasks to this task");
}
// wrap the Ant2 task in a TaskAdapter
TaskContainer container = (TaskContainer) this;
if (task instanceof Task) {
container.addTask((Task) task);
} else {
TaskAdapter adapter = new TaskAdapter();
adapter.setProxy(task);
adapter.setProject(getProject());
adapter.init(task.getAntContext(), task.getComponentType());
container.addTask(adapter);
}
}

/**
* Initialise this component
*
* @param context the core context for this component
* @param componentType the component type of this component
* @exception AntException if the component cannot be initialized
*/
public void init(AntContext context, String componentType)
throws AntException {
super.init(context, componentType);

taskType = componentType;
taskName = componentType;

org.apache.ant.common.util.Location contextLocation
= context.getLocation();

if (contextLocation
== org.apache.ant.common.util.Location.UNKNOWN_LOCATION) {
location = Location.UNKNOWN_LOCATION;
} else {
location = new Location(contextLocation.getSource(),
contextLocation.getLineNumber(),
contextLocation.getColumnNumber());
}
init();
}


/** Initialise this task */
public void init() {
}

/** Validate this component */
public void validateComponent() {
// no default validation for Ant1 tasks
}

/** Execute this task sending the appropriate build events */
public final void perform() {
try {
AntContext context = getAntContext();
ExecService execService
= (ExecService) context.getCoreService(ExecService.class);
execService.executeTask(this);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Handle Output produced by the task. When a task prints to System.out
* the container may catch this and redirect the content back to the
* task by invoking this method. This method must NOT call System.out,
* directly or indirectly.
*
* @param line The line of content produce by the task
*/
public void handleSystemOut(String line) {
handleOutput(line);
}

/**
* Handle error information produced by the task. When a task prints to
* System.err the container may catch this and redirect the content back
* to the task by invoking this method. This method must NOT call
* System.err, directly or indirectly.
*
* @param line The line of error info produce by the task
*/
public void handleSystemErr(String line) {
// default behaviout is to log at WARN level
handleErrorOutput(line);
}

/**
* Handle output captured for this task
*
* @param line the captured output
*/
protected void handleOutput(String line) {
log(line, Project.MSG_INFO);
}

/**
* Handle error output captured for this task
*
* @param line the captured error output
*/
protected void handleErrorOutput(String line) {
log(line, Project.MSG_ERR);
}

/**
* Set the name with which the task has been invoked.
*
* @param type the name the task has been invoked as.
*/
void setTaskType(String type) {
this.taskType = type;
}

/**
* Sets the file location where this task was defined.
*
* @param location the new location value
*/
public void setLocation(Location location) {
this.location = location;
}

}


+ 0
- 71
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/TaskContainer.java View File

@@ -1,71 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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;

/**
* TaskContainer facade
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public interface TaskContainer
extends org.apache.ant.common.antlib.TaskContainer {
/**
* Add a task to this container
*
* @param task the task to be added
*/
void addTask(Task task);
}


+ 0
- 71
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/input/InputRequest.java View File

@@ -1,71 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.input;

/**
* Encapsulates an input request.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
* @version $Revision$
* @since Ant 1.5
*/
public class InputRequest extends org.apache.ant.common.input.InputRequest {
/**
* @param prompt The prompt to show to the user. Must not be null.
*/
public InputRequest(String prompt) {
super(prompt);
}
}

+ 0
- 215
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -1,215 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.taskdefs;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ant.antlib.system.AntBase;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

/**
* Ant facade over system version of Ant
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class Ant extends Task {
/** The core Ant implementation to actually use */
private org.apache.ant.antlib.system.Ant realAnt = null;

/** The properties created by this task */
private List properties = new ArrayList();

/**
* If true, inherit all properties from parent Project If false, inherit
* only userProperties and those defined inside the ant call itself
*
* @param value true if the sub-build should receive all properties from
* this build
*/
public void setInheritAll(boolean value) {
realAnt.setInheritAll(value);
}

/**
* If true, inherit all references from parent Project If false, inherit
* only those defined inside the ant call itself
*
* @param value true if the subbuild should receive all references from
* the current build.
*/
public void setInheritRefs(boolean value) {
realAnt.setInheritRefs(value);
}

/**
* The directory which will be the base directory for the build
*
* @param d the base directory for the new build
*/
public void setDir(File d) {
realAnt.setDir(d);
}

/**
* set the build file, it can be either absolute or relative. If it is
* absolute, <tt>dir</tt> will be ignored, if it is relative it will be
* resolved relative to <tt>dir</tt> .
*
* @param s the name of the ant file either absolute or relative to the
* sub-build's basedir
*/
public void setAntfile(String s) {
realAnt.setAntFile(s);
}

/**
* set the target to execute. If none is defined it will execute the
* default target of the build file
*
* @param s the target to eb executed in the sub-build
*/
public void setTarget(String s) {
realAnt.setTarget(s);
}

/**
* Set the output file in which Ant stores output
*
* @param s name of the file to store output.
*/
public void setOutput(String s) {
// realAnt.setOutput(s);
}

/** Initialize the task */
public void init() {
AntContext context = getAntContext();
try {
ComponentService componentService = getComponentService();
AntLibFactory factory = getProject().getFactory();
realAnt = (org.apache.ant.antlib.system.Ant)
componentService.createComponent("ant.system", "ant");
} catch (AntException e) {
throw new BuildException(e);
}
}


/**
* Do the execution.
*
* @exception BuildException if the execution of the sub-build has a
* problem
*/
public void execute() throws BuildException {
for (Iterator i = properties.iterator(); i.hasNext();) {
Property property = (Property) i.next();
AntBase.Property newProperty = new AntBase.Property();
newProperty.setName(property.getName());
newProperty.setValue(property.getValue());
realAnt.addProperty(newProperty);
}
try {
realAnt.execute();
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Create a nested property element.
*
* @return the Property object to be configured.
*/
public Property createProperty() {
Property property = new Property();
properties.add(property);
return property;
}

/**
* create a reference element that identifies a data type that should be
* carried over to the new project.
*
* @param r the reference to be added to the call
*/
public void addReference(AntBase.Reference r) {
try {
realAnt.addReference(r);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Gets the componentService
*
* @return the componentService instance provided by the core
* @exception AntException if the service is not available.
*/
private ComponentService getComponentService() throws AntException {
AntContext context = getAntContext();
return (ComponentService)
context.getCoreService(ComponentService.class);
}

}


+ 0
- 165
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java View File

@@ -1,165 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.taskdefs;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ant.antlib.system.AntBase;
import org.apache.ant.antlib.system.AntCall;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

/**
* CallTarget facade over AntCall
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public class CallTarget extends Task {
/** The core AntCall implementation to actually use */
private AntCall antCall = null;

/** The properties created by this task */
private List properties = new ArrayList();

/**
* If true, inherit all properties from parent Project If false, inherit
* only userProperties and those defined inside the antcall call itself
*
* @param inherit the new inheritAll value
*/
public void setInheritAll(boolean inherit) {
antCall.setInheritAll(inherit);
}

/**
* Sets the target of the CallTarget
*
* @param target the new target value
*/
public void setTarget(String target) {
antCall.setTarget(target);
}

/** Initialize the task */
public void init() {
AntContext context = getAntContext();
try {
ComponentService componentService = getComponentService();
AntLibFactory factory = getProject().getFactory();
antCall = (AntCall) componentService.createComponent("ant.system",
"antcall");
} catch (AntException e) {
throw new BuildException(e);
}
}

/** execute the call */
public void execute() {
for (Iterator i = properties.iterator(); i.hasNext();) {
Property property = (Property) i.next();
AntBase.Property newProperty = new AntBase.Property();
newProperty.setName(property.getName());
newProperty.setValue(property.getValue());
antCall.addProperty(newProperty);
}
try {
antCall.execute();
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Create a nested param element.
*
* @return the Property object to be configured.
*/
public Property createParam() {
Property property = new Property();
properties.add(property);
return property;
}

/**
* create a reference element that identifies a data type that should be
* carried over to the new project.
*
* @param r the reference to be added to the call
*/
public void addReference(AntBase.Reference r) {
try {
antCall.addReference(r);
} catch (AntException e) {
throw new BuildException(e);
}
}

/**
* Gets the componentService
*
* @return the componentService instance provided by the core
* @exception AntException if the service is not available.
*/
private ComponentService getComponentService() throws AntException {
AntContext context = getAntContext();
return
(ComponentService) context.getCoreService(ComponentService.class);
}
}


+ 0
- 240
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/types/DataType.java View File

@@ -1,240 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.types;
import java.util.Stack;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;

import org.apache.tools.ant.ProjectComponent;

/**
* Ant1 DataType facade
*
* @author Conor MacNeill
* @created 31 January 2002
*/
public abstract class DataType extends ProjectComponent
implements org.apache.ant.common.antlib.DataType {

/** The description the user has set. */
protected String description = null;
/** Value to the refid attribute. */
protected Reference ref = null;
/**
* Are we sure we don't hold circular references? <p>
*
* Subclasses are responsible for setting this value to false if we'd
* need to investigate this condition (usually because a child element
* has been added that is a subclass of DataType).</p>
*/
protected boolean checked = true;

/**
* Sets a description of the current data type. It will be useful in
* commenting what we are doing.
*
* @param desc the new description value
*/
public void setDescription(String desc) {
description = desc;
}

/**
* Set the value of the refid attribute. <p>
*
* Subclasses may need to check whether any other attributes have been
* set as well or child elements have been created and thus override
* this method. if they do the must call <code>super.setRefid</code>.
* </p>
*
* @param ref the new refid value
*/
public void setRefid(Reference ref) {
this.ref = ref;
checked = false;
}

/**
* Sets the id of the DataType
*
* @param id the name under which the data type is to be referenced
*/
public void setId(String id) {
project.addReference(id, this);
}

/**
* Return the description for the current data type.
*
* @return the data type's description
*/
public String getDescription() {
return description;
}

/**
* Has the refid attribute of this element been set?
*
* @return true if this data type is a refeence to another instance
*/
public boolean isReference() {
return ref != null;
}

/** Validate this component */
public void validateComponent() {
// no default validation for Ant1 types
}


/**
* Performs the check for circular references and returns the referenced
* object.
*
* @param requiredClass the class which the object being referenced must
* support
* @param dataTypeName the name of the data type
* @return the refenced object
*/
protected Object getCheckedRef(Class requiredClass, String dataTypeName) {
if (!checked) {
Stack stk = new Stack();
stk.push(this);
dieOnCircularReference(stk, getProject());
}

Object o = ref.getReferencedObject(getProject());
if (!(requiredClass.isAssignableFrom(o.getClass()))) {
String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName;
throw new BuildException(msg);
} else {
return o;
}
}

/**
* Check to see whether any DataType we hold references to is included
* in the Stack (which holds all DataType instances that directly or
* indirectly reference this instance, including this instance itself).
* <p>
*
* If one is included, throw a BuildException created by {@link
* #circularReference circularReference}.</p> <p>
*
* This implementation is appropriate only for a DataType that cannot
* hold other DataTypes as children.</p> <p>
*
* The general contract of this method is that it shouldn't do anything
* if {@link #checked <code>checked</code>} is true and set it to true
* on exit.</p>
*
* @param stk stack used to check for a circular reference
* @param p the project
* @exception BuildException if this data type is a reference to an
* instance which depends on this data type
*/
protected void dieOnCircularReference(Stack stk, Project p)
throws BuildException {

if (checked || !isReference()) {
return;
}
Object o = ref.getReferencedObject(p);

if (o instanceof DataType) {
if (stk.contains(o)) {
throw circularReference();
} else {
stk.push(o);
((DataType) o).dieOnCircularReference(stk, p);
stk.pop();
}
}
checked = true;
}

/**
* Creates an exception that indicates that refid has to be the only
* attribute if it is set.
*
* @return an appropriate excpetion instance
*/
protected BuildException tooManyAttributes() {
return new BuildException("You must not specify more than "
+ "one attribute when using refid");
}

/**
* Creates an exception that indicates that this XML element must not
* have child elements if the refid attribute is set.
*
* @return an appropriate excpetion instance
*/
protected BuildException noChildrenAllowed() {
return new BuildException("You must not specify nested "
+ "elements when using refid");
}

/**
* Creates an exception that indicates the user has generated a loop of
* data types referencing each other.
*
* @return an appropriate excpetion instance
*/
protected BuildException circularReference() {
return new BuildException("This data type contains a "
+ "circular reference.");
}
}


+ 0
- 4
proposal/mutant/src/java/antlibs/monitor/antlib.xml View File

@@ -1,4 +0,0 @@
<antlib libid="antopt.monitor"
home="http://jakarta.apache.org/ant">
<aspect classname="org.apache.ant.antlib.monitor.MonitorAspect"/>
</antlib>

+ 0
- 135
proposal/mutant/src/java/antlibs/monitor/org/apache/ant/antlib/monitor/MonitorAspect.java View File

@@ -1,135 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.monitor;

import org.apache.ant.common.antlib.AbstractAspect;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.model.BuildElement;
import org.apache.ant.common.model.NamespaceValueCollection;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.event.MessageLevel;
import java.util.Date;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
* A monitoring aspect to help understand memory and performance
* characteristics.
*
* @author Conor MacNeill
*/
public class MonitorAspect extends AbstractAspect {
/** The log into which monitoring info is written */
private static PrintStream monitorLog;

/**
* Create a monitoring aspect instance. There will be one instance per
* active frame but they all share the same log output.
*/
public MonitorAspect() {
synchronized (MonitorAspect.class) {
if (monitorLog == null) {
try {
monitorLog
= new PrintStream(new FileOutputStream("monitor.log"));
monitorLog.println("Logging started at " + new Date());
} catch (IOException e) {
log("Unable to open monitor log", MessageLevel.WARNING);
}
}
}
}

/**
* This join point is activated just prior to task execution.
*
* @param task the task being executed.
* @param namespaceValues a collection of namesapce attribute values for use
* during the task execution - may be null if no namespace values are
* provided.
* @return an object which indicates that this aspect wishes to
* be notified after execution has been completed, in which case the obkect
* is returned to provide the aspect its context. If this returns null
* the aspect's postExecuteTask method will not be invoked.
* @exception AntException if the aspect cannot process the task.
*/
public Object preExecuteTask(Task task,
NamespaceValueCollection namespaceValues)
throws AntException {
System.gc();
AntContext taskContext = task.getAntContext();
BuildElement model = taskContext.getModel();
String name = (model == null) ? task.getClass().getName()
: model.getType();
return new MonitorRecord(name, taskContext.getLocation());
}

/**
* This join point is activated after a task has executed. The aspect
* may override the task's failure cause by returning a new failure.
*
* @param context the context the aspect provided in preExecuteTask.
* @param failureCause the current failure reason for the task.
*
* @return a new failure reason or null if the task is not to fail.
*/
public Throwable postExecuteTask(Object context, Throwable failureCause) {
MonitorRecord record = (MonitorRecord) context;
System.gc();
record.print(monitorLog);
return failureCause;
}
}

+ 0
- 112
proposal/mutant/src/java/antlibs/monitor/org/apache/ant/antlib/monitor/MonitorRecord.java View File

@@ -1,112 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.monitor;

import org.apache.ant.common.util.Location;
import java.io.PrintStream;

/**
* A record of some performance values at a particular time
*
* @author Conor MacNeill
*/
public class MonitorRecord {
/** The element name being monitored */
private String elementName;

/** The location in the build file */
private Location location;

/** System clock when task started */
private long startMillis;

/** Starting memory when task started */
private long startMemory;

/**
* Get the current used memory from the runtime
*
* @return the amount of memory in use.
*/
private long getMemoryUsage() {
Runtime rt = Runtime.getRuntime();
return rt.totalMemory() - rt.freeMemory();
}

/**
* Create a monitoring record.
*
* @param elementName the name of the element.
* @param location the build file location of the element.
*/
public MonitorRecord(String elementName, Location location) {
this.elementName = elementName;
this.location = location;
startMillis = System.currentTimeMillis();
startMemory = getMemoryUsage();
}

/**
* Print a summary of the monitor
*
* @param stream the stream onto which the summary is printed.
*/
public void print(PrintStream stream) {
long timeDiff = System.currentTimeMillis() - startMillis;
long memDiff = getMemoryUsage() - startMemory;
stream.println(location + elementName + " took " + timeDiff
+ " milliseconds, memory used at start " + startMemory
+ " which changed by " + memDiff);
}
}

+ 0
- 6
proposal/mutant/src/java/antlibs/script/antlib.xml View File

@@ -1,6 +0,0 @@
<antlib libid="antopt.script"
home="http://jakarta.apache.org/ant">

<factory classname="org.apache.ant.antlib.script.ScriptFactory"/>
<taskdef name="scriptdef" classname="org.apache.ant.antlib.script.ScriptDef"/>
</antlib>

+ 0
- 191
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java View File

@@ -1,191 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.script;
import com.ibm.bsf.BSFEngine;
import com.ibm.bsf.BSFException;
import com.ibm.bsf.BSFManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.DeferredTask;
import org.apache.ant.common.antlib.AntContext;

/**
* Task to import a component or components from a library
*
* @author Conor MacNeill
* @created 27 January 2002
*/
public class ScriptBase extends AbstractTask implements DeferredTask {
/** The script factory instance to be used by this script */
private ScriptFactory factory;
/** the name to which this script has been defined */
private String scriptName;

/** the attribute values set by the core */
private Map attributes = new HashMap();

/** Any embedded set by the core */
private String text = "";

/** A list of the nested element names which have been configured */
private List nestedElementNames = new ArrayList();
/** A list of the nested elements objects which have been configured */
private List nestedElements = new ArrayList();

/**
* Set the given attribute
*
* @param name the name of the attribute
* @param attributeValue the new attribute value
*/
public void setAttribute(String name, String attributeValue) {
attributes.put(name, attributeValue);
}

/**
* Add a nested element
*
* @param nestedElementName the nested element's name
* @param value the object being added
*/
public void addElement(String nestedElementName, Object value) {
nestedElementNames.add(nestedElementName);
nestedElements.add(value);
}


/**
* Execute the script
*
* @exception ScriptException if tghe script execution fails
*/
public void execute() throws ScriptException {
String language = factory.getScriptLanguage(scriptName);
String script = factory.getScript(scriptName);

try {
BSFManager manager = new BSFManager();
manager.declareBean("self", this, getClass());
manager.declareBean("context", getAntContext(), AntContext.class);

// execute the script
BSFEngine engine = manager.loadScriptingEngine(language);

engine.exec(scriptName, 0, 0, script);
for (Iterator i = attributes.keySet().iterator(); i.hasNext();) {
String attributeName = (String) i.next();
String value = (String) attributes.get(attributeName);
StringBuffer setter = new StringBuffer(attributeName);
setter.setCharAt(0, Character.toUpperCase(setter.charAt(0)));
engine.call(null, "set" + setter, new Object[]{value});
}

Iterator i = nestedElementNames.iterator();
Iterator j = nestedElements.iterator();
while (i.hasNext()) {
String nestedName = (String) i.next();
Object nestedElement = j.next();
StringBuffer adder = new StringBuffer(nestedName);
adder.setCharAt(0, Character.toUpperCase(adder.charAt(0)));
engine.call(null, "add" + adder, new Object[]{nestedElement});
}

engine.call(null, "execute", new Object[]{});
} catch (BSFException e) {
Throwable t = e;
Throwable te = e.getTargetException();
if (te != null) {
if (te instanceof ScriptException) {
throw (ScriptException) te;
} else {
t = te;
}
}
throw new ScriptException(t);
}
}

/**
* Defines the script.
*
* @param text Sets the value for the script variable.
*/
public void addText(String text) {
this.text += text;
}

/**
* Sets the factory of the ScriptBase
*
* @param factory the script factory this script instance will use
*/
protected void setFactory(ScriptFactory factory) {
this.factory = factory;
}

/**
* set the name of the script
*
* @param scriptName the script's defined name
*/
protected void setScriptName(String scriptName) {
this.scriptName = scriptName;
}

}


+ 0
- 128
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptDef.java View File

@@ -1,128 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.script;

import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.util.AntException;

/**
* Define a task using a script
*
* @author Conor MacNeill
* @created 11 February 2002
*/
public class ScriptDef extends AbstractTask {
/** The script factor to use */
private ScriptFactory factory;

/** the name by which this script will be activated */
private String name;

/** the scripting language used by the script */
private String language;

/** the script itself */
private String script = "";

/**
* set the name under which this script will be activated in a build
* file
*
* @param name the name of the script
*/
public void setName(String name) {
this.name = name;
}

/**
* Set the scripting language used by this script
*
* @param language the scripting language used by this script.
*/
public void setLanguage(String language) {
this.language = language;
}

/**
* Define the script. The script itself is stored in the factory where
* it is retried by the ScriptBase instance
*
* @exception AntException if the script cannot be defined
*/
public void execute() throws AntException {
// tell the factory about this script, under this name.
factory.defineScript(name, language, script);
}

/**
* Defines the script.
*
* @param text Sets the value for the script variable.
*/
public void addText(String text) {
this.script += text;
}

/**
* Set the script factory that will be used to store the script for
* later execution
*
* @param factory the script factory used to store script information.
*/
protected void setFactory(ScriptFactory factory) {
this.factory = factory;
}

}


+ 0
- 129
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptException.java View File

@@ -1,129 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.script;

import org.apache.ant.common.util.Location;
import org.apache.ant.common.util.AntException;

/**
* A Script related exception
*
* @author Conor MacNeill
*/
public class ScriptException extends AntException {
/**
* Constructs an exception with the given descriptive message.
*
* @param msg Description of or information about the exception.
*/
public ScriptException(String msg) {
super(msg);
}

/**
* Constructs an exception with the given descriptive message and a
* location in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public ScriptException(String msg, Location location) {
super(msg, location);
}

/**
* Constructs an exception with the given message and exception as a
* root cause.
*
* @param msg Description of or information about the exception.
* @param cause Throwable that might have cause this one.
*/
public ScriptException(String msg, Throwable cause) {
super(msg, cause);
}

/**
* Constructs an exception with the given message and exception as a
* root cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public ScriptException(String msg, Throwable cause,
Location location) {
super(msg, cause, location);
}

/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public ScriptException(Throwable cause) {
super(cause);
}

/**
* Constructs an exception with the given exception as a root cause and
* a location in a file.
*
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public ScriptException(Throwable cause, Location location) {
super(cause, location);
}
}


+ 0
- 205
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptFactory.java View File

@@ -1,205 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.script;
import java.util.HashMap;
import java.util.Map;

import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.StandardLibFactory;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;

/**
* The ScriptFactory class is a factory for the Scripting tasks. It stores
* the scripts as they are defined
*
* @author Conor MacNeill
* @created 11 February 2002
*/
public class ScriptFactory extends StandardLibFactory {
/**
* An inner class used to record information about defined scripts.
*
* @author Conor MacNeill
* @created 11 February 2002
*/
private static class ScriptInfo {
/** the scripting langauge to use */
private String language;
/** the script itself */
private String script;

/**
* Constructor for the ScriptInfo object
*
* @param language the language the script is written in
* @param script the script
*/
public ScriptInfo(String language, String script) {
this.language = language;
this.script = script;
}

/**
* Gets the language of the Script
*
* @return the language value
*/
public String getLanguage() {
return language;
}

/**
* Gets the script.
*
* @return the script text
*/
public String getScript() {
return script;
}
}

/** The core's Component Service instance */
private ComponentService componentService;

/** the scripts that have been defined */
private Map scripts = new HashMap();

/**
* Initialise the factory
*
* @param context the factory's context
* @exception AntException if the factory cannot be initialized
*/
public void init(AntContext context) throws AntException {
super.init(context);
componentService = (ComponentService)
context.getCoreService(ComponentService.class);
try {
Class.forName("com.ibm.bsf.BSFManager");
} catch (ClassNotFoundException e) {
throw new ScriptException("The script Ant library requires "
+ "bsf.jar to be available");
} catch (NoClassDefFoundError e) {
throw new ScriptException("The script Ant library requires "
+ "bsf.jar to be available. The class " + e.getMessage()
+ "appears to be missing");
}
}

/**
* Create an instance of the given component class
*
* @param componentClass the class for which an instance is required
* @param localName the name within the library undeer which the task is
* defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception AntException if there is a problem creating the task
*/
public Object createComponent(Class componentClass, String localName)
throws InstantiationException, IllegalAccessException, AntException {
Object component = super.createComponent(componentClass, localName);

if (component instanceof ScriptDef) {
ScriptDef scriptDef = (ScriptDef) component;
scriptDef.setFactory(this);
} else if (component instanceof ScriptBase) {
ScriptBase scriptBase = (ScriptBase) component;
scriptBase.setFactory(this);
scriptBase.setScriptName(localName);
}
return component;
}

/**
* Get the script language of a script
*
* @param scriptName the name the script is defined under
* @return the script language name
*/
protected String getScriptLanguage(String scriptName) {
ScriptInfo scriptInfo = (ScriptInfo) scripts.get(scriptName);
return scriptInfo.getLanguage();
}

/**
* Get a script.
*
* @param scriptName the name the script is defined under
* @return the script text
*/
protected String getScript(String scriptName) {
ScriptInfo scriptInfo = (ScriptInfo) scripts.get(scriptName);
return scriptInfo.getScript();
}

/**
* Define a script
*
* @param name the name the script is to be defined under
* @param language the language of the scripr
* @param script the script text
* @exception AntException if the script cannot be defined
*/
protected void defineScript(String name, String language, String script)
throws AntException {
ScriptInfo scriptDefinition = new ScriptInfo(language, script);
scripts.put(name, scriptDefinition);
componentService.taskdef(this, ScriptBase.class.getClassLoader(),
name, ScriptBase.class.getName());
}
}


+ 0
- 21
proposal/mutant/src/java/antlibs/system/antlib.xml View File

@@ -1,21 +0,0 @@
<antlib libid="ant.system"
home="http://jakarta.apache.org/ant">

<taskdef name="libpath" classname="org.apache.ant.antlib.system.LibPath"/>
<taskdef name="loadlib" classname="org.apache.ant.antlib.system.LoadLib"/>
<taskdef name="import" classname="org.apache.ant.antlib.system.Import"/>

<taskdef name="ant" classname="org.apache.ant.antlib.system.Ant"/>
<taskdef name="antcall" classname="org.apache.ant.antlib.system.AntCall"/>

<taskdef name="ref" classname="org.apache.ant.antlib.system.Ref"/>
<taskdef name="parallel" classname="org.apache.ant.antlib.system.Parallel"/>
<taskdef name="sequential" classname="org.apache.ant.antlib.system.Sequential"/>
<converter classname="org.apache.ant.antlib.system.FileConverter"/>
<converter classname="org.apache.ant.antlib.system.URLConverter"/>
<converter classname="org.apache.ant.antlib.system.PrimitiveConverter"/>

<aspect classname="org.apache.ant.antlib.system.AntAspect"/>
</antlib>

+ 0
- 171
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java View File

@@ -1,171 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;
import java.io.File;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.ant.common.model.Project;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.service.FileService;
import org.apache.ant.common.service.MagicProperties;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.FileUtils;
import org.apache.ant.common.logger.DefaultLogger;
import org.apache.ant.common.event.MessageLevel;

/**
* The Ant task - used to execute a different build file
*
* @author Conor MacNeill
* @created 4 February 2002
*/
public class Ant extends AntBase {
/** The ant file to be run */
private String antFileName;
/** the base directory to use for the run */
private File baseDir;
/** File to capture any output */
private String output;


/**
* sets the file containing the XML representation model to build
*
* @param antFileName the file to build
*/
public void setAntFile(String antFileName) {
this.antFileName = antFileName;
}


/**
* Set the base directory for the execution of the build
*
* @param baseDir the base directory for the build
*/
public void setDir(File baseDir) {
this.baseDir = baseDir;
}


/**
* The output file for capturing the build output
*
* @param output the output file for capturing the build output
*/
public void setOutput(String output) {
this.output = output;
}


/**
* Run the sub-build
*
* @exception AntException if the build can't be run
*/
public void execute() throws AntException {
if (baseDir == null) {
baseDir = getExecService().getBaseDir();
}

File antFile = null;

if (antFileName == null) {
antFile = new File(baseDir, "build.ant");
if (!antFile.exists()) {
antFile = new File(baseDir, "build.xml");
}
} else {
antFile
= FileUtils.newFileUtils().resolveFile(baseDir, antFileName);
}

setProperty(MagicProperties.BASEDIR, baseDir.getAbsolutePath());

ExecService execService = getExecService();
Project model = execService.parseXMLBuildFile(antFile);
Object key = execService.setupBuild(model, getDataValues(), true);

setSubBuildKey(key);

if (output != null) {
FileService fileService
= (FileService) getCoreService(FileService.class);

File outfile = null;
if (baseDir != null) {
outfile = FileUtils.newFileUtils().resolveFile(baseDir, output);
} else {
outfile = fileService.resolveFile(output);
}
try {
PrintStream out
= new PrintStream(new FileOutputStream(outfile));
DefaultLogger logger = new DefaultLogger();
logger.setMessageOutputLevel(MessageLevel.INFO);
logger.setOutputPrintStream(out);
logger.setErrorPrintStream(out);
execService.addBuildListener(key, logger);
} catch (IOException ex) {
log("Ant: Can't set output to " + output,
MessageLevel.INFO);
}
}

execService.runBuild(key, getTargets());
setSubBuildKey(null);
}
}


+ 0
- 204
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntAspect.java View File

@@ -1,204 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;

import org.apache.ant.common.antlib.AbstractAspect;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.AspectException;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.model.BuildElement;
import org.apache.ant.common.model.NamespaceValueCollection;
import org.apache.ant.common.util.AttributeCollection;
import org.apache.ant.common.constants.Namespace;
import org.apache.ant.common.util.DataValue;

/**
* The Ant aspect - handles all ant aspects
*
* @author Conor MacNeill
*/
public class AntAspect extends AbstractAspect {
/** The core's data service implementation */
private DataService dataService = null;

/** The core's component service */
private ComponentService componentService = null;

/**
* Initialise the aspect with a context.
*
* @param context the aspect's context
* @exception AntException if the aspect cannot be initialised
*/
public void init(AntContext context) throws AntException {
super.init(context);
dataService = (DataService) context.getCoreService(DataService.class);
componentService
= (ComponentService) context.getCoreService(ComponentService.class);
}


/**
* This join point is activated before a component has been created.
* The aspect can return an object to be used rather than the core creating
* the object.
*
* @param component the component that has been created. This will be null
* unless another aspect has created the component
* @param model the Build model that applies to the component
*
* @return a component to use.
* @exception AntException if the aspect cannot process the component.
*/
public Object preCreateComponent(Object component, BuildElement model)
throws AntException {
String refId
= model.getNamespaceAttributeValue(Namespace.ANT_META_URI, "refid");
if (refId != null) {
if (model.getAttributeNames().hasNext() ||
model.getNestedElements().hasNext() ||
model.getText().length() != 0) {
throw new AspectException("Element <" + model.getType()
+ "> is defined by reference and hence may not specify "
+ "any attributes, nested elements or content",
model.getLocation());
}
Object referredComponent = dataService.getDataValue(refId);
if (referredComponent == null) {
throw new AspectException("The given ant:refid value '"
+ refId + "' is not defined", model.getLocation());
}
return referredComponent;
}
return component;
}

/**
* This join point is activated after a component has been created and
* configured. If the aspect wishes, an object can be returned in place
* of the one created by Ant.
*
* @param component the component that has been created.
* @param model the Build model used to create the component.
*
* @return a replacement for the component if desired. If null is returned
* the current component is used.
* @exception AntException if the component cannot be processed.
*/
public Object postCreateComponent(Object component, BuildElement model)
throws AntException {
String typeId
= model.getNamespaceAttributeValue(Namespace.ANT_META_URI, "id");

if (typeId != null) {
dataService.setDataValue(typeId,
new DataValue(component, DataValue.PRIORITY_BASE), true);
}

return super.postCreateComponent(component, model);
}

/**
* This join point is activated just prior to task execution.
*
* @param task the task being executed.
* @param namespaceValues a collection of namespace attribute values for use
* during the task execution.
*
* @return an objectwhich indicates that this aspect wishes to
* be notified after execution has been completed, in which case the obkect
* is returned to provide the aspect its context. If this returns null
* the aspect's postExecuteTask method will not be invoked.
* @exception AntException if the aspect cannot process the task.
*/
public Object preExecuteTask(Task task,
NamespaceValueCollection namespaceValues)
throws AntException {
AntAspectContext aspectContext = new AntAspectContext();
AttributeCollection antAspectValues
= namespaceValues.getAttributes(Namespace.ANT_META_URI);
if (antAspectValues == null) {
return null;
}

componentService.configureAttributes(aspectContext, antAspectValues,
true);
if (aspectContext.isRequired()) {
return aspectContext;
}
return null;
}

/**
* This join point is activated after a task has executed. The aspect
* may override the task's failure cause by returning a new failure.
*
* @param context the context the aspect provided in preExecuteTask.
* @param failureCause the current failure reason for the task.
*
* @return a new failure reason or null if the task is not to fail.
*/
public Throwable postExecuteTask(Object context, Throwable failureCause) {
AntAspectContext aspectContext = (AntAspectContext) context;
if (!aspectContext.getFailOnError()) {
return null;
}
return super.postExecuteTask(context, failureCause);
}

}


+ 0
- 94
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntAspectContext.java View File

@@ -1,94 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;

/**
* The context for the Ant Aspect
*
* @author Conor MacNeill
*/
public class AntAspectContext {
/** Indicates if the task's execution should not fail */
private boolean failOnError = true;
/**
* Set the flag covering whether a task failure halts the build.
*
* @param failOnError false if the build should continue.
*/
public void setFailOnError(boolean failOnError) {
this.failOnError = failOnError;
}

/**
* Indicate whether a task failure halts the build.
*
* @return true if a task error causes the build to fail.
*/
public boolean getFailOnError() {
return failOnError;
}

/**
* Indicate if this aspect context is required - i.e. whether the
* aspect needs to be reactivated after task execution
*
* @return true if the context should be used and the aspect reactivated
* after task execution.
*/
public boolean isRequired() {
return failOnError != true;
}
}


+ 0
- 201
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntBase.java View File

@@ -1,201 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.DataValue;

/**
* Common Base class for the Ant and AntCall tasks
*
* @author Conor MacNeill
* @created 4 February 2002
*/
public abstract class AntBase extends SubBuild {

/**
* flag which indicates if all current properties should be passed to the
* subbuild
*/
private boolean inheritAll = true;

/**
* flag which indicates if all current references should be passed to the
* subbuild
*/
private boolean inheritRefs = false;

/**
* The key to the subbuild with which the Ant task can manage the subbuild
*/
private Object subbuildKey;

/** The name of the target to be evaluated in the sub-build */
private String targetName;

/**
* Get the properties to be used with the sub-build
*
* @return the properties the sub-build will start with
* @exception AntException if the data values cannot be combined with
* existing values.
*/
protected Map getDataValues() throws AntException {
DataService dataService = getDataService();
int priority = inheritAll ? DataValue.PRIORITY_BASE
: DataValue.PRIORITY_INHERIT;

Map values = new HashMap(super.getDataValues());
dataService.mergeDataValues(values, dataService.getAllDataValues(),
priority);
return values;
}


/**
* Get the list of targets to be executed
*
* @return A List of string target names.
*/
protected List getTargets() {
List targets = new ArrayList();

if (targetName != null) {
targets.add(targetName);
}
return targets;
}


/**
* Handle error information produced by the task. When a task prints to
* System.err the container may catch this and redirect the content back
* to the task by invoking this method. This method must NOT call
* System.err, directly or indirectly.
*
* @param line The line of error info produce by the task
* @exception AntException if the output cannot be handled.
*/
public void handleSystemErr(String line) throws AntException {
if (subbuildKey == null) {
super.handleSystemErr(line);
} else {
getExecService().handleBuildOutput(subbuildKey, line, true);
}
}


/**
* Handle Output produced by the task. When a task prints to System.out
* the container may catch this and redirect the content back to the task
* by invoking this method. This method must NOT call System.out, directly
* or indirectly.
*
* @param line The line of content produce by the task
* @exception AntException if the output cannot be handled.
*/
public void handleSystemOut(String line) throws AntException {
if (subbuildKey == null) {
super.handleSystemOut(line);
} else {
getExecService().handleBuildOutput(subbuildKey, line, false);
}
}


/**
* Indicate if all properties should be passed
*
* @param inheritAll true if all properties should be passed
*/
public void setInheritAll(boolean inheritAll) {
this.inheritAll = inheritAll;
}


/**
* Indicate if all references are to be passed to the subbuild
*
* @param inheritRefs true if the sub-build should be given all the
* current references
*/
public void setInheritRefs(boolean inheritRefs) {
this.inheritRefs = inheritRefs;
}


/**
* Set the key of the subbuild
*
* @param key the key returned by the Ant core for managing the subbuild
*/
protected void setSubBuildKey(Object key) {
this.subbuildKey = key;
}


/**
* Sets the target to be executed in the subbuild
*
* @param targetName the name of the target to build
*/
public void setTarget(String targetName) {
this.targetName = targetName;
}
}


+ 0
- 90
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntCall.java View File

@@ -1,90 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.service.MagicProperties;

/**
* The Ant task - used to execute a different build file
*
* @author Conor MacNeill
* @created 4 February 2002
*/
public class AntCall extends AntBase {
/**
* Execute the sub-build
*
* @exception AntException if the build fails
*/
public void execute() throws AntException {
setProperty(MagicProperties.BASEDIR,
getExecService().getBaseDir().getAbsolutePath());

Object key = getExecService().setupBuild(getDataValues(), true);
setSubBuildKey(key);
getExecService().runBuild(key, getTargets());
setSubBuildKey(null);
}

/**
* Alias to add a property to the sub-build
*
* @param param descriptor for the property to be passed
*/
public void addParam(Property param) {
super.addProperty(param);
}

}


+ 0
- 101
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/FileConverter.java View File

@@ -1,101 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;

import java.io.File;
import org.apache.ant.common.antlib.AbstractConverter;
import org.apache.ant.common.antlib.ConverterException;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.service.FileService;

/**
* A converter to convert to File objects, resolving against the
* project's basedir
*
* @author Conor MacNeill
* @created 21 January 2002
*/
public class FileConverter extends AbstractConverter {

/**
* Get the list of classes this converter is able to convert to.
*
* @return an array of Class objects representing the classes this
* converter handles.
*/
public Class[] getTypes() {
return new Class[]{File.class};
}

/**
* Convert a string from the value given to an instance of the given
* type.
*
* @param value The value to be converted
* @param type the desired type of the converted object
* @return the value of the converted object
* @exception ConverterException if the conversion cannot be made
*/
public Object convert(String value, Class type) throws ConverterException {
try {
FileService fileService
= (FileService) getContext().getCoreService(FileService.class);
return fileService.resolveFile(value);
} catch (AntException e) {
throw new ConverterException("Unable to resolve file: "
+ value, e);
}
}
}


+ 0
- 159
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Import.java View File

@@ -1,159 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;

import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.ValidationException;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;

/**
* Task to import a component or components from a library
*
* @author Conor MacNeill
* @created 27 January 2002
*/
public class Import extends AbstractTask {
/** The Ant LIbrary Id from which the component must be imported */
private String libraryId = null;
/** The name of the component to be imported */
private String name = null;
/**
* A ref is used to import a task which has been declared in another
* project
*/
private String ref = null;
/** The alias that is to be used for the name */
private String alias = null;

/**
* Sets the libraryId of the Import
*
* @param libraryId the new libraryId value
*/
public void setLibraryId(String libraryId) {
this.libraryId = libraryId;
}

/**
* Sets the name of the Import
*
* @param name the new name value
*/
public void setName(String name) {
this.name = name;
}

/**
* Set the reference name of a task defined in a referenced frame
*
* @param ref the new ref value
*/
public void setRef(String ref) {
this.ref = ref;
}

/**
* Sets the alias of the Import
*
* @param alias the new alias value
*/
public void setAlias(String alias) {
this.alias = alias;
}

/**
* Validate this task is properly configured
*
* @exception ValidationException if the task is not configured correctly
*/
public void validateComponent() throws ValidationException {
if (ref != null) {
if (libraryId != null || name != null) {
throw new ValidationException("The \"ref\" attribute can only "
+ "be used when \"libraryId\" and \"name\" attributes are "
+ "not present");
}
} else {
if (libraryId == null) {
throw new ValidationException("You must specify a library "
+ "identifier with the \"libraryid\" attribute");
}
if (alias != null && name == null) {
throw new ValidationException("You may only specify an alias"
+ " when you specify the \"name\" or \"ref\" attributes");
}
}
}

/**
* Do the work and import the component or components
*
* @exception AntException if the components cannot be imported
*/
public void execute() throws AntException {
AntContext context = getAntContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
if (ref != null) {
componentService.importFrameComponent(ref, alias);
} else if (name == null) {
componentService.importLibrary(libraryId);
} else {
componentService.importComponent(libraryId, name, alias);
}
}
}


+ 0
- 177
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LibPath.java View File

@@ -1,177 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.ValidationException;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.init.InitUtils;

/**
* Task to add an additional classpath to the given library
*
* @author Conor MacNeill
* @created 27 January 2002
*/
public class LibPath extends AbstractTask {
/** The id of the library for which this additional path is being set */
private String libraryId;
/**
* This is the location, either file or URL of the library or libraries
* to be loaded
*/
private URL url;

/**
* Sets the libraryId of the LibPath
*
* @param libraryId the new libraryId value
*/
public void setLibraryId(String libraryId) {
this.libraryId = libraryId;
}

/**
* Sets the URL of the library to be loaded
*
* @param url the URL from which the library is to be loaded
* @exception ValidationException if the URL cannot be set
*/
public void setURL(URL url) throws ValidationException {
checkNullURL();
this.url = url;
}

/**
* Set the file from which the library should be loaded.
*
* @param file the file from which the library should be loaded
* @exception ValidationException if the file attribute cannot be set
*/
public void setFile(File file) throws ValidationException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(file);
} catch (MalformedURLException e) {
throw new ValidationException(e);
}
}

/**
* Set the dir in which to search for AntLibraries.
*
* @param dir the dir from which all Ant Libraries found will be loaded.
* @exception ValidationException if the dir attribute cannot be set
*/
public void setDir(File dir) throws ValidationException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(dir);
} catch (MalformedURLException e) {
throw new ValidationException(e);
}
}

/**
* Validate this task is configured correctly
*
* @exception ValidationException if the task is not configured correctly
*/
public void validateComponent() throws ValidationException {
if (libraryId == null) {
throw new ValidationException("You must specify the id of the"
+ "library for which you are providing additional classpaths");
}
if (url == null) {
throw new ValidationException("You must provide an additional "
+ "classpath using one of the file, dir or url attributes");
}
}

/**
* Add the libpath to the set of paths associated with the library
*
* @exception AntException if the library path cannot be addded to
* the library
*/
public void execute() throws AntException {
AntContext context = getAntContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
log("Adding lib path " + url + " for " + libraryId,
MessageLevel.DEBUG);
componentService.addLibPath(libraryId, url);
}

/**
* Check if any of the location specifying attributes have already been
* set.
*
* @exception ValidationException if the search URL has already been set
*/
private void checkNullURL() throws ValidationException {
if (url != null) {
throw new ValidationException("Location of library has already "
+ "been set. Please use only one of file, dir or url "
+ "attributes");
}
}
}


+ 0
- 172
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LoadLib.java View File

@@ -1,172 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 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.ant.antlib.system;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.antlib.ValidationException;
import org.apache.ant.common.util.AntException;
import org.apache.ant.init.InitUtils;

/**
* Load an AntLibrary and optionally import all its components
*
* @author Conor MacNeill
* @created 29 January 2002
*/
public class LoadLib extends AbstractTask {
/** Flag which indicates if all components should be imported */
private boolean importAll;

/**
* This is the location, either file or URL of the library or libraries
* to be loaded
*/
private URL url;

/**
* Sets the URL of the library to be loaded
*
* @param url the URL from which the library is to be loaded
* @exception ValidationException if the URL cannot be set
*/
public void setURL(URL url) throws ValidationException {
checkNullURL();
this.url = url;
}

/**
* Set the file from which the library should be loaded.
*
* @param file the file from which the library should be loaded
* @exception ValidationException if the file attribute cannot be set
*/
public void setFile(File file) throws ValidationException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(file);
} catch (MalformedURLException e) {
throw new ValidationException(e);
}
}

/**
* Set the dir in which to search for AntLibraries.
*
* @param dir the dir from which all Ant Libraries found will be loaded.
* @exception ValidationException if the dir attribute cannot be set
*/
public void setDir(File dir) throws ValidationException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(dir);
} catch (MalformedURLException e) {
throw new ValidationException(e);
}
}

/**
* Indicate whether all components from the library should be imported
*
* @param importAll true if all components in the library should be
* imported.
*/
public void setImportAll(boolean importAll) {
this.importAll = importAll;
}

/**
* Validate this task is configured correctly
*
* @exception ValidationException if the task is not configured correctly
*/
public void validateComponent() throws ValidationException {
if (url == null) {
throw new ValidationException("A location from which to load "
+ "libraries must be provided");
}
}


/**
* Load the library or libraries and optiinally import their components
*
* @exception AntException if the library or libraries cannot be
* loaded.
*/
public void execute() throws AntException {
AntContext context = getAntContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
componentService.loadLib(url, importAll);
}

/**
* Check if any of the location specifying attributes have already been
* set.
*
* @exception ValidationException if the search URL has already been set
*/
private void checkNullURL() throws ValidationException {
if (url != null) {
throw new ValidationException("Location of library has already "
+ "been set. Please use only one of file, dir or url "
+ "attributes");
}
}
}


+ 0
- 205
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Parallel.java View File

@@ -1,205 +0,0 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 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.ant.antlib.system;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;

import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.TaskContainer;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;

/**
* Implements a multi threaded task execution.
*
* @author Thomas Christen <a href="mailto:chr@active.ch">chr@active.ch</a>
* @author Conor MacNeill
* @created 27 February 2002
*/
public class Parallel extends AbstractTask
implements TaskContainer {

/**
* Class which stores information about the thread to which each task is
* associated
*
* @author Conor MacNeill
* @created 27 February 2002
*/
private class TaskThread extends Thread {
/** The exception thrown, if any, by the task running in this thread */
private Throwable exception;
/** The task running is this thread */
private Task task;
/** An identifier for the thread */
private int taskNumber;

/**
* Construct a new TaskThread
*
* @param task the Task to be executed in a seperate thread
* @param taskNumber the thread's identifier
*/
TaskThread(int taskNumber, Task task) {
this.task = task;
this.taskNumber = taskNumber;
}

/**
* Get the exception thrown by the task, if any.
*
* @return the Throwable instance thrown by the task or null if
* nothing was thrown.
*/
public Throwable getException() {
return exception;
}

/**
* Executes the task within a thread and takes care about Exceptions
* raised within the task.
*/
public void run() {
try {
AntContext context = getAntContext();
ExecService execService
= (ExecService) context.getCoreService(ExecService.class);
execService.executeTask(task);
} catch (Throwable t) {
exception = t;
}
}
}

/** Collection holding the nested tasks */
private List nestedTasks = new ArrayList();


/**
* Add a nested task to execute parallel (asynchron).
*
* @param nestedTask Nested task to be executed in parallel
*/
public void addNestedTask(Task nestedTask) {
nestedTasks.add(nestedTask);
}

/**
* Block execution until the specified time or for a specified amount of
* milliseconds and if defined, execute the wait status.
*
* @exception AntException if any of the nested tasks throws an
* exception
*/
public void execute() throws AntException {
TaskThread[] threads = new TaskThread[nestedTasks.size()];
int threadNumber = 0;
for (Iterator i = nestedTasks.iterator(); i.hasNext(); threadNumber++) {
Task nestedTask = (Task) i.next();
threads[threadNumber] = new TaskThread(threadNumber, nestedTask);
}

// now start all threads
for (int i = 0; i < threads.length; ++i) {
threads[i].start();
}

// now join to all the threads
for (int i = 0; i < threads.length; ++i) {
try {
threads[i].join();
} catch (InterruptedException ie) {
// who would interrupt me at a time like this?
}
}

// now did any of the threads throw an exception
StringBuffer exceptionMessage = new StringBuffer();
String lSep = System.getProperty("line.separator");
int numExceptions = 0;
Throwable firstException = null;
Location firstLocation = Location.UNKNOWN_LOCATION;
for (int i = 0; i < threads.length; ++i) {
Throwable t = threads[i].getException();
if (t != null) {
numExceptions++;
if (firstException == null) {
firstException = t;
}
if (t instanceof AntException &&
firstLocation == Location.UNKNOWN_LOCATION) {
firstLocation = ((AntException) t).getLocation();
}
exceptionMessage.append(lSep);
exceptionMessage.append(t.getMessage());
}
}

if (numExceptions == 1) {
if (firstException instanceof AntException) {
throw (AntException) firstException;
} else {
throw new SystemException(firstException);
}
} else if (numExceptions > 1) {
throw new SystemException(exceptionMessage.toString(),
firstLocation);
}
}
}


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save