You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by eh...@apache.org on 2002/03/03 13:37:34 UTC
cvs commit: jakarta-ant/proposal/sandbox/antlib/src/testcases/org/apache/ant/contrib Case.java
ehatcher 02/03/03 04:37:34
Modified: proposal/sandbox/antlib build.xml
proposal/sandbox/antlib/src/testcases build.xml
case-antlib.xml case.xml
proposal/sandbox/antlib/src/testcases/org/apache/ant/contrib
Case.java
Log:
once again for Jose Alberto - think I got it right this time
Revision Changes Path
1.4 +40 -6 jakarta-ant/proposal/sandbox/antlib/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/build.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build.xml 2 Mar 2002 22:21:43 -0000 1.3
+++ build.xml 3 Mar 2002 12:37:33 -0000 1.4
@@ -6,21 +6,24 @@
<property name='build' location='build' />
<property name='dist' location='dist' />
<property name='classes' location='${build}/classes' />
+ <property name='testcases' location='src/testcases' />
<property name="debug" value="true" />
<property name="deprecation" value="false" />
<property name="optimize" value="true" />
-
-
+
+
<target name='init'>
<ant target='build' dir='${orig}' inheritAll='false' />
<mkdir dir='${classes}' />
<copy toDir='${classes}' preservelastmodified='true' >
<fileset dir='${orig-classes}'>
<include name='**' />
- <exclude name='org/apache/tools/ant/Project.class' />
- <exclude name='org/apache/tools/ant/TaskAdapter.class' />
- <exclude name='org/apache/tools/ant/taskdefs/Ant.class' />
+ <exclude name='org/apache/tools/ant/Project.class' />
+ <exclude name='org/apache/tools/ant/ProjectHelper.class' />
+ <exclude name='org/apache/tools/ant/IntrospectionHelper.class' />
+ <exclude name='org/apache/tools/ant/TaskAdapter.class' />
+ <exclude name='org/apache/tools/ant/taskdefs/Ant.class' />
</fileset>
</copy>
</target>
@@ -39,6 +42,32 @@
<property name="build.dir" value="${build}"/>
<property name="dist.dir" value="${dist}"/>
</ant>
+ <!--
+ Rejar things to use lib descriptors
+ It needs to work with the original ANT processor
+ -->
+ <path id="newtasks">
+ <pathelement location="${classes}" />
+ </path>
+ <taskdef name="antjar" classname="org.apache.tools.ant.taskdefs.Antjar"
+ classpathref="newtasks" />
+ <taskdef name="antlib" classname="org.apache.tools.ant.taskdefs.Antlib"
+ classpathref="newtasks" />
+ <mkdir dir='${dist}/autolib' />
+ <antjar antxml="src/main/org/apache/tools/ant/opt-antlib.xml"
+ destfile="${dist}/autolib/optional.jar" >
+ <zipfileset src="${dist}/lib/optional.jar" >
+ <include name="**/*" />
+ </zipfileset>
+ </antjar>
+ <antjar antxml="src/main/org/apache/tools/ant/antlib.xml"
+ destfile="${dist}/lib/newant.jar" >
+ <zipfileset src="${dist}/lib/ant.jar" >
+ <include name="**/*" />
+ </zipfileset>
+ </antjar>
+ <delete file="${dist}/lib/optional.jar" />
+ <move file="${dist}/lib/newant.jar" tofile="${dist}/lib/ant.jar"/>
</target>
<target name='compile'>
@@ -48,6 +77,11 @@
optimize="${optimize}">
<include name='**/*.java'/>
</javac>
+ <copy toDir='${classes}' preservelastmodified='true' >
+ <fileset dir='src/main'>
+ <include name='**/*.xml' />
+ </fileset>
+ </copy>
</target>
<target name='clean'>
@@ -56,7 +90,7 @@
<target name='test'>
<ant dir='${testcases}' inheritAll='false'/>
- <ant dir='${testcases}'
+ <ant dir='${testcases}'
antfile='${testcases}/case.xml' inheritAll='false'/>
</target>
1.2 +30 -30 jakarta-ant/proposal/sandbox/antlib/src/testcases/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/testcases/build.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build.xml 18 Feb 2002 08:55:16 -0000 1.1
+++ build.xml 3 Mar 2002 12:37:33 -0000 1.2
@@ -1,30 +1,30 @@
-<?xml version="1.0"?>
-
-<project name="local" default="libs" >
-
- <taskdef name="antjar" classname="org.apache.tools.ant.taskdefs.Antjar" />
- <property name="src" location="." />
- <property name="classes" location="../../build/testcases" />
- <property name="contrib" location="../../build/case_contrib.jar" />
-
- <target name="libs" depends="compile" >
- <antjar destfile="${contrib}" antxml="${src}/case-antlib.xml" >
- <fileset dir="${classes}" >
- <include name="org/**" />
- </fileset>
- </antjar>
- </target>
-
- <target name="compile" >
- <mkdir dir="${classes}" />
- <javac srcdir="${src}" destdir="${classes}" >
- <include name="org/**/*.java" />
- </javac>
- </target>
-
- <target name="clean" >
- <delete dir="${classes}" />
- <delete file='${contrib}'/>
- </target>
-
-</project>
+<?xml version="1.0"?>
+
+<project name="local" default="libs" >
+
+ <taskdef name="antjar" classname="org.apache.tools.ant.taskdefs.Antjar" />
+ <property name="src" location="." />
+ <property name="classes" location="../../build/testcases" />
+ <property name="contrib" location="../../build/case_contrib.jar" />
+
+ <target name="libs" depends="compile" >
+ <antjar destfile="${contrib}" antxml="${src}/case-antlib.xml" >
+ <fileset dir="${classes}" >
+ <include name="org/**" />
+ </fileset>
+ </antjar>
+ </target>
+
+ <target name="compile" >
+ <mkdir dir="${classes}" />
+ <javac srcdir="${src}" destdir="${classes}" >
+ <include name="org/**/*.java" />
+ </javac>
+ </target>
+
+ <target name="clean" >
+ <delete dir="${classes}" />
+ <delete file='${contrib}'/>
+ </target>
+
+</project>
1.2 +5 -5 jakarta-ant/proposal/sandbox/antlib/src/testcases/case-antlib.xml
Index: case-antlib.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/testcases/case-antlib.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- case-antlib.xml 18 Feb 2002 08:55:17 -0000 1.1
+++ case-antlib.xml 3 Mar 2002 12:37:33 -0000 1.2
@@ -1,5 +1,5 @@
-<?xml version="1.0" ?>
-
-<antlib version="1.0" >
- <task name="case" class="org.apache.ant.contrib.Case" />
-</antlib>
+<?xml version="1.0" ?>
+
+<antlib version="1.0" >
+ <task name="case" class="org.apache.ant.contrib.Case" />
+</antlib>
1.2 +39 -39 jakarta-ant/proposal/sandbox/antlib/src/testcases/case.xml
Index: case.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/testcases/case.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- case.xml 18 Feb 2002 08:55:17 -0000 1.1
+++ case.xml 3 Mar 2002 12:37:33 -0000 1.2
@@ -1,39 +1,39 @@
-<?xml version="1.0"?>
-
-<project name="case-test" default="test" basedir=".">
-
- <property name="value" value="task.xml" />
-
- <target name="init">
- <taskdef name="antlib" classname="org.apache.tools.ant.taskdefs.Antlib" />
- <antlib file="../../build/case_contrib.jar" />
- </target>
-
- <target name="test" depends="init,case,test1,test2,test3">
- <echo message="Value=${value}" />
- </target>
-
- <target name="case" >
- <case property="value" >
- <when value="task.xml" property="value.xml" />
- </case>
- <case property="location" >
- <when value="loc" property="location.fail" />
- <when value="" property="location.fail" />
- <else property="location.unset" />
- </case>
- </target>
-
- <target name="test1" if="value.xml">
- <echo message="Value equals to itself" />
- </target>
-
- <target name="test2" if="location.fail">
- <fail message="Location passed" />
- </target>
-
- <target name="test3" if="location.unset">
- <echo message="Location does not exists" />
- </target>
-
-</project>
+<?xml version="1.0"?>
+
+<project name="case-test" default="test" basedir=".">
+
+ <property name="value" value="task.xml" />
+
+ <target name="init">
+ <taskdef name="antlib" classname="org.apache.tools.ant.taskdefs.Antlib" />
+ <antlib file="../../build/case_contrib.jar" />
+ </target>
+
+ <target name="test" depends="init,case,test1,test2,test3">
+ <echo message="Value=${value}" />
+ </target>
+
+ <target name="case" >
+ <case property="value" >
+ <when value="task.xml" property="value.xml" />
+ </case>
+ <case property="location" >
+ <when value="loc" property="location.fail" />
+ <when value="" property="location.fail" />
+ <else property="location.unset" />
+ </case>
+ </target>
+
+ <target name="test1" if="value.xml">
+ <echo message="Value equals to itself" />
+ </target>
+
+ <target name="test2" if="location.fail">
+ <fail message="Location passed" />
+ </target>
+
+ <target name="test3" if="location.unset">
+ <echo message="Location does not exists" />
+ </target>
+
+</project>
1.2 +169 -169 jakarta-ant/proposal/sandbox/antlib/src/testcases/org/apache/ant/contrib/Case.java
Index: Case.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/sandbox/antlib/src/testcases/org/apache/ant/contrib/Case.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Case.java 18 Feb 2002 08:55:17 -0000 1.1
+++ Case.java 3 Mar 2002 12:37:34 -0000 1.2
@@ -1,169 +1,169 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999 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", "Tomcat", 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.contrib;
-
-import java.io.*;
-import java.util.*;
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.types.*;
-
-/**
- * Will set one of the given properties depending on the result of testing
- * the value of another property.
- *
- * <!ELEMENT case (when*, else) >
- * <!ATTLIST case property CDATA #REQUIRED > The name of the property to test
- * <!ELEMENT when EMPTY >
- * <!ATTLIST when value CDATA #REQUIRED > The value to compare and set prop.
- * <!ATTLIST when property CDATA #REQUIRED > The name of the property to set
- * <!ELEMENT else EMPTY >
- * <!ATTLIST else property CDATA #REQUIRED > The name of the property to set otherwise
- * <!ATTLIST else value CDATA #IMPLIED > The value to set; default "true".
- *
- * @author Jose Alberto Fernandez <a href="mailto:jfernandez@viquity.com">jfernandez@viquity.com</a>
- */
-
-public class Case extends Task {
-
- public class When {
- private String property;
- private String value;
-
- public void setProperty(String name) {
- property = name;
- }
-
- public String getProperty() {
- return property;
- }
-
- public void setValue(String val) {
- value = val;
- }
-
- public String getValue() {
- return value;
- }
-
- public boolean tryCase(String caseValue) throws BuildException {
- if (property == null)
- throw new BuildException("Property attribute is mandatory");
-
- if (value == null)
- throw new BuildException("Value attribute is mandatory");
-
- if (!value.equals(caseValue)) return false;
-
- if (getProject().getProperty(property) == null) {
- getProject().setProperty(property, value);
- } else {
- log("Override ignored for " + property, Project.MSG_VERBOSE);
- }
- return true;
- }
-
- public void doElse() throws BuildException {
- if (property == null)
- throw new BuildException("Property attribute is mandatory");
-
- String elseValue = (value == null) ? "true" : value;
-
- if (getProject().getProperty(property) == null) {
- getProject().setProperty(property, elseValue);
- } else {
- log("Override ignored for " + property, Project.MSG_VERBOSE);
- }
- }
- }
-
- private String caseProperty;
- private Vector whenList = new Vector();
- private When elseCase = null;
-
- public When createWhen() throws BuildException {
- When w = new When();
- whenList.addElement(w);
- return w;
- }
-
- public When createElse() throws BuildException {
- if (elseCase != null)
- throw new BuildException("Only one else element allowed per case");
-
- return (elseCase = new When());
- }
-
- public void setProperty(String property) {
- this.caseProperty = property;
- }
-
- public void execute() throws BuildException {
- if (caseProperty == null) {
- throw new BuildException("property attribute is required",
- location);
- }
-
- String caseValue = getProject().getProperty(caseProperty);
-
- for (Enumeration e = whenList.elements(); e.hasMoreElements(); ) {
- When w = (When)e.nextElement();
- if (w.tryCase(caseValue)) return;
- }
-
- if (elseCase != null)
- elseCase.doElse();
- }
-
-}
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 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", "Tomcat", 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.contrib;
+
+import java.io.*;
+import java.util.*;
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.types.*;
+
+/**
+ * Will set one of the given properties depending on the result of testing
+ * the value of another property.
+ *
+ * <!ELEMENT case (when*, else) >
+ * <!ATTLIST case property CDATA #REQUIRED > The name of the property to test
+ * <!ELEMENT when EMPTY >
+ * <!ATTLIST when value CDATA #REQUIRED > The value to compare and set prop.
+ * <!ATTLIST when property CDATA #REQUIRED > The name of the property to set
+ * <!ELEMENT else EMPTY >
+ * <!ATTLIST else property CDATA #REQUIRED > The name of the property to set otherwise
+ * <!ATTLIST else value CDATA #IMPLIED > The value to set; default "true".
+ *
+ * @author Jose Alberto Fernandez <a href="mailto:jfernandez@viquity.com">jfernandez@viquity.com</a>
+ */
+
+public class Case extends Task {
+
+ public class When {
+ private String property;
+ private String value;
+
+ public void setProperty(String name) {
+ property = name;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setValue(String val) {
+ value = val;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean tryCase(String caseValue) throws BuildException {
+ if (property == null)
+ throw new BuildException("Property attribute is mandatory");
+
+ if (value == null)
+ throw new BuildException("Value attribute is mandatory");
+
+ if (!value.equals(caseValue)) return false;
+
+ if (getProject().getProperty(property) == null) {
+ getProject().setProperty(property, value);
+ } else {
+ log("Override ignored for " + property, Project.MSG_VERBOSE);
+ }
+ return true;
+ }
+
+ public void doElse() throws BuildException {
+ if (property == null)
+ throw new BuildException("Property attribute is mandatory");
+
+ String elseValue = (value == null) ? "true" : value;
+
+ if (getProject().getProperty(property) == null) {
+ getProject().setProperty(property, elseValue);
+ } else {
+ log("Override ignored for " + property, Project.MSG_VERBOSE);
+ }
+ }
+ }
+
+ private String caseProperty;
+ private Vector whenList = new Vector();
+ private When elseCase = null;
+
+ public When createWhen() throws BuildException {
+ When w = new When();
+ whenList.addElement(w);
+ return w;
+ }
+
+ public When createElse() throws BuildException {
+ if (elseCase != null)
+ throw new BuildException("Only one else element allowed per case");
+
+ return (elseCase = new When());
+ }
+
+ public void setProperty(String property) {
+ this.caseProperty = property;
+ }
+
+ public void execute() throws BuildException {
+ if (caseProperty == null) {
+ throw new BuildException("property attribute is required",
+ location);
+ }
+
+ String caseValue = getProject().getProperty(caseProperty);
+
+ for (Enumeration e = whenList.elements(); e.hasMoreElements(); ) {
+ When w = (When)e.nextElement();
+ if (w.tryCase(caseValue)) return;
+ }
+
+ if (elseCase != null)
+ elseCase.doElse();
+ }
+
+}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>