Filip Majernik
Filip Majernik

Reputation: 7810

How to compile a widgetSet in vaadin?

I am trying to use the visualizationsForVaadin add-on. The problem is, that I have to compile a custom widgetSet. I've been dealing with this the whole day, and still cannot compile it. First of all, here is my configuration:

following dependencies are in my pom file:

When I try to compile the widgetSet with maven gwt plugin I get an exception:

Loading inherited module 'com.google.gwt.core.XSLinker'
[ERROR] Line 22: Unexpected element 'when-linker-added'
[ERROR] Failure while parsing XML

An interesting thing is, that the gwt-dev library, that is automatically loaded (as far as I know) is of version 2.0.3 I have tried everything possible (even impossible) and still nothing. At some point I had other exceptions complaining that the import of validation classes could not be resolved. I think, that has been resolved by some other dependencies. Please help. Thank you.

POM configuration:

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>gwt-maven-plugin</artifactId>
<!-- Version 2.1.0-1 works at least with Vaadin 6.5 -->
 <version>2.3.0</version>
 <configuration>
     <!-- if you don't specify any modules, the plugin will find them -->
     <!--modules>
         ..
     </modules-->
     <webappDirectory>${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets</webappDirectory>
     <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
     <runTarget>clean</runTarget>
     <hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
     <noServer>true</noServer>
     <port>8080</port>
     <soyc>false</soyc>
 </configuration>
 <executions>
     <execution>
         <goals>
             <goal>resources</goal>
             <goal>compile</goal>
         </goals>
     </execution>
 </executions>
 <dependencies>
    <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-dev</artifactId>
    <version>2.3.0</version>
    </dependency>
    <dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-user</artifactId>
    <version>${gwt.version}</version>
    </dependency>
</dependencies>
</plugin>

And here are the GWT dependencies

<dependency>
        <groupId>com.google.gwt.google-apis</groupId>
        <artifactId>gwt-visualization</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>        
    <dependency>
        <groupId>com.google.gwt.google-apis</groupId>
        <artifactId>gwt-ajaxloader</artifactId>
        <version>1.1.0</version>
    </dependency>
<dependency>
        <groupId>org.vaadin.addons</groupId>
        <artifactId>visualizationsforvaadin</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
    </dependency>

Upvotes: 1

Views: 8610

Answers (2)

user95947
user95947

Reputation:

I struggled with this over the past 2 days. For future reference:

What you'll need:

<dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiler</artifactId>
        <version>${versions.vaadin}</version>
    </dependency>

Configure gwt-maven-plugin as follows (you may not need all configs that I used, of course):

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>${versions.gwt}</version>
            <configuration>
                <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                <webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets
                </webappDirectory>
                <hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets
                </hostedWebapp>
                <noServer>true</noServer>
                <draftCompile>true</draftCompile>
                <compileReport>false</compileReport>
                <style>DETAILED</style>
                <runTarget>http://localhost:8080/</runTarget>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>resources</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

The vaadin-maven-plugin:

<plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>${versions.vaadin}</version>
            <executions>
                <execution>
                    <configuration>
                        <!--<modules>
                            <module>org.vaadin.aceeditor.AceEditorWidgetSet</module>
                        </modules>-->
                    </configuration>
                    <goals>
                        <goal>update-widgetset</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

You may also want to configure your maven-clean-plugin:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>
                            ${basedir}/src/main/webapp/VAADIN/widgetsets
                        </directory>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

In web.xml for your servlet (Ace Editor as an example):

    <init-param>
        <param-name>widgetset</param-name>
        <param-value>org.vaadin.aceeditor.AceEditorWidgetSet</param-value>
    </init-param>

Note that I did NOT include gwt as a dependency in my pom.xml.

Upvotes: 3

miq
miq

Reputation: 2766

I have a fully functional Vaadin project with custom widgets in Eclipse and I can't find any references to gwt-dev anywhere in the project. Go to Project properties -> Java Build Path -> Libraries and delete all references to gwt-dev. Also remove it from your pom.xml and try to recompile the widgetset.

edit: It could also be your gwt-user dependency. Try setting the version of gwt-user to 2.3.0 (if it already isn't) and set the scope to provided.

Upvotes: 1

Related Questions