Build script for Vaadin Application

Hi , Is there a way to build the Vaadin Application using ant Script , I can build the application from eclipse but i want an ant script that i can run from the terminal and build the whole application . I tried with the normal Java build script but I am not able to compile the GWT component . Please help me out . Thanks in advance.

Hi Dave,

There are some different ways to compile your Vaadin widgetset.
The easiest way to cpmpile is:

$ ant -f build-widgetset.xml

but otherwise when you wil create an build.xml look at the
Bookf of Vaadin
there is an good example.

Thanks Christian , I will give it a try .

Please give me a report if its work and paste the code here?

Below is an example widgetset build script. It will need some project specific configurations: you have to configure those properties and path to match your project settings. If you have Vaadin add-ons in your project those might be needed to added jar by jar to build script (e.g. )


<?xml version="1.0" encoding="UTF-8"?>
<project name="Compile Vaadin Widgetset" default="compile-widgetset" basedir=".">
	<target name="widgetset-init">
		<!-- Folders -->
		<property name="src.dir" value="src" />
                <property name="lib.dir" value="lib" />
		<property name="build.web.dir" value="WebContent" />

		<!-- Name of the widget set -->
		<property name="widgetset" value="org.example.YourWidgetset" />

		<!-- Path to the widgetset directory. Required only for -->
		<!-- generated widget sets. Must be relative to         -->
		<!-- $src.dir, that is, under the first entry in        -->
		<!-- classpath.                                         -->
		<property name="widgetset-path" value="org/example" />

		<!-- Target where to compile the widget set -->
		<property name="client-side-destination" value="WebContent/VAADIN/widgetsets" />

		<!-- Define if the widget set be generated automatically -->
		<!-- from all widget sets included in the class path.    -->
	</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="widgetset-init" if="generate.widgetset">
		<echo>Updating ${widgetset}...</echo>
		<echo>Remember to define the widgetset in web.xml as follows.</echo>
		<echo>
            &lt;init-param&gt;
                &lt;param-name&gt;widgetset&lt;/param-name&gt;
                &lt;param-value&gt;${widgetset}&lt;/param-value&gt;
            &lt;/init-param&gt;
        </echo>

		<!-- Create the directory if it does not already exist. -->
		<mkdir dir="${src.dir}/${widgetset-path}" />

		<java classname="com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="${widgetset}" />
			<jvmarg value="-Xss1024k" />
			<jvmarg value="-Djava.awt.headless=true" />
			<classpath>
				<pathelement path="${src.dir}" />
				<pathelement path="${build.web.dir}/WEB-INF/classes" />
				<pathelement location="${lib.dir}/gwt-user.jar" />
				<pathelement location="${lib.dir}/gwt-dev.jar" />
				<fileset dir="${build.web.dir}/WEB-INF/lib/">
					<include name="*.jar" />
				</fileset>
                                <fileset dir="${lib.dir}">
					<include name="*.jar" />
				</fileset>
			</classpath>
		</java>
	</target>

	<!-- Compiles the widget set using the GWT compiler. -->
	<target name="compile-widgetset" depends="widgetset-init, generate-widgetset">
		<echo>Compiling ${widgetset} into ${client-side-destination} directory...</echo>
		<java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="1000m">
			<arg value="-draftCompile"/>
			<arg value="-localWorkers"/>
			<arg value="2"/>
			<arg value="-style" />
			<arg value="PRETTY" />
			<arg value="-war" />
			<arg value="${client-side-destination}" />
			<arg value="${widgetset}" />
			<jvmarg value="-Xss1024k" />
			<jvmarg value="-Djava.awt.headless=true" />
			<classpath>
				<pathelement location="${lib.dir}/gwt-user.jar" />
				<pathelement location="${lib.dir}/gwt-dev.jar" />
				<fileset dir="${build.web.dir}/WEB-INF/lib/">
					<include name="*.jar" />
				</fileset>
                                <fileset dir="${lib.dir}">
					<include name="*.jar" />
				</fileset>
				<pathelement path="${src.dir}/" />
				<pathelement path="${build.web.dir}/WEB-INF/classes" />
			</classpath>
		</java>
	</target>
</project>

Thank you for your work and code example Johannes i will try it too… but later im still at work :slight_smile:

Hi,

The thing is I generated the widgetSet using eclipse plugin and some how there are no *widgetset.gwt.xml generated I search and i could not find any xml file for that particular widget.

It generated two files com.test.widget.Helloworld.java and com.test.widgetset.ui.VHelloworld.java and when i try to build using the build script it says it is unable to find the *.gwt.xml

