Author: nbubna
Date: Mon Nov 27 12:44:18 2006
New Revision: 479758

URL: http://svn.apache.org/viewvc?view=rev&rev=479758
Log:
unify and simplify the ant build process for the examples

Added:
    jakarta/velocity/tools/trunk/examples.xml   (with props)
Removed:
    jakarta/velocity/tools/trunk/examples/layout/build.xml
    jakarta/velocity/tools/trunk/examples/simple/build.xml
    jakarta/velocity/tools/trunk/examples/struts/build.xml
Modified:
    jakarta/velocity/tools/trunk/build.xml

Modified: jakarta/velocity/tools/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/jakarta/velocity/tools/trunk/build.xml?view=diff&rev=479758&r1=479757&r2=479758
==============================================================================
--- jakarta/velocity/tools/trunk/build.xml (original)
+++ jakarta/velocity/tools/trunk/build.xml Mon Nov 27 12:44:18 2006
@@ -70,17 +70,7 @@
     <delete dir="${dist.dir}"/>
 
     <!-- Clean example applications  -->
-    <ant dir="${examples.home}/simple" target="clean" inheritAll="false"/>
-    <ant dir="${examples.home}/struts" target="clean" inheritAll="false"/>
-    <ant dir="${examples.home}/layout" target="clean" inheritAll="false"/>
-    <delete>
-      <fileset dir="${examples.home}/simple/WEB-INF/lib" includes="*.jar"/>
-      <fileset dir="${examples.home}/struts/WEB-INF/lib" includes="*.jar"/>
-      <fileset dir="${examples.home}/layout/WEB-INF/lib" includes="*.jar"/>
-    </delete>
-    <delete>
-      <fileset dir="${examples.home}" includes="*.war"/>
-    </delete>
+    <ant antfile="${basedir}/examples.xml" target="clean-examples" />
   </target>
 
   <!-- To help rebuild the documentation -->
@@ -376,96 +366,32 @@
 
 
   <!-- Build all example applications -->
-  <target name="examples"
-          depends="example.simple,example.struts,example.layout"
-          description="Compiles and jars all example applications."/>
-
-
+  <target name="examples" depends="jar.view,jar.struts"
+          description="Compiles and jars all example applications.">
+    <ant antfile="${basedir}/examples.xml" target="build-examples" />
+  </target>
 
   <!-- Build VelocityView - Simple application -->
-  <target name="example.simple" depends="jar.view"
+  <target name="simple" depends="jar.view"
           description="Compiles and jars the VelocityView example 
application.">
-
-    <property name="simple.lib" value="${examples.home}/simple/WEB-INF/lib"/>
-
-    <!-- Clean up any past build -->
-    <delete file="${examples.home}/simple.war"/>
-    <delete>
-      <fileset dir="${simple.lib}" includes="velocity-tools*.jar"/>
-    </delete>
-
-    <!-- Assemble and build the simple example -->
-    <copy todir="${simple.lib}" file="${dist.dir}/${view.id}.jar"/>
-    <copy todir="${simple.lib}" file="${commons-collections.jar}"/>
-    <copy todir="${simple.lib}" file="${commons-digester.jar}"/>
-    <copy todir="${simple.lib}" file="${commons-beanutils.jar}"/>
-    <copy todir="${simple.lib}" file="${commons-logging.jar}"/>
-    <copy todir="${simple.lib}" file="${oro.jar}"/>
-    <copy todir="${simple.lib}" file="${velocity.jar}"/>
-    <copy todir="${simple.lib}" file="${commons-lang.jar}"/>
-
-    <ant dir="${examples.home}/simple" target="war" inheritAll="false"/>
+    <property name="target" value="war"/>
+    <ant antfile="${basedir}/examples.xml" target="simple-example" />
   </target>
 
-
+  <!-- Build VelocityView - Layout application -->
+  <target name="layout" depends="jar.view"
+          description="Compiles and jars the VelocityView Layout example 
application.">
+    <property name="target" value="war"/>
+    <ant antfile="${basedir}/examples.xml" target="layout-example" />
+  </target>
 
   <!-- Build VelocityStruts example application -->
-  <target name="example.struts" depends="jar.struts"
+  <target name="struts" depends="jar.struts"
           description="Compiles and jars the VelocityStruts example 
