blob: f6229cd266d10d8373404ba25250c82a4f803d1d [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
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000025 <target name="source" description="Copy source to the output folder">
26 <mkdir dir="${sample.build}/src" />
27 <copy todir="${sample.build}/src">
28 <fileset dir="src" />
29 </copy>
scottb@google.com6cd61e92009-01-16 19:50:20 +000030 <mkdir dir="${sample.build}/war" />
31 <copy todir="${sample.build}/war">
32 <fileset dir="war" excludes="WEB-INF/classes/**"/>
33 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000034 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +000035
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000036 <target name="compile" description="Compile all java files">
scottb@google.com6cd61e92009-01-16 19:50:20 +000037 <mkdir dir="${sample.build}/war/WEB-INF/classes" />
38 <gwt.javac destdir="${sample.build}/war/WEB-INF/classes">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000039 <classpath>
40 <pathelement location="${gwt.user.jar}" />
41 <pathelement location="${gwt.dev.jar}" />
42 </classpath>
43 </gwt.javac>
44 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000045
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000046 <target name="gwtc" description="Compile to JavaScript">
47 <outofdate>
48 <sourcefiles>
49 <fileset dir="src" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000050 <fileset dir="${sample.build}/war/WEB-INF/classes" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000051 <fileset file="${gwt.user.jar}" />
52 <fileset file="${gwt.dev.jar}" />
53 </sourcefiles>
scottb@google.com6cd61e92009-01-16 19:50:20 +000054 <targetfiles path="${sample.build}/war/${sample.lower}/${sample.lower}.nocache.js" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000055 <sequential>
scottb@google.com6cd61e92009-01-16 19:50:20 +000056 <mkdir dir="${sample.build}/war" />
fabbott@google.comf2503f32009-06-11 20:18:35 +000057 <gwt.timer name="${sample.upper} with ${gwt.samples.localworkers} localWorkers">
scottb@google.com6cd61e92009-01-16 19:50:20 +000058 <java dir="${sample.build}" classname="com.google.gwt.dev.Compiler" classpath="src:${sample.build}/war/WEB-INF/classes:${gwt.user.jar}:${gwt.dev.jar}" fork="yes" failonerror="true">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000059 <jvmarg value="-Xmx256M"/>
fabbott@google.comf2503f32009-06-11 20:18:35 +000060 <arg value="-localWorkers" />
61 <arg value="${gwt.samples.localworkers}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000062 <arg value="-war" />
63 <arg file="${sample.build}/war" />
64 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000065 </java>
66 </gwt.timer>
67 <length property="sample.size">
scottb@google.com6cd61e92009-01-16 19:50:20 +000068 <fileset dir="${sample.build}/war/${sample.lower}" includes="*.cache.html,*.cache.js"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000069 </length>
scottb@google.com6cd61e92009-01-16 19:50:20 +000070 <echo message="output size for ${sample.upper} is ${sample.size} bytes"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000071 </sequential>
72 </outofdate>
73 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000074
scottb@google.com6cd61e92009-01-16 19:50:20 +000075 <macrodef name="webAppCreator">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000076 <attribute name="platform" />
77 <attribute name="extension" default="" />
78 <sequential>
79 <outofdate>
80 <sourcefiles />
81 <targetfiles>
amitmanjhi@google.com33d16392009-10-03 01:14:10 +000082 <pathelement location="${samples.scripts}/${sample.upper}/build.xml" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000083 </targetfiles>
84 <sequential>
amitmanjhi@google.com33d16392009-10-03 01:14:10 +000085 <mkdir dir="${samples.scripts}/${sample.upper}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000086 <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 +000087 <!-- Relative path is important! Paths will be relative in final distro -->
amitmanjhi@google.com33d16392009-10-03 01:14:10 +000088 <sysproperty key="gwt.devjar" value="../../gwt-dev.jar" />
jgw@google.coma3509e22009-02-06 21:06:24 +000089 <arg value="-XnoEclipse" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000090 <arg value="-overwrite" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000091 <arg value="-out" />
amitmanjhi@google.com33d16392009-10-03 01:14:10 +000092 <arg file="${samples.scripts}/${sample.upper}" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000093 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000094 </java>
95 </sequential>
96 </outofdate>
97 </sequential>
98 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000099
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000100 <target name="scripts" description="Create launch scripts">
scottb@google.com6cd61e92009-01-16 19:50:20 +0000101 <webAppCreator platform="linux" />
102 <webAppCreator platform="windows" extension=".cmd" />
103 <webAppCreator platform="mac" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000104 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000105
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000106 <target name="build" depends="source, compile, gwtc, scripts" description="Build and package this project" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000107
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000108 <target name="checkstyle" description="Static analysis of source">
fabbott@google.com615a29b2009-06-23 16:20:54 +0000109 <gwt.checkstyle outputdirectory="${sample.build}">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000110 <fileset dir="src" />
111 </gwt.checkstyle>
112 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +0000113
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000114 <target name="clean" description="Cleans this project's intermediate and output files">
115 <delete dir="${sample.build}" />
116 <delete includeemptydirs="true">
117 <fileset dir="${samples.scripts}">
scottb@google.com6cd61e92009-01-16 19:50:20 +0000118 <include name="*/${sample.upper}/**" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000119 </fileset>
120 </delete>
121 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000122</project>