Source

webwork / webapps / build.xml

<project name="webwork-webapps" default="help" basedir=".">
	<property file="../build.properties" />

	<target name="help">
		<echo>
            o To create a new webapp structure, simply run

                 ant new

            o To build a webapp, simply run:

                 ant build -Dwebapp=XXX

              ... Where XXX is the name of the webapp you want to build.
              After the build is finished, the fully-built war file can
              be found in the dist directory. You may deploy this file
              to any servlet container.

                 For example:

                 ant build -Dwebapp=sandbox

            o To build a portlet webapp, simply run:

                 ant build-portlet

              You can use the 'container' system property to target a specific container, e.g. '-Dcontainer=exo'.
              Supported containers are exo, gridsphere, liferay-3.6.1, jboss-portal-2.0, jboss-portal-2.2 and jetspeed2.
              For IBM WebSphere Portal 5.1 and Apache Pluto 1.0.1, no container property is required.

                 For example:
                 ant build-portlet -Dcontainer=jboss-portal-2.2
        </echo>
	</target>

	<path id="cp">
		<fileset dir="../lib">
			<include name="**/*.jar" />
		</fileset>
		<fileset dir="..">
			<include name="webwork-*.jar" />
		</fileset>
		<!-- used for allowing WebWork developers to build wars w/o building the whole distribution -->
		<path path="../build/java" />
	</path>

	<macrodef name="compile">
		<attribute name="srcdir" />
		<attribute name="destdir" />
		<attribute name="classpath" default="" />
		<attribute name="classpathref" default="cp" />
		<attribute name="excludes" default="" />
		<attribute name="source" default="1.4" />
		<attribute name="target" default="1.4" />
		<sequential>
			<mkdir dir="@{destdir}" />
			<javac srcdir="@{srcdir}" destdir="@{destdir}" classpath="@{classpath}" classpathref="@{classpathref}" debug="on" source="@{source}" target="@{target}" />
			<copy filtering="no" todir="@{destdir}">
				<fileset dir="@{srcdir}">
					<exclude name="**/*.java" />
					<exclude name="**/package.html" />
				</fileset>
			</copy>
		</sequential>
	</macrodef>

	<target name="build">
		<!-- prepare -->
		<delete dir="${basedir}/tmp" />
		<mkdir dir="${basedir}/tmp" />
		<mkdir dir="${basedir}/dist" />

		<!-- copy over the webapp -->
		<copy todir="${basedir}/tmp">
			<fileset dir="${basedir}/${webapp}/src/webapp" />
		</copy>

		<!-- compile the sources -->
		<mkdir dir="${basedir}/tmp/WEB-INF/classes" />
		<compile srcdir="${basedir}/${webapp}/src/java" destdir="${basedir}/tmp/WEB-INF/classes" />

		<!-- war up the app -->
		<war file="${basedir}/dist/${webapp}.war" webxml="tmp/WEB-INF/web.xml">
			<zipfileset dir="tmp" prefix="" />

			<!-- only these configurations are needed for now. Also, these are probably more than
                 needed, but we're just picking a single set of jars that each webapp can use -->
			<zipfileset dir="${basedir}/../lib/ajax" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/default" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/fileupload" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/sitemesh" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/portlet" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/jasperreports" prefix="WEB-INF/lib" excludes="commons-collections.jar" />
			<zipfileset dir="${basedir}/../lib/spring" prefix="WEB-INF/lib" includes="*.jar" excludes="commons-logging.jar" />
			<zipfileset dir="${basedir}/../lib/velocity" prefix="WEB-INF/lib" includes="velocity*.jar" />
			<zipfileset dir="${basedir}/../lib/quickstart" prefix="WEB-INF/lib" includes="log4j.jar, commons-io.jar, commons-lang.jar, commons-collections.jar" />
			<zipfileset dir="${basedir}/../lib/jfree" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../build" prefix="WEB-INF/lib" includes="${name}-${version}.jar" />
			<zipfileset dir="${basedir}/.." prefix="WEB-INF/lib" includes="${name}-${version}.jar" />
		</war>
	</target>

    <target name="new" description="Create a new webapp project with the specified name and packages">
        <echo level="info">
            +=============================================================+
            |              -- Create a new web application  --            |
            +=============================================================+
        </echo>
        <echo/>

        <!-- Prompt the user for input -->
        <input message="Enter the name of your new application [myapp]?" addproperty="new.app.name"
            defaultvalue="myapp"/>

        <echo level="info">Creating '${new.app.name}' web application...</echo>
        <copy todir="${new.app.name}">
            <fileset dir="${basedir}/blank">
                <exclude name="tmp/**"/>
                <exclude name="build/**"/>
                <include name="**"/>
                <exclude name=".#**"/>
                <exclude name="*.iml"/>
                <exclude name="*.classpath"/>
                <exclude name="CVS/**"/>
                <exclude name="**/CVS"/>
            </fileset>
        </copy>

        <!-- Copy the IDEA project file(s) -->
        <copy file="blank/blank.iml" tofile="${new.app.name}/${new.app.name}.iml"/>
        <replace dir="${new.app.name}" value="${new.app.name}" token="blank">
            <include name="${new.app.name}.i*"/>
        </replace>

        <!-- Copy the Eclipse project file(s) -->
        <copy file="blank/.classpath" tofile="${new.app.name}/.classpath"/>
        <replace file="${new.app.name}/.classpath" value="${basedir}/.." token="@WEBWORK_HOME@"/>
        <replace file="${new.app.name}/.classpath" value="${version}" token="@WEBWORK_VERSION@"/>
        <copy file="blank/.project" tofile="${new.app.name}/.project"/>
        <replace file="${new.app.name}/.project" value="${new.app.name}" token="@PROJECT_NAME@"/>

        <echo level="info">
            +=============================================================+
            |    -- Your Web Application was created successfully! --     |
            |                                                             |
            | Now you should be able to build your application with:      |
            | > ant build -Dwebapp=${new.app.name}                        |
            +=============================================================+
        </echo>
    </target>


    <target name="build-portlet" depends="prepare-portlet,prepare-portlet-deploy" description="Builds the portlet application. You can use the 'container' system property to target a specific container, e.g. '-Dcontainer=exo'. Supported containers are exo, gridsphere, jboss-portal-2.0, jboss-portal-2.2 and jetspeed2">
		<!-- war up the app -->
		<war file="${basedir}/dist/webwork-portlet.war" webxml="tmp/WEB-INF/web.xml">
			<zipfileset dir="tmp" prefix="" />

			<!-- only these configurations are needed for now. Also, these are probably more than
	                 needed, but we're just picking a single set of jars that each webapp can use -->
			<zipfileset dir="${basedir}/../lib/ajax" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/default" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/cewolf" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/fileupload" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/freemarker" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/sitemesh" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/spring" prefix="WEB-INF/lib" includes="*.jar" excludes="commons-logging.jar" />
			<zipfileset dir="${basedir}/../lib/velocity" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../lib/quickstart" prefix="WEB-INF/lib" includes="log4j.jar, commons-lang.jar" />
			<zipfileset dir="${basedir}/../lib/jfree" prefix="WEB-INF/lib" includes="*.jar" />
			<zipfileset dir="${basedir}/../build" prefix="WEB-INF/lib" includes="${name}-${version}.jar" />
			<zipfileset dir="${basedir}/.." prefix="WEB-INF/lib" includes="${name}-${version}.jar" />
		</war>
	</target>

	<target name="prepare-portlet">
		<property name="webapp" value="portlet" />
		<!-- prepare -->
		<delete dir="${basedir}/tmp" />
		<mkdir dir="${basedir}/tmp" />
		<mkdir dir="${basedir}/dist" />

		<!-- copy over the webapp -->
		<copy todir="${basedir}/tmp">
			<fileset dir="${basedir}/${webapp}/src/webapp" />
		</copy>
		<!-- compile the sources -->
		<mkdir dir="${basedir}/tmp/WEB-INF/classes" />
		<compile srcdir="${basedir}/${webapp}/src/java" destdir="${basedir}/tmp/WEB-INF/classes" />
	</target>

	<target name="prepare-portlet-deploy" if="container">
		<!-- Prepare descriptors and potential extra jars -->
		<property name="deploy.src.dir" value="${basedir}/portlet/src/etc" />
		<antcall target="prepare-${container}" />
	</target>

	<target name="prepare-exo">
		<copy file="${deploy.src.dir}/exo/web.xml" tofile="tmp/WEB-INF/web.xml" overwrite="true" />
	</target>

	<target name="prepare-jboss-portal-2.2">
		<copy todir="tmp/WEB-INF/">
			<fileset dir="${deploy.src.dir}/jbossportal2.2">
				<include name="*.*" />
			</fileset>
		</copy>
	</target>

	<target name="prepare-jboss-portal-2.0">
		<copy todir="tmp/WEB-INF/" overwrite="true">
			<fileset dir="${deploy.src.dir}/jbossportal2.0">
				<include name="*.*" />
			</fileset>
		</copy>
	</target>

	<target name="prepare-jetspeed2">
		<copy todir="tmp/WEB-INF/" overwrite="true">
			<fileset dir="${deploy.src.dir}/jetspeed2">
				<include name="*.*" />
			</fileset>
		</copy>
	</target>

	<target name="prepare-gridsphere">
		<copy todir="tmp/WEB-INF/" overwrite="true">
			<fileset dir="${deploy.src.dir}/gridsphere">
				<include name="*.xml" />
				<include name="*.txt" />
			</fileset>
		</copy>
		<copy todir="tmp/WEB-INF/lib/" overwrite="true">
			<fileset dir="${deploy.src.dir}/gridsphere">
				<include name="*.jar" />
			</fileset>
		</copy>
	</target>

	<target name="prepare-liferay-3.6.1">
		<copy todir="tmp/WEB-INF/" overwrite="true">
			<fileset dir="${deploy.src.dir}/liferay3.6.1">
				<include name="*.xml" />
			</fileset>
		</copy>
	</target>
</project>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.