My application use treetable widget library and it also need to be compiled during my GWT compilation. So I am kinda lost on how to build using ant .
In eclipse it automatically compiles all the jar files and the widgetset but i am unable to find the script that is called when ctrl+6 is pressed.

Also using eclipse compilation i am able to use the widget in my application without any problem even though it does not have a *.gwt.xml

thanks
dave

Hi ,

After i run the ant task I am able to compile most of the widgetset i have but I am not able to compile the Custom widgetset in source folder.

My Custom widget is in src/abcd/xyz/widgets/TestWidget.java

My Client widget is in src/abcd/xyz/widgetset/client/ui/VTestWidget.java

Eclipse is able to compile it but using custom build script i am unable to compile.

Client widget Annotation is present in my Custom widget , @ClientWidget(VTestWidget.class)

Am i doing anything wrong here.

thanks

My build snippet is as follows ,


<target name="compile-widgetset" depends="widgetset-init, generate-widgetset">
    <echo>Compiling ${widgetset} into ${client-side-destination} directory...</echo>
    <java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="1000m">
        <arg value="-draftCompile"/>
        <arg value="-localWorkers"/>
        <arg value="2"/>
        <arg value="-style" />
        <arg value="PRETTY" />
        <arg value="-war" />
        <arg value="${client-side-destination}" />
        <arg value="${widgetset}" />
        <jvmarg value="-Xss1024k" />
        <jvmarg value="-Djava.awt.headless=true" />
        <classpath>
            <pathelement location="${lib.dir}/gwt-user.jar" />
            <pathelement location="${lib.dir}/gwt-dev.jar" />
            <fileset dir="${build.web.dir}/WEB-INF/lib/">
                <include name="*.jar" />
            </fileset>
                            <fileset dir="${lib.dir}">
                <include name="*.jar" />
            </fileset>
            <pathelement path="${src.dir}/" />
            <pathelement path="${build.web.dir}/WEB-INF/classes" />
        </classpath>
    </java>
</target>

Resulting log : The log is similar to the one GWT compilation with eclipse but the only difference is that my custom widget is present in eclipse log output but not in my custom build script.

[java] Widget set will contain implementations for following components: . . . . com.abcd.xyz.widgets.TestWidget . [java] Done. (0seconds) generate-widgetset: [echo] Updating com.abc.xyz.widgetset.TreetableWidgetset... [echo] Remember to define the widgetset in web.xml as follows. [echo]
 [echo]
         <init-param>
 [echo]
             <param-name>widgetset</param-name>
 [echo]
             <param-value>com.abcd.xyz.widgetset.TreetableWidgetset</param-value>
 [echo]
         </init-param>
 [echo]
     
 [java]

Dec 8, 2011 2:55:11 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[java]
INFO: Widgetsets found from classpath:
[java]
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/vaadin-6.6.3.jar!/
[java]
org.vaadin.hezamu.canvas.widgetset.CanvastestWidgetset in jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/canvaswidget-1.0.1.jar!/
[java]
com.vaadin.addon.treetable.TreetableWidgetset in jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/vaadin-treetable-1.2.2.jar!/
[java]
com.github.wolfie.sessionguard.SessionguardWidgetset in jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/sessionguard-0.0.4.jar!/
[java]
org.vaadin.johannes.graph.VaadingraphWidgetset in jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/VaadinGraph.jar!/
[java]
com.abcd.xyz.widgetset.TreetableWidgetset in file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/src
[java]

 [java]

Dec 8, 2011 2:55:11 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[java]
INFO: Search took 8ms

