ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Deitte <bdei...@allaire.com>
Subject general JRun build file
Date Wed, 18 Oct 2000 17:40:41 GMT
Awhile back I mentioned I was working on a uber JRun build file, and here it
is.  It'll probably be posted on the Allaire dev center at some point, but
would love to get some comments first, if anybody has any after looking.

I tried to write it so that the user didn't have to even look in build.xml
for basic projects.  As a sidenote, two things I'd love to see to help this:
a <failon> task that takes in a property and fails if it isn't defined, and
the iterative wildcard idea that was mentioned in a discussion on ejbc a few
days ago. 

build.properties is first, followed by build.xml.  -Brian

# Copyright Allaire and all that mumbo jumbo

# see the README for how to set up your environment to use this build

##### Necessary Properties ######
# base directory of jrun
# default: jrun.dir=(none)
jrun.dir=c:/jrun

# jrun server to deploy the app on
# default: jrun.server=(none)
jrun.server=default

# Packages from source directory to include for documenting.
# Can specify more than one group by a comma.     
# default: javadoc.packages=(none)
javadoc.packages=com.allaire.faq.ejb,com.allaire.faq.pagehandler,com.allaire
.faq.pagehandler.util,com.allaire.faq.servlet
v

##### End Necessary Properties #####

# base of build directory
# default: dev.dir=(none)
dev.dir=C:/dev/skunkworks/devWebSite/faq-app-dev/build

# name of build
# default: build.name=(none)
build.name=faq

##### Properties Dependent on dev.dir and build.name #####

# The directory where Ant can assemble things.
# default: build.dir=${dev.dir}/generated

# The root of where the source files are.
# default: src.dir=${build.dir}/source

# The name for the ejb jar.
# default: ejb.name=${build.name}_ejb.jar

# The location of ejb-jar.xml
# default: ejbxml.file=${dev.dir}/META-INF/ejb-jar.xml

# The web root in the server.  Should be the same as the context-root
element
# in application.xml
# default: webroot.name=${build.name}
webroot.name=faq-app

# The root of where the web application files are.  (ie, the jsp, html, gif)
# Note that this is the development location, NOT the place where they
# will be in the server.
# default: webroot.dir=${dev.dir}/webroot

# The name for the war.
# default: war.name=${build.name}.war

# The location of web.xml.
# default: warxml.file=${dev.dir}/WEB-INF/web.xml

# The name for the ear.
# default: ear.name=${build.name}.ear

# The location of application.xml.
# default: earxml.file=${dev.dir}/META-INF/application.xml

# The directory where generated documentation should be put.
# default: javadoc.dir=${dev.dir}/doc

##### End Dependent Properties #####

##### Other Useful Properties #####

# Jars to add to the default classpath.  (The default classpath includes
# all jars in JRUN/lib and JRUN/lib/ext.)  Note that the type of 
# separater used (whether ';' or ':') doesn't matter, Ant will convert it
# for the os.
# default: classpath.add=(none)
classpath.add=c:/j2sdkee1.2.1/lib/j2ee.jar

# Files from source directory to compile.
# Can specify more than one group by a comma.
# Can use ** to specify a match of any directory, 
# * to specify a match of any letters, and
# ? to specify a match of one letter. 
# default: compile.include=**/*.class

# Classes from compile directory to include in the ejb jar.
# See compile.include for how to specify what to include.
# default: ejb.include=**/*.class

# Files from webroot to include in the war.
# See compile.include for how to specify what to include.
# default: webroot.include=**

# Classes from compile directory to include in the war.
# See compile.include for how to specify what to include.
# default: war.include=**/*.class

# Same as -windowtitle in javadoc.
# default: javadoc.window=${build.name}'s\ API

# Same as -bottom in javadoc.
# default: javadoc.bottom=Copyright\ &#169;\ 2000.\ All\ Rights\ Reserved.
javadoc.bottom=Copyright\ &#169;\ Allaire\ 2000.\ All\ Rights\ Reserved.


----------------

<?xml version="1.0"?>

<project name="Escher" default="dev2web" basedir=".">

  <property file="${basedir}/build.properties" /> 

  <path id="classpath">

    <pathelement location="${dev.dir}" />
    <pathelement path="${classpath.add}" />
    <fileset dir="${jrun.dir}/lib">
      <include name="**/*.jar" />
    </fileset>

  </path>

  <property name="jrun.dir" value="  SET jrun.dir IN BUILD.PROPERTIES  "/>
  <property name="jrun.server" value="  SET jrun.server IN BUILD.PROPERTIES
