Compiling widgetsets from Add-Ons without any plugins

Hello All,

I’ve been away from the forums[1]
for the last few months, working on other non-Vaadin related projects; however, I am in the early stages of planning and designing a new web application.

All that’s a roundabout way of saying I haven’t flexed my Vaadin (or, indeed, web-application) muscles for a while, so please forgive the simple newbie style questions that are about to follow.

I am trying to set up a small experimental/prototype web application using Vaadin. I want to use some add-ons from the directory : we don’t use Eclipse, and so we don’t use the Eclipse plugin. We are not (yet) developing our own Widgets.[2]

From what I remember, I believe I need to do the following

  1. Reference a custom widgetset in the web.xml
  2. Generate the widgetset based on all the widgets in the add-ons (IIRC this is an xml file saying what other widgetsets are being used)
  3. Compile the widgetset (generate the gwt javascript and the css/images used by the widgets in the widgetset)

Questions
a) Have I missed any steps?
b) Are there any unecessary steps?
c) How do I do 2 & 3?

I have been trying to deconstruct both the
NetBeans build-widgetset.xml
and the
vaadin-6.4.4\WebContent\docs\example-source\build-widgetset.xml
but I think I am going round and round in circles - I think it’s the references to “src”, when I am not compiling any of my own widgets, that’s throwing me.

In short, I’d like to develop a simple ant build file with the following customizable properties
a) the name of the widgetset to generate and compile
a) a vaadin installation directory (because it’ll contain the necessary version of gwt)
b) a directory containing all the add-ons I want to use
c) an output directory (e.g. the web root)

I suspect that both of the ant files reference above are almost - or quite possibly exactly - there; I just can’t quite cross the last hurdle!

Any and all help/pointers will be gratefully received; if I succeed in building/mangling thisbuild file, and others consider such a thing useful, I’ll happily return it to the community.

Cheers,

Charles.

[1]
This is the second time I’ve constructed this post : I hate the editor for this forum! I ended up retyping everything in a text editor, just so I wouldn’t lose it when I tried to insert tokens using the Toolbar…

[2]
Nor do we use Netbeans and it’s plugin : for what it’s worth, we use an old version (7.0.5) IntelliJ. We can’t really justify upgrading versions, and since we’ve been using IntelliJ for more than 7 years, my fingers and brain are pretty much wired-in to their way of thinking; I’ve tried many times, but I just can’t get comfortable and productive in Eclipse. Some of our dev’s do use Eclipse, but the majority don’t.

And, of course, after crafting such a long post - I see that the netbeans ant file is almost completely what I need.

Doh!

As ever, the process of explaining the problem helps to solve it.

Look, I’m replying to myself again!

I have created an ant build file, heavily based on the build-widgetset.xml build file for the NetBeans plugin. It has the following differences :

[list=2]

[]
It works out the widgetset-path from the widgetset classname
[
]
It only generates the widgetset if there are any changes to the add-ons (or Vaadin version)
[*]
It cleans up any old widgetset javascript/css/images from previous builds

[/list] It needs five properties to be completed : everything else is derived from these.

[list=2]

[]
widgetset : the classname of the widgetset to generate
[
]
vaadin-home.dir : the directory of the vaadin distribution. Used to locate the Vaadin jar, and the gwt compiler
[]
vaadin-addons.dir : the directory containing all the Vaadin add-ons to include in the widgetset
[
]
buid.web.dir : the root of the web directory, where the widgetset and the javascript/css/images of the widgets are generated to
[*]
ant-contrib.file : the path to the
ant-contrib
jar, used by tasks in the build file

[/list] In my IDE I have tied this build file to the Launch Configuration for the web application, so that any time I run it, it checks to see if vaadin or any add-ons have been changed or added, and if so generates the widgetset.

That fits nicely into my current workflow, and it may help others; I have attached it to this post. Anyone is free to use it as they see fit.

Cheers,

Charles.
11456.xml (4.51 KB)

Charles,

thanks for your contribution but can you please explain a bit more about your project setup/structure/artifacts/run configuration in intellij idea?

I have a question regarding widgetsets.

This is the ANT part from VAADIN:


	    <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"/>
	
	        <!-- Define if the widget set be generated automatically -->
	        <!-- from all widget sets included in the class path.    -->
	        <!-- <property name="generate.widgetset" value="1"/>     --> 
	       
	        <!-- Path to the widgetset directory. Required only for --> 
	        <!-- generated widget sets. Must be relative to         --> 
	        <!-- $src-location, that is, under the first entry in   --> 
	        <!--  class path.                                       --> 
	        <property name="widgetset-path" value="com/vaadin/demo/widgetset"/>
	    </target>

And the following is your modified ANT script:


    <!-- *************************************************************************************************************-->  
    <!-- The classname of the widgetset to generate -->
    <property name="widgetset" value="..."/>
    <!-- The root of the web application. The Widgetset will be generated to WEB-INF/classes, and the GWT code to VAADIN/widgetsets. -->
    <property name="build.web.dir" value="${basedir}/out/generated-widgetset"/>
    <!-- The location of all of the vaadin add-ons to include in the widgetset -->
    <property name="runtime-jars.dir" value="${basedir}/lib/runtime"/>
    <!-- The location of all of the files needed to generate the widgeset -->
    <property name="build-support.dir" value="${basedir}/lib/build-support"/>
    <!-- *************************************************************************************************************-->
    
    <target name="generate-widgetset" description="Generates the widgetset, if necessary ">

It seems either way that your modified script should search for widgetsets and generate them anyway, but it doesn’t. Is that because I have filled out the property “widgetset”? Is there a way to put a wildcard there too, like ${srcdir} then it could search all source paths in my project, since I have more than one?

VAADIN proposes the entry “generate.widgetset=1” in order to make it work. Your entry is with a dash and has only a description. Do I need to add the value “1” in there? Is it just a matter of script versions that you have a dash instead of a dot?