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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
<?xml version="1.0"?>
<!--
Client-side code is compiled by using GWTCompiler which compiles client-side Java code into
JavaScript. Generated files are located under WebContent/VAADIN/widgetsets/*.
Client-side compilation is required if you create new or modify existing widgets.
You may use either this script or Vaadin Hosted Mode Browser.launch (in Eclipse)
to compile your client-side java code.
By default Vaadin first tries to serve widgetset resources from the file system, if that
fails then files are streamed from vaadin-@version@.jar.
See configure target to adjust this buildfile.
-->
<project name="Widgetset compile example" basedir="." default="compile-widgetset">
<!--
Update based on your project structure, by default this buildfile assumes that you
1. use WebContent under your project's root directory
2. WebContent/WEB-INF/lib/vaadin-@version@.jar exists
3. WebContent/WEB-INF/src contains your project source files
4. gwt directory contains extracted GWT distribution
-->
<target name="configure">
<!-- Path from this file to the project root -->
<property name="base"
value="../../../" />
<!-- Location of GWT distribution -->
<property name="gwt-location"
value="${base}gwt" />
<!-- Location of Vaadin JAR -->
<property name="vaadin-jar-location"
value="${base}WebContent/WEB-INF/lib/vaadin-@version@.jar" />
<!-- Location of project source code -->
<property name="src-location"
value="${base}WebContent/WEB-INF/src" />
<!-- Target where to compile server-side classes -->
<property name="server-side-destination"
value="${base}WebContent/WEB-INF/classes"/>
<!-- Target where to compile the widget set -->
<property name="client-side-destination"
value="${base}WebContent/VAADIN/widgetsets" />
</target>
<!-- Modify this configuration to compile your own widgetset -->
<target name="configure-widgetset">
<echo>Modify this example Ant script to compile your own widget sets.</echo>
<!-- Name of the widget set -->
<property name="widgetset" value="com.vaadin.demo.colorpicker.gwt.ColorPickerWidgetSet"/>
<!-- If generated automatically as a combining widget set -->
<!-- from all the widget sets included in the class path. -->
<!-- <property name="widgetset" value="com.vaadin.demo.widgetset.CombiningWidgetSet"/> -->
<!-- <property name="generate.widgetset" value="1"/> -->
<!-- Path to the generated widget set directory. Must be -->
<!-- relative to $src-location, which must be the first -->
<!-- entry in the class path. -->
<property name="widgetset-path" value="com/vaadin/demo/widgetset"/>
</target>
<!-- Modify this configuration to package your own widgetset Jar. -->
<target name="configure-jar">
<!-- The compiled JAR name -->
<property name="jar-destination" value="${base}colorpicker.jar"/>
<!-- Title of the widget set (for JAR) -->
<property name="widgetset-title" value="ColorPicker"/>
<!-- Version of the widget set (for JAR) -->
<property name="widgetset-version" value="1.0"/>
<!-- Vendor of the widget set (for JAR) -->
<property name="widgetset-vendor" value="Vaadin Ltd"/>
</target>
<!-- ================================================== -->
<!-- Build Targets -->
<!-- ================================================== -->
<target name="init" depends="configure">
<echo>Requirements for classpath:</echo>
<echo> ${gwt-location}/gwt-dev.jar</echo>
<echo> ${gwt-location}/gwt-user.jar</echo>
<echo> ${gwt-location}/validation-api-1.0.0.GA.jar</echo>
<echo> ${gwt-location}/validation-api-1.0.0.GA-sources.jar</echo>
<echo> ${vaadin-jar-location}</echo>
<echo> ${src-location}</echo>
<echo>Output will be written into ${client-side-destination}</echo>
<!-- Check that files exist -->
<fail message="Some of the required files (listed above) are missing.">
<condition><not><resourcecount count="5">
<filelist files="${gwt-location}/gwt-dev.jar,${gwt-location}/gwt-user.jar,${gwt-location}/validation-api-1.0.0.GA.jar,${gwt-location}/validation-api-1.0.0.GA-sources.jar,${vaadin-jar-location}"/>
</resourcecount></not></condition>
</fail>
<!-- Construct and check classpath -->
<!-- Includes paths required for both server and client-side compilation -->
<path id="compile.classpath">
<!-- The source location must be first, as required by generate-widgetset. -->
<pathelement path="${src-location}" />
<pathelement path="${server-side-destination}" />
<pathelement path="${vaadin-jar-location}" />
<pathelement path="${gwt-location}/gwt-user.jar" />
<pathelement path="${gwt-location}/gwt-dev.jar" />
<pathelement path="${gwt-location}/validation-api-1.0.0.GA.jar" />
<pathelement path="${gwt-location}/validation-api-1.0.0.GA-sources.jar" />
<fileset dir="${base}WebContent/WEB-INF/lib/">
<include name="*.jar"/>
</fileset>
</path>
</target>
<!-- Compiled server-side components are needed for building the client-side -->
<target name="compile-server-side" depends="init">
<javac srcdir="${src-location}" destdir="${server-side-destination}">
<classpath>
<path refid="compile.classpath"/>
</classpath>
</javac>
</target>
<!-- Generates a combined widget set from all widget -->
<!-- sets in the class path, including project sources. -->
<!-- Updates the configuration if it already exists. -->
<target name="generate-widgetset"
depends="compile-server-side, configure-widgetset"
if="generate.widgetset">
<!-- Create the directory if it does not already exist. -->
<mkdir dir="${src-location}/${widgetset-path}"/>
<java classname="com.vaadin.server.widgetsetutils.WidgetSetBuilder"
failonerror="yes" fork="yes" maxmemory="256m">
<arg value="${widgetset}"/>
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<path refid="compile.classpath"/>
</classpath>
</java>
</target>
<!-- Build the widget set. -->
<target name="compile-widgetset"
depends="compile-server-side, generate-widgetset">
<echo>Compiling ${widgetset}...</echo>
<java classname="com.google.gwt.dev.Compiler"
failonerror="yes" fork="yes" maxmemory="256m">
<arg value="-war" />
<arg value="${client-side-destination}" />
<arg value="${widgetset}" />
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<path refid="compile.classpath"/>
</classpath>
</java>
</target>
<!-- Build JAR -->
<target name="package-jar"
depends="init, configure-widgetset, configure-jar">
<jar jarfile="${jar-destination}" compress="true">
<manifest>
<attribute name="Vaadin-Package-Version" value="1" />
<attribute name="Vaadin-Widgetsets" value="${widgetset}" />
<attribute name="Implementation-Title" value="${widgetset-title}" />
<attribute name="Implementation-Version" value="${widgetset-version}" />
<attribute name="Implementation-Vendor" value="${widgetset-vendor}" />
<!-- The following are Vaadin-specific. -->
<attribute name="Vaadin-License-Title" value="Apache2" />
<attribute name="Vaadin-License-File" value="http://www.apache.org/licenses/LICENSE-2.0" />
</manifest>
<!-- The built server-side classes are here. -->
<fileset dir="${server-side-destination}">
<patternset>
<include name="**/*" />
</patternset>
</fileset>
<!-- Especially all the widget set source files are required. -->
<fileset dir="${src-location}">
<patternset>
<include name="**/*" />
</patternset>
</fileset>
</jar>
</target>
</project>
|