application.">
-
-    <property name="velstruts.lib" 
value="${examples.home}/struts/WEB-INF/lib"/>
-
-    <!-- Clean away old war -->
-    <delete>
-      <fileset dir="${examples.home}" includes="velstruts.war"/>
-    </delete>
-
-    <!-- Deploy jars -->
-    <delete>
-      <fileset dir="${velstruts.lib}" includes="velocity-tools*.jar"/>
-    </delete>
-    <copy todir="${velstruts.lib}" file="${dist.dir}/${struts.id}.jar"/>
-    <copy todir="${velstruts.lib}" file="${commons-beanutils.jar}"/>
-    <copy todir="${velstruts.lib}" file="${commons-collections.jar}"/>
-    <copy todir="${velstruts.lib}" file="${commons-digester.jar}"/>
-    <copy todir="${velstruts.lib}" file="${commons-lang.jar}"/>
-    <copy todir="${velstruts.lib}" file="${commons-logging.jar}"/>
-    <copy todir="${velstruts.lib}" file="${commons-validator.jar}"/>
-    <copy todir="${velstruts.lib}" file="${servlet.jar}"/>
-    <copy todir="${velstruts.lib}" file="${sslext.jar}"/>
-    <copy todir="${velstruts.lib}" file="${struts.jar}"/>
-    <copy todir="${velstruts.lib}" file="${oro.jar}"/>
-    <copy todir="${velstruts.lib}" file="${velocity.jar}"/>
-
-    <!-- Build VelocityStruts examples -->
-    <ant dir="${examples.home}/struts" target="all" inheritAll="false"/>
+    <property name="target" value="war"/>
+    <ant antfile="${basedir}/examples.xml" target="struts-example" />
   </target>
 
-
-
-  <!-- Build VelocityView - Layout application -->
-  <target name="example.layout" depends="jar.view"
-          description="Compiles and jars the VelocityView Layout example 
application.">
-
-    <property name="layout.lib" value="${examples.home}/layout/WEB-INF/lib"/>
-
-    <!-- Clean up any past build -->
-    <delete file="${examples.home}/layout.war"/>
-    <delete>
-      <fileset dir="${layout.lib}" includes="velocity-tools*.jar"/>
-    </delete>
-
-    <!-- Assemble and build the layout example -->
-    <copy todir="${layout.lib}" file="${dist.dir}/${view.id}.jar"/>
-    <copy todir="${layout.lib}" file="${commons-beanutils.jar}"/>
-    <copy todir="${layout.lib}" file="${commons-collections.jar}"/>
-    <copy todir="${layout.lib}" file="${commons-digester.jar}"/>
-    <copy todir="${layout.lib}" file="${commons-lang.jar}"/>
-    <copy todir="${layout.lib}" file="${oro.jar}"/>
-    <copy todir="${layout.lib}" file="${velocity.jar}"/>
-
-    <ant dir="${examples.home}/layout" target="war" inheritAll="false"/>
-  </target>
 
 
   <!-- Convenient target for rolling releases -->

