blob: 248acd216822832a16192a2d1fa55ffdb2a60905 [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
scottb@google.com6cd61e92009-01-16 19:50:20 +00006 <property name="sample.lower" value="${sample.root}" />
7 <property name="sample.upper" value="${sample.module}" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +00008
fabbott@google.com0e2dc6282008-08-22 16:09:01 +00009 <property.ensure name="gwt.user.jar" location="${gwt.build.lib}/gwt-user.jar" />
10 <!-- Platform shouldn't matter here, just picking one -->
11 <property.ensure name="gwt.dev.jar" location="${gwt.build.lib}/gwt-dev-linux.jar" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000012
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000013 <!-- Mirror directory for scripts; makes building distro easier -->
14 <property name="samples.scripts" value="${gwt.build.out}/samples-scripts" />
15 <!-- Use the uppercase name rather than the lowercase name -->
scottb@google.com6cd61e92009-01-16 19:50:20 +000016 <property name="sample.build" value="${gwt.build.out}/samples/${sample.upper}" />
gwt.team.scottb69965322006-12-19 23:58:19 +000017
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000018 <target name="source" description="Copy source to the output folder">
19 <mkdir dir="${sample.build}/src" />
20 <copy todir="${sample.build}/src">
21 <fileset dir="src" />
22 </copy>
scottb@google.com6cd61e92009-01-16 19:50:20 +000023 <mkdir dir="${sample.build}/war" />
24 <copy todir="${sample.build}/war">
25 <fileset dir="war" excludes="WEB-INF/classes/**"/>
26 </copy>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000027 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +000028
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000029 <target name="compile" description="Compile all java files">
scottb@google.com6cd61e92009-01-16 19:50:20 +000030 <mkdir dir="${sample.build}/war/WEB-INF/classes" />
31 <gwt.javac destdir="${sample.build}/war/WEB-INF/classes">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000032 <classpath>
33 <pathelement location="${gwt.user.jar}" />
34 <pathelement location="${gwt.dev.jar}" />
35 </classpath>
36 </gwt.javac>
37 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000038
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000039 <target name="gwtc" description="Compile to JavaScript">
40 <outofdate>
41 <sourcefiles>
42 <fileset dir="src" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000043 <fileset dir="${sample.build}/war/WEB-INF/classes" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000044 <fileset file="${gwt.user.jar}" />
45 <fileset file="${gwt.dev.jar}" />
46 </sourcefiles>
scottb@google.com6cd61e92009-01-16 19:50:20 +000047 <targetfiles path="${sample.build}/war/${sample.lower}/${sample.lower}.nocache.js" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000048 <sequential>
scottb@google.com6cd61e92009-01-16 19:50:20 +000049 <mkdir dir="${sample.build}/war" />
50 <gwt.timer name="${sample.upper}">
51 <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 +000052 <jvmarg value="-Xmx256M"/>
scottb@google.com6cd61e92009-01-16 19:50:20 +000053 <arg value="-war" />
54 <arg file="${sample.build}/war" />
55 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000056 </java>
57 </gwt.timer>
58 <length property="sample.size">
scottb@google.com6cd61e92009-01-16 19:50:20 +000059 <fileset dir="${sample.build}/war/${sample.lower}" includes="*.cache.html,*.cache.js"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000060 </length>
scottb@google.com6cd61e92009-01-16 19:50:20 +000061 <echo message="output size for ${sample.upper} is ${sample.size} bytes"/>
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000062 </sequential>
63 </outofdate>
64 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000065
scottb@google.com6cd61e92009-01-16 19:50:20 +000066 <macrodef name="webAppCreator">
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000067 <attribute name="platform" />
68 <attribute name="extension" default="" />
69 <sequential>
70 <outofdate>
71 <sourcefiles />
72 <targetfiles>
scottb@google.com6cd61e92009-01-16 19:50:20 +000073 <pathelement location="${samples.scripts}/@{platform}/${sample.upper}/build.xml" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000074 </targetfiles>
75 <sequential>
scottb@google.com6cd61e92009-01-16 19:50:20 +000076 <mkdir dir="${samples.scripts}/@{platform}/${sample.upper}" />
77 <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 +000078 <!-- Relative path is important! Paths will be relative in final distro -->
79 <sysproperty key="gwt.devjar" value="../../gwt-dev-@{platform}.jar" />
jgw@google.coma3509e22009-02-06 21:06:24 +000080 <arg value="-XnoEclipse" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000081 <arg value="-overwrite" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000082 <arg value="-out" />
scottb@google.com6cd61e92009-01-16 19:50:20 +000083 <arg file="${samples.scripts}/@{platform}/${sample.upper}" />
84 <arg value="com.google.gwt.sample.${sample.lower}.${sample.upper}" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000085 </java>
86 </sequential>
87 </outofdate>
88 </sequential>
89 </macrodef>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000090
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000091 <target name="scripts" description="Create launch scripts">
scottb@google.com6cd61e92009-01-16 19:50:20 +000092 <webAppCreator platform="linux" />
93 <webAppCreator platform="windows" extension=".cmd" />
94 <webAppCreator platform="mac" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000095 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000096
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000097 <target name="build" depends="source, compile, gwtc, scripts" description="Build and package this project" />
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +000098
fabbott@google.com0e2dc6282008-08-22 16:09:01 +000099 <target name="checkstyle" description="Static analysis of source">
100 <gwt.checkstyle>
101 <fileset dir="src" />
102 </gwt.checkstyle>
103 </target>
gwt.team.scottb69965322006-12-19 23:58:19 +0000104
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000105 <target name="clean" description="Cleans this project's intermediate and output files">
106 <delete dir="${sample.build}" />
107 <delete includeemptydirs="true">
108 <fileset dir="${samples.scripts}">
scottb@google.com6cd61e92009-01-16 19:50:20 +0000109 <include name="*/${sample.upper}/**" />
fabbott@google.com0e2dc6282008-08-22 16:09:01 +0000110 </fileset>
111 </delete>
112 </target>
gwt.team.scottb14c5b9d2006-12-10 06:06:08 +0000113</project>