"/>

  <property name="dev.dir" value="  SET dev.dir IN BUILD.PROPERTIES  "/>
  <property name="build.name" value="  SET build.name IN BUILD.PROPERTIES
"/>

  <property name="javadoc.properties" value="  SET javadoc.properties IN
BUILD.PROPERTIES  "/>

  <property name="build.dir" value="${dev.dir}/generated"/>
  <property name="src.dir" value="${dev.dir}/source"/>
  <property name="server.dir" value="${jrun.dir}/servers/${jrun.server}"/>

  <property name="compile.include" value="**/*.java"/>

  <property name="ejb.name" value="${build.name}_ejb.jar"/>
  <property name="ejbxml.file" value="${dev.dir}/META-INF/ejb-jar.xml"/>
  <property name="ejb.include" value="**/*.class"/>

  <property name="webroot.name" value="${build.name}"/>
  <property name="webroot.dir" value="${dev.dir}/webroot"/>
  <property name="webroot.include" value="**"/>

  <property name="war.name" value="${build.name}.war"/>
  <property name="warxml.file" value="${dev.dir}/WEB-INF/web.xml"/>
  <property name="war.include" value="**/*.class"/>

  <property name="ear.name" value="${build.name}.ear"/>
  <property name="earxml.file" value="${dev.dir}/META-INF/application.xml"/>

  <property name="javadoc.dir" value="${dev.dir}/doc"/>
  <property name="javadoc.window" value="${build.name}'s API"/>
  <property name="javadoc.bottom" value="Copyright &#169; 2000. All Rights
Reserved."/>

  <property name="build.compiler" value="classic"/>


  <!-- ===================================================================
-->
  <!-- jstart                                                          -->
  <!-- ===================================================================