compile-widgetset:
[echo]
Compiling com.abcd.xyz.widgetset.TreetableWidgetset into WebContent/VAADIN/widgetsets directory…
[java]
Compiling module com.abcd.xyz.widgetset.TreetableWidgetset
[java]
Validating newly compiled units
[java]
[WARN]
Warnings in ‘jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/gwt-incubator-20100204-r1747.jar!/com/google/gwt/widgetideas/client/impl/GlassPanelImpl.java’
[java]
[WARN]
Line 30: Referencing deprecated class ‘com.google.gwt.user.client.impl.DocumentRootImpl’
[java]
[WARN]
Line 38: Referencing deprecated class ‘com.google.gwt.user.client.impl.DocumentRootImpl’
[java]
Scanning for additional dependencies: jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/vaadin-6.6.3.jar!/com/vaadin/terminal/gwt/client/WidgetSet.java
[java]
Computing all possible rebind results for ‘com.vaadin.terminal.gwt.client.WidgetMap’
[java]
Rebinding com.vaadin.terminal.gwt.client.WidgetMap
[java]
Invoking generator com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator
[java]
Detecting Vaadin components in classpath to generate WidgetMapImpl.java …
[java]
Dec 8, 2011 2:55:39 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
[java]
INFO: Searching for paintables…
[java]
Dec 8, 2011 2:55:40 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
[java]
INFO: Search took 836ms
[java]
Widget set will contain implementations for following components:
[java]
com.github.wolfie.sessionguard.SessionGuard
[java]
com.vaadin.addon.treetable.TreeTable
[java]
com.vaadin.ui.AbsoluteLayout
[java]
com.vaadin.ui.Accordion
[java]
com.vaadin.ui.Button
[java]
com.vaadin.ui.CheckBox
[java]
com.vaadin.ui.ComboBox
[java]
com.vaadin.ui.CssLayout
[java]
com.vaadin.ui.CustomComponent
[java]
com.vaadin.ui.CustomLayout
[java]
com.vaadin.ui.DateField
[java]
com.vaadin.ui.DragAndDropWrapper
[java]
com.vaadin.ui.Embedded
[java]
com.vaadin.ui.Form
[java]
com.vaadin.ui.FormLayout
[java]
com.vaadin.ui.GridLayout
[java]
com.vaadin.ui.HorizontalLayout
[java]
com.vaadin.ui.HorizontalSplitPanel
[java]
com.vaadin.ui.InlineDateField
[java]
com.vaadin.ui.Label
[java]
com.vaadin.ui.Link
[java]
com.vaadin.ui.ListSelect
[java]
com.vaadin.ui.MenuBar
[java]
com.vaadin.ui.NativeButton
[java]
com.vaadin.ui.NativeSelect
[java]
com.vaadin.ui.OptionGroup
[java]
com.vaadin.ui.OrderedLayout
[java]
com.vaadin.ui.Panel
[java]
com.vaadin.ui.PasswordField
[java]
com.vaadin.ui.PopupView
[java]
com.vaadin.ui.ProgressIndicator
[java]
com.vaadin.ui.RichTextArea
[java]
com.vaadin.ui.Select
[java]
com.vaadin.ui.Slider
[java]
com.vaadin.ui.SplitPanel
[java]
com.vaadin.ui.TabSheet
[java]
com.vaadin.ui.Table
[java]
com.vaadin.ui.TextArea
[java]
com.vaadin.ui.TextField
[java]
com.vaadin.ui.Tree
[java]
com.vaadin.ui.TwinColSelect
[java]
com.vaadin.ui.Upload
[java]
com.vaadin.ui.UriFragmentUtility
[java]
com.vaadin.ui.VerticalLayout
[java]
com.vaadin.ui.VerticalSplitPanel
[java]
com.vaadin.ui.Window
[java]
org.vaadin.hezamu.canvas.Canvas
[java]
org.vaadin.johannes.graph.VaadinGraph
[java]
Done. (0seconds)
[java]
Scanning for additional dependencies: jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/gwt-graphics-0.9.7.jar!/org/vaadin/gwtgraphics/client/DrawingArea.java
[java]
Computing all possible rebind results for ‘org.vaadin.gwtgraphics.client.impl.SVGImpl’
[java]
Rebinding org.vaadin.gwtgraphics.client.impl.SVGImpl
[java]
Could not find an exact match rule. Using ‘closest’ rule based on fall back values. You may need to implement a specific binding in case the fall back behavior does not replace the missing binding
[java]
Scanning for additional dependencies: jar:file:/home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/WEB-INF/lib/vaadin-6.6.3.jar!/com/vaadin/terminal/gwt/client/ui/dd/VAcceptCriteria.java
[java]
Computing all possible rebind results for ‘com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory’
[java]
Rebinding com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory
[java]
Invoking generator com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator
[java]
Detecting available criteria …
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.Not
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll
[java]
creating mapping for com.vaadin.ui.Tree.TreeDropCriterion
[java]
creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem
[java]
creating mapping for com.vaadin.ui.Table.TableDropCriterion
[java]
creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs
[java]
creating mapping for com.vaadin.ui.Tree.TargetInSubtree
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.Or
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.And
[java]
creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs
[java]
Done. (0seconds)
[java]
Compiling 6 permutations
[java]
Compiling permutation 0…
[java]
Process output
[java]
Compiling
[java]
Compiling permutation 1…
[java]
Compiling permutation 2…
[java]
Compiling
[java]
Compiling permutation 3…
[java]
Compiling permutation 4…
[java]
Compiling
[java]
Compiling permutation 5…
[java]
Compile of permutations succeeded
[java]
Linking into /home/dave/ABCdef-project/abcd/test-ui/abcd-xyz/WebContent/VAADIN/widgetsets/com.abcd.xyz.widgetset.TreetableWidgetset
[java]
Link succeeded
[java]
Compilation succeeded – 66.974s