Kevin Cruijssen
Kevin Cruijssen

Reputation: 9326

Vaadin Widgetset.gwt.xml inherits-tag automatically removed on compile

Recently we updated Vaadin 7 to Vaadin 8. One of our components wasn't working, and when analyzing the problem today I found it was due to still being Vaadin 7, and having mismatches. So I updated the component to Vaadin 8 (although still using all the .v7 libraries for now, and added the @Widgetset("com.vaadin.v7.Vaadin7WidgetSet") on the UI class, as well as added the vaadin-compatibility-client-compiled maven dependency.
Our test-WAR of this component was working as it should again, and I deployed this new version to our Nexus (with a TODO to actually update all the Vaadin 7 and Viritin components to Vaadin 8).

Now in our main project (where we use this component) I've updated it's version in the pom.xml, but when running it gave the same error as before I added the @Widgetset to the component's UI-class. Our main project already has an @Widgetset with a custom Widgetset of ours. I figured I'd just add the com.vaadin.v7.Vaadin7WidgetSet as <inherits> to this Widgetset.gwt.xml file of our main project, but when I do and save, some Maven plugin autmatically resets it to what it was.

This is what our Widgetset.gwt.xml currently looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
        "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name="com.vaadin.DefaultWidgetSet" />

    <stylesheet src="resetbuttonfortextfield/styles.css" />
</module>

And when I try to add these two lines:

<!-- TODO: Remove following inherit after Templates Component has been migrated to Vaadin 8 -->
<inherits name="com.vaadin.v7.Vaadin7WidgetSet" />

Only the TODO-comment remains after saving. Since my co-workers for this project all live on the other side of the world where it's currently evening, I can't really contact them for help, so I resort to StackOverflow instead.

Here is our pom.xml as reference, and I think something here causes the Widgetset.gwt.xml to reset after I save it:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
      <groupId>our.project</groupId>
      <artifactId>web-parent</artifactId>
      <version>develop-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

  <artifactId>web2-widgetset</artifactId>
  <name>web2-widgetset</name>
  <packaging>jar</packaging>

  <dependencies>
    <!-- Versions for these are configured in the parent POM -->
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-server</artifactId>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-client</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-client-compiler</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-maven-plugin</artifactId>
        <configuration>
          <extraJvmArgs>-Xmx1024M -Xss2048k</extraJvmArgs>
          <webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
          <draftCompile>true</draftCompile>
          <compileReport>false</compileReport>
          <!-- Change to PRETTY (or possibly DETAILED) to get unobfuscated client side stack traces. A better approach for debugging is to use Super Dev  Mode -->
          <style>OBF</style>
          <strict>true</strict>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>update-widgetset</goal>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Vaadin-Package-Version>1</Vaadin-Package-Version>
              <Vaadin-Widgetsets>our.project.Widgetset</Vaadin-Widgetsets>
            </manifestEntries>
          </archive>
          <!-- Exclude some unnecessary files generated by the GWT compiler. -->
          <excludes>
            <exclude>VAADIN/gwt-unitCache/**</exclude>
            <exclude>VAADIN/widgetsets/WEB-INF/**</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

I'm assuming the vaadin-maven-plugin with <goal>update-widgetset</goal> is responsible for removing my <inherits>-tag in the Widgetset.gwt.xml, but I'm not entirely sure. I'm still relatively new to Maven in general.
But if I'm right, how do I modify the pom.xml so it will also add this <inherits>-tag I need?

TL;DR: How to permanently add an additional <inherits>-tag in my Widgetset.gwt.xml (without having some plugin in our Maven pom.xml overwrite these manual changes)?


EDIT: If I comment out <goal>update-widgetset</goal> the Widgetset.gwt.xml isn't updated anymore, but it is giving an error in the pom.xml:

GWT Module com.vaadin.v7.Vaadin7WidgetSet not found in project sources or resources. (com.vaadin:vaadin-maven-plugin:8.0.6:compile:default:process-classes)

org.apache.maven.plugin.MojoExecutionException: GWT Module com.vaadin.v7.Vaadin7WidgetSet not found in project sources or resources.
    at org.codehaus.mojo.gwt.shell.CompileMojo.compilationRequired(CompileMojo.java:701)
    at org.codehaus.mojo.gwt.shell.CompileMojo.compile(CompileMojo.java:567)
    at org.codehaus.mojo.gwt.shell.CompileMojo.doExecute(CompileMojo.java:435)
    at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo.execute(AbstractGwtShellMojo.java:182)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
    at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
    at com.vaadin.integration.eclipse.maven.VaadinMojoExecutionBuildParticipant.build(VaadinMojoExecutionBuildParticipant.java:87)
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.codehaus.mojo.gwt.utils.GwtModuleReaderException: GWT Module com.vaadin.v7.Vaadin7WidgetSet not found in project sources or resources.
    at org.codehaus.mojo.gwt.AbstractGwtModuleMojo.readModule(AbstractGwtModuleMojo.java:209)
    at org.codehaus.mojo.gwt.GwtModule.getLocalInherits(GwtModule.java:189)
    at org.codehaus.mojo.gwt.GwtModule.getInherits(GwtModule.java:149)
    at org.codehaus.mojo.gwt.GwtModule.getEntryPoints(GwtModule.java:114)
    at org.codehaus.mojo.gwt.shell.CompileMojo.compilationRequired(CompileMojo.java:615)
    ... 36 more

Which is already a great step in the right direction of what caused the <inherits> to be removed automatically. Seems like I need to figure out the relevant dependency and add it to the pom.xml if I understand correctly.

Upvotes: 1

Views: 1060

Answers (1)

Kevin Cruijssen
Kevin Cruijssen

Reputation: 9326

Ok, fixed. I came across this post of someone else migrating Vaadin 7 to 8 and having some issues with the Widgetset: https://vaadin.com/forum/#!/thread/15031831/15036434

And the first reply (which I quote here) solved my problem:

Hi, good to know that you are enjoying the new version :) Check the following:

  • You have to replace the vaadin-server dependency with vaadin-compatibility-server.
  • If you are using the default widgetset (you are not compiling it by yourself):
    • Replace the vaadin-client-compiled dependency with vaadin-compatibility-client-compiled.
    • Add @Widgetset("com.vaadin.v7.Vaadin7WidgetSet") to your UI implementations.
  • If you are using a custom widgetset:
    • Replace the vaadin-client dependency with vaadin-compatibility-client.
    • Recompile it.

So I changed vaadin-client with vaadin-compatibility-client in our Widgetset's pom.xml and now the <inherits>-tag remains.

Upvotes: 1

Related Questions