-->
  <target name="jstart">

    <!-- Should use "call" on windows otherwise stuck here.
         Unfortunately, the os param wants an exact match.
         (And don't know good way to handle the 'else' case.
         Commented out for now.

    <exec executable="call"   
          os="windows"
          dir="${jrun.dir}/bin">
         <arg line="jrun -start ${jrun.server}"/>
    </exec>

    <exec executable="jrun"   
          os="unix"
          dir="${jrun.dir}/bin">
         <arg line="-start ${jrun.server}"/>
    </exec>

    -->

  </target>

  <!-- ===================================================================
-->
  <!-- jstop                                                          -->
  <!-- ===================================================================
-->
  <target name="jstop">

    <exec executable="jrun"
          dir="${jrun.dir}/bin">
         <arg line="-stop ${jrun.server}"/>
    </exec>

  </target>

  <!-- ===================================================================
-->
  <!-- jrestart                                                          -->
  <!-- ===================================================================
-->
  <target name="jrestart">

    <exec executable="jrun"
          dir="${jrun.dir}/bin">
         <arg line="-restart ${jrun.server}"/>
    </exec>

  </target>


  <!-- ===================================================================
-->
  <!-- compile: Compiles the source code
-->
  <!-- ===================================================================
-->
  <target name="compile">

    <mkdir dir="${build.dir}/classes"/>

    <javac srcdir="${src.dir}"
           destdir="${build.dir}/classes"
           debug="on"
           includes="${compile.include}"
    >
	   <classpath refid = "classpath" />
    </javac>

  </target>





  <!-- ===================================================================
-->
  <!-- ejb  -->
  <!-- ===================================================================
-->
  <target name="ejb" depends="compile">

    <copy file="${ejbxml.file}"
              tofile="${build.dir}/META-INF/ejb-jar.xml"
	      overwrite="true"
    />

    <jar jarfile="${build.dir}/${ejb.name}">

        <fileset dir="${build.dir}/classes">
            <include name ="${ejb.include}"/>
        </fileset>

        <fileset dir="${build.dir}">
            <include name ="META-INF/ejb-jar.xml"/>
        </fileset>

    </jar>

  </target>

  <!-- ===================================================================
-->
  <!-- deploy  -->
  <!-- ===================================================================
-->
  <target name="deploy" depends="ejb">

    <copy file="${build.dir}/${ejb.name}" 
          todir="${server.dir}/deploy" 
    />

    <!-- make a deploy task... someday -->

    <java classname = "allaire.ejipt.tools.Deploy"
          fork = "yes"
          failonerror = "yes"
    >
          <jvmarg line="-Dejipt.home=${jrun.dir}
-Djava.security.policy=${jrun.dir}/lib/jrun.policy
-Dejipt.ejbDirectory=${server.dir}"/>
	  <classpath refid = "classpath" />
    </java>

  </target>

  <!-- ===================================================================
-->
  <!-- redeploy  -->
  <!-- ===================================================================
-->
  <target name="redeploy" depends="ejb">

    <copy file="${build.dir}/${ejb.name}" 
          todir="${server.dir}/deploy"
	  overwrite="yes" 
    />

    <java classname = "allaire.ejipt.tools.Deploy"
          fork = "yes"
          failonerror = "yes"
    >
         <jvmarg line="-Dejipt.home=${jrun.dir}
-Djava.security.policy=${jrun.dir}/lib/jrun.policy
-Dejipt.ejbDirectory=${server.dir}"/>
         <arg line="-redeploy"/>
	 <classpath refid = "classpath" />

    </java>

  </target>

  <!-- ===================================================================
-->
  <!-- ejb2web  -->
  <!-- ===================================================================
-->
  <target name="ejb2web" depends="redeploy"/>





  <!-- ===================================================================
-->
  <!-- war:    -->
  <!-- ===================================================================
-->
  <target name="war" depends="compile">

    <copy file="${warxml.file}"
          tofile="${build.dir}/WEB-INF/web.xml"
	  overwrite="true"
    />

    <war warfile="${build.dir}/${war.name}"
         webxml= "${build.dir}/WEB-INF/web.xml">

        <fileset dir="${webroot.dir}"
        		 includes="${webroot.include}" />
        <webinf dir="${build.dir}"
        		includes="classes/${war.include}" />

    </war>

  </target>

  <!-- ===================================================================
-->
  <!-- war2web:    -->
  <!-- ===================================================================
-->
  <target name="war2web" depends="war">

     <mkdir dir="${server.dir}/${webroot.name}"/>
     <unwar src="${build.dir}/${war.name}"
            dest="${server.dir}/${webroot.name}"/>
     <antcall target="jstart"/>

  </target>





  <!-- ===================================================================
-->
  <!-- ear:    -->
  <!-- ===================================================================
-->
  <target name="ear" depends="war, ejb">

    <copy file="${earxml.file}"
          tofile="${build.dir}/META-INF/application.xml"
	  overwrite="true"
    />

    <jar jarfile="${build.dir}/${ear.name}"
         basedir="${build.dir}"
         includes="${ejb.name}, ${war.name}, META-INF/application.xml"
    />

  </target>

  <!-- ===================================================================
-->
  <!-- eardeploy:    -->
  <!-- ===================================================================
-->
  <target name="eardeploy" depends="ear">

    <java classname = "allaire.jrun.tools.EarDeploy"
          fork = "yes"
          failonerror = "yes"
          >
         <arg line="-d ${build.dir}/${name}.ear -s ${jrun.server} -j
${jrun.dir}"/>
	 <classpath refid = "classpath" />
    </java>

    <antcall target="jrestart" />
  </target>




  <!-- ===================================================================
-->
  <!-- dev2web                                  -->
  <!-- ===================================================================
-->
  <target name="dev2web" depends="ejb2web, war2web"/>


  <!-- ===================================================================
-->
  <!-- web2dev                                  -->
  <!-- ===================================================================
-->
  <target name="web2dev">

      <!--
      just copy everything from web dir to dev dir (no point in
      moving ejb stuff back to dev since it is just classes)
      -->
    
      <copydir file="${server.dir}/${webroot.name}"
               tofile="${webroot.dir}"
      />

  </target>




  <!-- ===================================================================
-->
  <!-- javadoc: Create the documentation
-->
  <!-- ===================================================================
-->
  <target name="javadoc">
    <mkdir dir="${javadoc.dir}"/>

    <javadoc sourcepath="${src.dir}"
             destdir="${javadoc.dir}"
             sourcefiles="${javadoc.packages}"
             author="true"
             version="true"
             windowtitle="${javadoc.window}"
             bottom="${javadoc.bottom}"
    >

	 <classpath refid = "classpath" />
    </javadoc>
  </target>




  <!-- ===================================================================
-->
  <!-- cleandev     -->
  <!-- ===================================================================
-->
  <target name="cleandev">

    <delete dir="${javadoc.dir}"
	    includes="**"/>
    <delete dir="${build.dir}/classes"
	    includes="**"/>
    <delete dir="${build.dir}"
            includes="${ear.name}, ${ejb.name}, ${war.name}"/>

  </target>

  <!-- ===================================================================
-->
  <!-- cleanweb     -->
  <!-- ===================================================================
-->
  <target name="cleanweb" depends="jstop">

    <delete dir="${webroot.dir}"
	    includes="**"/>

  </target>

</project>








Mime
View raw message