Added: jakarta/velocity/tools/trunk/examples.xml
URL: 
http://svn.apache.org/viewvc/jakarta/velocity/tools/trunk/examples.xml?view=auto&rev=479758
==============================================================================
--- jakarta/velocity/tools/trunk/examples.xml (added)
+++ jakarta/velocity/tools/trunk/examples.xml Mon Nov 27 12:44:18 2006
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.    
+-->
+
+<!--
+  This file contains all the jar download targets to build Velocity.
+  Its tasks are referenced from the build.xml file and should not be
+  called directly.
+
+  This is here so that the main build file is not cluttered any further.
+-->
+
+<project name="VelocityTools - Example Apps" basedir=".">
+  
+  <target name="build-examples"
+          description="Build WAR files for all VelocityTools example 
applications">
+    <property name="target" value="war"/>
+    <antcall target="simple-example" />
+    <antcall target="layout-example" />
+    <antcall target="struts-example" />
+  </target>
+
+  <target name="clean-examples"
+          description="Build WAR files for all VelocityTools example 
applications">
+    <property name="target" value="clean"/>
+    <antcall target="simple-example" />
+    <antcall target="layout-example" />
+    <antcall target="struts-example" />
+  </target>
+
+  <target name="simple-example">
+    <property name="name" value="simple" />
+    <property name="base" value="${examples.home}/${name}" />
+    <property name="lib" value="${base}/WEB-INF/lib"/>
+    <antcall target="example-${target}"/>
+  </target>
+  <target name="simple-dependencies">
+    <copy todir="${lib}" file="${dist.dir}/${view.id}.jar"/>
+    <copy todir="${lib}" file="${commons-beanutils.jar}"/>
+    <copy todir="${lib}" file="${commons-collections.jar}"/>
+    <copy todir="${lib}" file="${commons-digester.jar}"/>
+    <copy todir="${lib}" file="${commons-lang.jar}"/>
+    <copy todir="${lib}" file="${commons-logging.jar}"/>
+    <copy todir="${lib}" file="${oro.jar}"/>
+    <copy todir="${lib}" file="${velocity.jar}"/>
+  </target>
+
+  <target name="layout-example">
+    <property name="name" value="layout" />
+    <property name="base" value="${examples.home}/${name}" />
+    <property name="lib" value="${base}/WEB-INF/lib"/>
+    <antcall target="example-${target}"/>
+  </target>
+  <target name="layout-dependencies" depends="simple-dependencies"/>
+
+  <target name="struts-example">
+    <property name="name" value="struts" />
+    <property name="base" value="${examples.home}/${name}" />
+    <property name="lib" value="${base}/WEB-INF/lib"/>
+    <antcall target="example-${target}"/>
+  </target>
+  <target name="struts-dependencies">
+    <copy todir="${lib}" file="${dist.dir}/${struts.id}.jar"/>
+    <copy todir="${lib}" file="${commons-beanutils.jar}"/>
+    <copy todir="${lib}" file="${commons-collections.jar}"/>
+    <copy todir="${lib}" file="${commons-digester.jar}"/>
+    <copy todir="${lib}" file="${commons-lang.jar}"/>
+    <copy todir="${lib}" file="${commons-logging.jar}"/>
+    <copy todir="${lib}" file="${commons-validator.jar}"/>
+    <copy todir="${lib}" file="${servlet.jar}"/>
+    <copy todir="${lib}" file="${sslext.jar}"/>
+    <copy todir="${lib}" file="${struts.jar}"/>
+    <copy todir="${lib}" file="${oro.jar}"/>
+    <copy todir="${lib}" file="${velocity.jar}"/>
+  </target>
+
+  <target name="example-compile">
+    <!-- run the dependencies target -->
+    <antcall target="${name}-dependencies"/>
+
+    <!-- compile the classes -->
+    <mkdir dir="${base}/WEB-INF/classes"/>
+    <javac srcdir="${base}/WEB-INF/src"
+           includes="*/**"
+           destdir="${base}/WEB-INF/classes">
+       <classpath>
+        <fileset dir="${lib}">
+          <include name="*.jar"/>
+        </fileset>
+      </classpath>
+    </javac>
+
+    <!-- copy non-java resources -->
+    <copy todir="${base}/WEB-INF/classes">
+      <fileset dir="${base}/WEB-INF/src" excludes="**/*.java"/>
+    </copy>
+  </target>
+
+  <target name="example-war" depends="example-compile">
+    <jar jarfile="${examples.home}/${name}.war"
+         basedir="${base}"
+         
excludes="**/MANIFEST.MF,**/servletapi-${jar.servletapi.version}.jar"/>
+    <echo>                                                  </echo>
+    <echo>  A WAR file (Web ARchive) was created for you at </echo>
+    <echo>                                                  </echo>
+    <echo>      ${examples.home}/${name}.war                </echo>
+    <echo>                                                  </echo>
+    <echo>  To use it with Tomcat, copy the ${name}.war file</echo>
+    <echo>  to the webapps directory in the Tomcat tree     </echo>
+    <echo>  (assuming a standard Tomcat installation)  and  </echo>
+    <echo>  then restart Tomcat.  To access the page        </echo>
+    <echo>  point you browser to                            </echo>
+    <echo>                                                  </echo>
+    <echo>     http://localhost:8080/${name}/index.vm       </echo>
+    <echo>                                                  </echo>
+    <echo>  If you have any questions, don't hesitate to    </echo>
+    <echo>  ask on the Velocity user list.                  </echo>
+  </target>
+
+  <target name="example-clean">
+    <delete file="${examples.home}/${name}.war"/>
+    <delete>
+      <fileset dir="${lib}" includes="*.jar"/>
+    </delete>
+    <delete dir="${base}/WEB-INF/classes"/>
+  </target>
+
+</project>
+

Propchange: jakarta/velocity/tools/trunk/examples.xml
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to