summaryrefslogtreecommitdiffstats
path: root/build/package/build.xml
blob: f270b3b7c36098576d37548bfe4287e9088a23be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!--

Creates two packages:

1. WAR package that can be deployed to application server or servlet container.

2. JAR package which requires JRE only, includes embedded web server.

-->
<project name="vaadin-examples" basedir="." default="package">

	<target name="init">
		<echo message="Creating two packages:" />
		<echo message="1. WAR package that can be deployed to application server or servlet container." />
		<echo message="2. JAR package which requires JRE only, includes embedded web server." />
		<property name="server.main.class" value="com.vaadin.demo.DesktopServer" />
		<property name="webserver.jar" value="WebServer/winstone-0.9.9.jar" />
		<property file="build.properties" />
		<mkdir dir="build" />
	</target>

	<target name="clean">
		<delete dir="build" />
	</target>

	<!-- Compiles your Vaadin application -->
	<target name="compile" depends="init">
		<echo message="Compiling Vaadin application sources." />
		<path id="compile.class.path">
			<fileset dir="WebContent">
				<include name="WEB-INF/lib/*.jar" />
			</fileset>
			<fileset dir="WebServer">
				<include name="*.jar" />
			</fileset>
		</path>

		<javac srcdir="WebContent/src" destdir="WebContent/WEB-INF/classes" classpathref="compile.class.path">
		</javac>
		<javac srcdir="WebServer/src" destdir="WebServer/classes" classpathref="compile.class.path">
		</javac>
	</target>

	<!-- Creates Vaadin WAR package (requires Application Server / Servlet Container)-->
	<target name="war-package" depends="compile">
		<echo message="Creating WAR package." />
		<war warfile="build/${ant.project.name}.war" webxml="WebContent/WEB-INF/web.xml">
			<fileset dir="WebContent">
				<include name="**/*" />
				<exclude name="WEB-INF/web.xml" />
			</fileset>
		</war>
	</target>

	<!-- Creates Vaadin JAR package that contains embedded WebServer -->
	<target name="jar-package" depends="war-package">
		<echo message="Creating JAR package." />
		<copy tofile="build/WebServer-temp/embedded.war" file="build/${ant.project.name}.war" />
		<unjar src="${webserver.jar}" dest="build/WebServer-temp" />
		<manifest file="build/WebServer-temp/META-INF/MANIFEST.MF">
			<attribute name="Main-Class" value="${server.main.class}" />
		</manifest>
		<copy todir="build/WebServer-temp">
			<fileset dir="WebServer/classes">
				<include name="**/*" />
			</fileset>
		</copy>
	</target>

	<!-- Creates both Vaadin WAR and JAR packages -->
	<target name="package" depends="jar-package">
		<jar destfile="build/${ant.project.name}.jar" basedir="build/WebServer-temp" manifest="build/WebServer-temp/META-INF/MANIFEST.MF" />
		<echo message="Created WAR-file to build/${ant.project.name}.war." />
		<echo message="Deploy this file to your application server or servlet container." />
		<echo message=" " />
		<echo message="Created JAR-file to build/${ant.project.name}.jar" />
		<echo message="Run your application using command like: java -jar build/${ant.project.name}.jar" />
	</target>

</project>