blob: 0152144999b24b8e209276a3fdbab2a239d5fa79 [file] [log] [blame]
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00001<project name="samples-common">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +00002 <property name="gwt.root" location="../.." />
3 <property name="project.tail" value="samples/${sample.root}" />
4 <import file="${gwt.root}/common.ant.xml" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00005
fabbott@google.comf2503f32009-06-11 20:18:35 +00006 <!--
7 Number of localworkers for sample compilation. This depends on your
8 hardware, so it's a good candidate to specify in local.ant.properties
9 if this default isn't good for you. Ideally, it should approximate
10 the number of CPU cores in your machine.
11 -->
12 <property name="gwt.samples.localworkers" value="2" />
13
scottb@google.com6cd61e92009-01-16 19:50:20 +000014 <property name="sample.lower" value="${sample.root}" />
15 <property name="sample.upper" value="${sample.module}" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000016
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000017 <property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
jat@google.com0b1619e2009-09-20 19:33:31 +000018 <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev.jar" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000019
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000020 <!-- Mirror directory for scripts; makes building distro easier -->
21 <property name="samples.scripts" value="${gwt.build.out}/samples-scripts" />
22 <!-- Use the uppercase name rather than the lowercase name -->
scottb@google.com6cd61e92009-01-16 19:50:20 +000023 <property name="sample.build" value="${gwt.build.out}/samples/${sample.upper}" />
gwt.team.scottb69965322006-12-19 23:58:19 +000024
cramsdale@google.comfa87f8f2010-08-19 01:29:03 +000025 <path id="gae.extraclasspath">
26 <pathelement location="${gwt.tools.lib}/appengine/appengine-api-1.0-sdk-1.3.4.jar"/>
27 <pathelement location="${gwt.tools.lib}/appengine/geronimo-jpa_3.0_spec-1.1.1.jar"/>
28 <pathelement location="${gwt.tools.lib}/appengine/datanucleus-appengine-1.0.7.final.jar"/>
29 </path>
30
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000031 <target name="source" description="Copy source to the output folder">
32 <mkdir dir="${sample.build}/src" />
33 <copy todir="${sample.build}/src">
34 <fileset dir="src" />
35 </copy>
scottb@google.com6cd61e92009-01-16 19:50:20 +000036 <mkdir dir="${sample.build}/war" />
37 <copy todir="${sample.build}/war">
38 <fileset dir="war" excludes="WEB-INF/classes/**"/>
39 </copy>
cramsdale@google.com408e75e2010-08-20 15:26:19 +000040 <if>
41 <available file="pom.xml"/>
42 <then>
43 <copy tofile="${sample.build}/pom.xml" file="pom.xml"/>
44 </then>
45 </if>
cramsdale@google.com0e04c412010-08-20 19:02:03 +000046 <if>
47 <available file="README-MAVEN.txt"/>
48 <then>
49 <copy tofile="${sample.build}/README-MAVEN.txt" file="README-MAVEN.txt"/>
50 </then>
51 </if>
fabbott@google.com6bdc0f12010-08-25 18:12:04 +000052 <if>
53 <available file="user-build.xml"/>
54 <then>
55 <copy tofile="${sample.build}/build.xml" file="user-build.xml"/>
56 </then>
57 </if>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000058 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +000059
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000060 <target name="compile" description="Compile all java files">
scottb@google.com6cd61e92009-01-16 19:50:20 +000061 <mkdir dir="${sample.build}/war/WEB-INF/classes" />
62 <gwt.javac destdir="${sample.build}/war/WEB-INF/classes">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000063 <classpath>
64 <pathelement location="${gwt.user.jar}" />
65 <pathelement location="${gwt.dev.jar}" />
cramsdale@google.comfa87f8f2010-08-19 01:29:03 +000066 <pathelement location="${gwt.tools.lib}/jsr107cache/jsr107cache-1.1.jar"/>
67 <pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar"/>
68 <path refid="gae.extraclasspath" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000069 </classpath>
70 </gwt.javac>
71 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000072
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000073 <target name="gwtc" description="Compile to JavaScript">
74 <outofdate>
75 <sourcefiles>
cramsdale@google.comfa87f8f2010-08-19 01:29:03 +000076 <fileset dir="${sample.path}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000077 <fileset dir="${sample.build}/war/WEB-INF/classes" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000078 <fileset file="${gwt.user.jar}" />
79 <fileset file="${gwt.dev.jar}" />
80 </sourcefiles>
scottb@google.com6cd61e92009-01-16 19:50:20 +000081 <targetfiles path="${sample.build}/war/${sample.lower}/${sample.lower}.nocache.js" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000082 <sequential>
scottb@google.com6cd61e92009-01-16 19:50:20 +000083 <mkdir dir="${sample.build}/war" />
fabbott@google.comf2503f32009-06-11 20:18:35 +000084 <gwt.timer name="${sample.upper} with ${gwt.samples.localworkers} localWorkers">
fabbott@google.com6ae2c632010-08-27 14:47:27 +000085 <java dir="${sample.build}" classname="com.google.gwt.dev.Compiler"
86 classpath="${sample.path}:${sample.build}/war/WEB-INF/classes:${gwt.user.jar}:${gwt.dev.jar}:${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar:${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar"
87 fork="yes" failonerror="true">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000088 <jvmarg value="-Xmx256M"/>
fabbott@google.comf2503f32009-06-11 20:18:35 +000089 <arg value="-localWorkers" />
90 <arg value="${gwt.samples.localworkers}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000091 <arg value="-war" />
92 <arg file="${sample.build}/war" />
93 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000094 </java>
95 </gwt.timer>
96 <length property="sample.size">
scottb@google.com6cd61e92009-01-16 19:50:20 +000097 <fileset dir="${sample.build}/war/${sample.lower}" includes="*.cache.html,*.cache.js"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000098 </length>
scottb@google.com6cd61e92009-01-16 19:50:20 +000099 <echo message="output size for ${sample.upper} is ${sample.size} bytes"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000100 </sequential>
101 </outofdate>
102 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000103
scottb@google.com6cd61e92009-01-16 19:50:20 +0000104 <macrodef name="webAppCreator">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000105 <attribute name="platform" />
106 <attribute name="extension" default="" />
107 <sequential>
108 <outofdate>
109 <sourcefiles />
110 <targetfiles>
amitmanjhi@google.com33d16392009-10-03 01:14:10 +0000111 <pathelement location="${samples.scripts}/${sample.upper}/build.xml" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000112 </targetfiles>
113 <sequential>
amitmanjhi@google.com33d16392009-10-03 01:14:10 +0000114 <mkdir dir="${samples.scripts}/${sample.upper}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +0000115 <java classname="com.google.gwt.user.tools.WebAppCreator" classpath="${gwt.user.jar}:${gwt.dev.jar}" failonerror="true">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000116 <!-- Relative path is important! Paths will be relative in final distro -->
amitmanjhi@google.com33d16392009-10-03 01:14:10 +0000117 <sysproperty key="gwt.devjar" value="../../gwt-dev.jar" />
jgw@google.coma3509e22009-02-06 21:06:24 +0000118 <arg value="-XnoEclipse" />
scottb@google.com6cd61e92009-01-16 19:50:20 +0000119 <arg value="-overwrite" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000120 <arg value="-out" />
amitmanjhi@google.com33d16392009-10-03 01:14:10 +0000121 <arg file="${samples.scripts}/${sample.upper}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +0000122 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000123 </java>
124 </sequential>
125 </outofdate>
126 </sequential>
127 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000128
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000129 <target name="scripts" description="Create launch scripts">
scottb@google.com6cd61e92009-01-16 19:50:20 +0000130 <webAppCreator platform="linux" />
131 <webAppCreator platform="windows" extension=".cmd" />
132 <webAppCreator platform="mac" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000133 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000134
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000135 <target name="build" depends="source, compile, gwtc, scripts" description="Build and package this project" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000136
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000137 <target name="checkstyle" description="Static analysis of source">
fabbott@google.com615a29b2009-06-23 16:20:54 +0000138 <gwt.checkstyle outputdirectory="${sample.build}">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000139 <fileset dir="src" />
140 </gwt.checkstyle>
141 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +0000142
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000143 <target name="clean" description="Cleans this project's intermediate and output files">
144 <delete dir="${sample.build}" />
145 <delete includeemptydirs="true">
146 <fileset dir="${samples.scripts}">
scottb@google.com6cd61e92009-01-16 19:50:20 +0000147 <include name="*/${sample.upper}/**" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000148 </fileset>
149 </delete>
150 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000151</project>