Compiling a widgetset

Hi, I wanted to try the Vaadin Responsive Add-on in V7. As far as I understand for this I need to re-compile the widgetset. My question is how to compile a widgetset only with a plain Ant script within Eclipse. We don’t use Maven nor Ivy. All I have is a Java Project with all needed Vaadin-JARs in it and now I want to successfully execute the com.google.gwt.dev.Compiler. Is there any demo script for this? Thank you.

Hello Marco,
here is my ant script for generaring and compiling widgetset:

    <target name="build-widgetsets" depends="clean-widgetset, retrieve-for-widgetset, compile, generate-widgetset">
        <java classname="com.vaadin.tools.WidgetsetCompiler"
              failonerror="yes" fork="yes">
            <jvmarg value="-Djava.awt.headless=true"/>
            <jvmarg value="-Dgwt.persistentunitcachedir=${java.io.tmpdir}/widgetset_${widgetset.name}${uuid}"/>
            <arg value="-war" />
            <arg value="${widgetset.dir}" />
            <arg value="-deploy"/>
            <arg value="${java.io.tmpdir}/widgetset_${widgetset.name}${uuid}"/>
            <arg value="-extra"/>
            <arg value="${java.io.tmpdir}/widgetset_${widgetset.name}${uuid}"/>
            <arg value="-localWorkers"/>
            <arg value="4"/>
            <arg value="-logLevel"/>
            <arg value="INFO"/>
            <arg value="${widgetset.name}" />
            <classpath>
                <fileset dir="${lib.dir}" includes="**/*"/>
                <fileset dir="${WebContent.lib.dir}" includes="**/*"/>
                <pathelement path="${class.dir}"/>
            </classpath>
        </java>

        <!-- cleanup -->
        <delete dir="${java.io.tmpdir}/${widgetset.name}${uuid}"/>
        <delete dir="${widgetset.dir}/../gwt-unitCache"/>
        <delete dir="${widgetset.dir}/WEB-INF"/>
    </target>

    
    <target name="generate-widgetset" depends="retrieve-for-widgetset,compile">
        <java classname="com.vaadin.server.widgetsetutils.WidgetSetBuilder" failonerror="yes" fork="yes" maxmemory="256m">
            <arg value="${widgetset.name}"/>
            <jvmarg value="-Xss1024k"/>
            <jvmarg value="-Djava.awt.headless=true"/>
            <classpath>
                <fileset dir="${lib.dir}" includes="**/*"/>
                <pathelement path="${class.dir}"/>
            </classpath>
        </java>
    </target>

    <scriptdef name="uuid" language="javascript" description="Generate unique hash for gwt widgets temp directory">
        <attribute name="property" />
        <![CDATA[
        importClass( java.util.UUID );
        project.setProperty( attributes.get( "property" ), UUID.randomUUID() );
        ]]>
    </scriptdef>

Thank you Agata. I reduced the dependencies and added some missing variables, so the WidgetsetCompiler does some work now. But when the GWT Compiler start, I get the following error. Any idea how to fix this? Thank you.

 [java]

Starting GWT compiler
[java]
Compiling module ResponsiveWidgetSet
[java]
[ERROR]
Unexpected internal compiler error
[java]
java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException
[java]
at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:464)
[java]
at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:423)
[java]
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:373)
[java]
at com.google.gwt.dev.Precompile.precompile(Precompile.java:246)

Do you have vadin-client-compiler.jar on class path?
Maybe also vaadin-client-compiler-deps.jar is needed.

Thank you Agata - that’s it! The vaadin-client-compiler-deps.jar was needed and not in my classpath.

Hm… still having problems… managed to compile the responsive widgetset and added a paramter inside the web.xml to use it. But now the Vaadin client always gives me a dialog showing this error:


Failed to load the widgetset: ./VAADIN/widgetsets/com.vaadin.addon.responsive.ResponsiveWidgetSet/com.vaadin.addon.responsive.ResponsiveWidgetSet.nocache.js?1383816446205

It seems to me that the duplicate package name could be the problem, but I don’t know how this load address is achieved and how to correct this. Any ideas?

I use the script with libraries on class path resolved with ivy and it works fine. I would try the compilation with ivy dependencies and, if it works properly, check the downloaded libraries. Then you would remove the resolving task. I have following jars in lib/widgetset-compile directory:
ant-launcher.jar
ant.jar
apache-mime4j.jar
commons-cli.jar
commons-codec.jar
commons-collections.jar
commons-io.jar
commons-jexl.jar
commons-lang.jar
commons-logging.jar
cssparser.jar
jetty-util.jar
jetty.jar
jsoup.jar
sac.jar
servlet-api-2.5.jar
swing-worker.jar
vaadin-client-compiler-deps.jar
vaadin-client-compiler.jar
vaadin-client.jar
vaadin-server.jar
vaadin-shared-deps.jar
vaadin-shared.jar
vaadin-theme-compiler.jar
validation-api.jar

It looks like you are trying to compile the widgetset of the add-on, which is not the correct approach.

Instead, your project should have its own widgetset which imports the default widgetset and the widgetset of the add-on, and you should compile and use your own widgetset. See the help page of the directory of the Book of Vaadin or the dozens of posts elsewhere about this for more information.

Thank you both. I will try what Henri posted, because I tried to compile the add-on.

Great! Just managed to define my own widgetset - know it works! Thank you again.