How to compile widgetset without eclipse (Vaadin 7.5.7)?

Hi,

I’m trying to compile a widgetset for vaadin 7.5.7 wihtout using the eclipse plugin. To do that I use the ant script from here: https://vaadin.com/download/misc/build-widgetset.xml

First problem is that the ant script above is not compatible to Vaadin 7.5.7. I have adjust the script to

<?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}/WebContent/WEB-INF/lib/vaadin-client-compiler-@version@.jar" />
        <property name="ant-jar-location"
                  value="${base}/extLib/antExt/vaadin/ant-1.6.5.jar" />

        <!-- 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}/src" />

        <!-- Target where to compile server-side classes -->
        <property name="server-side-destination"
                  value="${base}/build/classes"/>
        
        <!-- Target where to compile the widget set -->
        <property name="client-side-destination"
                  value="${base}WebContent/VAADIN/widgetsets" />
    </target>
        
    <!-- NOTE: Modify this example 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.xyz.vaadin.widgetset.XyzvaadinWidgetset"/>

        <!-- 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="XyzVaadin.VAADIN/com.xyz.vaadin.widgetset.XyzvaadinWidgetset/"/>
    </target>

    <!-- Note: Modify this example to compile 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="IT Mill Oy"/>
    </target>
    
    <!-- ================================================== -->
    <!-- Build Targets                                      -->
  <!-- ================================================== -->

  <target name="init" depends="configure">
    <echo>Requirements for classpath:</echo>
    <echo>  ${gwt-location}</echo>
    <!-- echo>  ${gwt-location}/validation-api-1.0.0.GA.jar.save</echo>
    <echo>  ${gwt-location}/validation-api-1.0.0.GA-sources.jar.save</echo -->
    <echo>  ${ant-jar-location}</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="3">
            <!-- filelist
                files="${gwt-location}/gwt-dev.jar.save,${gwt-location}/gwt-user.jar.save,${gwt-location}/validation-api-1.0.0.GA.jar.save,${gwt-location}/validation-api-1.0.0.GA-sources.jar.save,${vaadin-jar-location},${ant-jar-location}"/ -->
            <filelist
                files="${gwt-location},${vaadin-jar-location},${ant-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="${ant-jar-location}"/>
      <pathelement path="${gwt-location}"/>
      <!-- pathelement path="${gwt-location}/validation-api-1.0.0.GA.jar.save"/>
      <pathelement path="${gwt-location}/validation-api-1.0.0.GA-sources.jar.save"/ -->
      <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.terminal.gwt.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>

The libraries used by the ant script are:

  • vaadin-*-7.5.7.jar
  • ant-1.6.5.jar

But if I run the script I get following exception:

    at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
    at com.google.gwt.dev.Compiler.main(Compiler.java:127)
Caused by: java.lang.ClassNotFoundException: com.google.gwt.core.ext.GeneratorExt
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 139 more

But I cannot find the GeneratorExt class in any jar file of Vaadin 7.5.7. Anybody knows whats wrong or missing? Is there anywhere a tutorial how I can compile a widgetset for Vaadin 7.5/7.6 “by hand” (means: without using the eclipse plugin)?

Thanks,
Steffen



EDIT

Same result by using following command line call:

java -classpath vaadin-client-compiler-7.5.7.jar:guava-16.0.1.vaadin1.jar:../../../src:gwt-user.jar:vaadin-widgets-7.5.7.jar:ant-1.6.5.jar com.google.gwt.dev.Compiler -war ../../VAADIN/widgetsets com.xyz.vaadin.widgetset.XyzvaadinWidgetset

The dependencies are a bit complex and therefore it’s easiest to compile using Eclipse or Maven (or some other tool which handles the dependencies for you). On thing you can do is create a Maven project using an archetype, e.g.

mvn archetype:generate -DgroupId=com.example -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.6.0 -DartifactId=wstest and then compile the widget set using the Maven debug parameter (-X)

mvn vaadin:compile -X and look at what it includes on the classpath - quite a lot

target/classes
src/main/java
src/main/resources

ant-1.6.5.jar
ant-launcher-1.6.5.jar
apache-mime4j-0.6.jar
asm-5.0.3.jar
asm-commons-5.0.3.jar
asm-tree-5.0.3.jar
asm-util-5.0.3.jar
atmosphere-runtime-2.2.7.vaadin1.jar
commons-codec-1.8.jar
commons-collections-3.1.jar
commons-io-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
cssparser-0.9.11.jar
flute-1.3.0.gg2.jar
guava-16.0.1.vaadin1.jar
httpclient-4.3.1.jar
httpcore-4.3.jar
httpmime-4.3.1.jar
icu4j-50.1.1.jar
javax.activation-1.1.0.v201105071233.jar
javax.annotation-1.1.0.v201108011116.jar
javax.mail.glassfish-1.4.1.v201005082020.jar
javax.servlet-3.0.0.v201112011016.jar
javax.servlet-api-3.0.1.jar
javax.transaction-1.1.1.v201105210645.jar
jetty-annotations-8.1.12.v20130726.jar
jetty-client-8.1.12.v20130726.jar
jetty-continuation-8.1.12.v20130726.jar
jetty-http-8.1.12.v20130726.jar
jetty-io-8.1.12.v20130726.jar
jetty-jndi-8.1.12.v20130726.jar
jetty-plus-8.1.12.v20130726.jar
jetty-security-8.1.12.v20130726.jar
jetty-server-8.1.12.v20130726.jar
jetty-servlet-8.1.12.v20130726.jar
jetty-servlets-8.1.12.v20130726.jar
jetty-util-8.1.12.v20130726.jar
jetty-webapp-8.1.12.v20130726.jar
jetty-xml-8.1.12.v20130726.jar
js-1.7R2.jar
jsoup-1.8.3.jar
nekohtml-1.9.19.jar
org.objectweb.asm-3.1.0.v200803061910.jar
sac-1.3.jar
serializer-2.7.1.jar
streamhtmlparser-jsilver-0.0.10.vaadin1.jar
swing-worker-1.1.jar
vaadin-client-7.6.0.jar
vaadin-client-compiler-7.6.0.jar
vaadin-client-compiler-deps-1.2.0.jar
vaadin-push-7.6.0.jar
vaadin-sass-compiler-0.9.13.jar
vaadin-server-7.6.0.jar
vaadin-shared-7.6.0.jar
vaadin-slf4j-jdk14-1.6.1.jar
vaadin-themes-7.6.0.jar
validation-api-1.0.0.GA-sources.jar
validation-api-1.0.0.GA.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
yuicompressor-2.4.8.jar

What you also want to ensure that you DO NOT include gwt-user.jar or any gwt-.jar, as these classes are already in vaadin-.jar