2017-09-12 52 views
1

最近我們更新了Vaadin 7到Vaadin 8.我們的一個組件沒有工作,今天在分析問題時我發現它是由於仍然是Vaadin 7 ,並有不匹配。所以我更新了組件到Vaadin 8(雖然現在仍然使用所有的.v7庫,並且在UI類中添加了@Widgetset("com.vaadin.v7.Vaadin7WidgetSet"),並且添加了vaadin-compatibility-client-compiled maven dependency。
我們的這個組件的測試WAR是作爲它工作的應該再次,我將這個新版本部署到我們的Nexus(用TODO實際上將所有Vaadin 7和Viritin組件更新到Vaadin 8)Vaadin Widgetset.gwt.xml inherits-tag在編譯時自動刪除

現在在我們的主項目中(我們使用這個組件)更新了它的版本pom.xml,但是運行時它給出了與之前我將@Widgetset添加到組件的UI類相同的錯誤。我們的主項目已經有一個@Widgetset帶有我們自定義的Widgetset。我想我只是添加com.vaadin.v7.Vaadin7WidgetSet作爲<inherits>到我們主項目的Widgetset.gwt.xml文件,但是當我做和保存時,一些Maven插件會自動將它重置爲原來的樣子。

這是我們目前Widgetset.gwt.xml樣子:

<?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> 

當我嘗試添加以下兩行:

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

只有TODO註釋仍然保存後。由於我的這個項目的同事都住在當前晚上的世界的另一邊,所以我無法真正聯繫他們尋求幫助,所以我改用了StackOverflow。

這是我們作爲參考pom.xml,我覺得這裏的東西引起Widgetset.gwt.xml復位後,我將它保存:

<?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> 

我假設vaadin-maven-plugin<goal>update-widgetset</goal>負責清除我的<inherits> - 標籤Widgetset.gwt.xml,但我不完全確定。一般來說,我對Maven還是比較陌生的。
但是如果我是對的,我該如何修改pom.xml,所以它也會加上這個<inherits> -tag我需要?

TL; DR:如何永久我Widgetset.gwt.xml添加額外的<inherits> - 標籤(而不必在我們的Maven pom.xml一些插件覆蓋這些手動更改)?


編輯:如果我註釋掉<goal>update-widgetset</goal>Widgetset.gwt.xml沒有更新了,但它給了一個錯誤的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 

這已經是在朝着正確的方向邁出的一大步是什麼導致<inherits>被自動刪除。似乎我需要弄清楚相關的依賴關係,並將其添加到pom.xml,如果我理解正確。

+1

你嘗試過了,https://github.com/vaadin/framework8-migration-tool(只是想知道) – petey

+0

@petey啊,沒有。不適用於此組件。我認爲我的同事已經在我們將主項目遷移到Vaadin 8之後使用了它,但是現在我已經看到它了。在你已經鏈接的git的自述文件中,確實聲明「_The工具沒有,而且你需要_」不過,我應該手動將'vaadin-client'和'vaadin-client-compiled'更改爲其兼容性版本。當我有一段時間時,我可能會回到舊的git標籤並嘗試使用該組件,看看我的手動更改有什麼不同。 –

回答

0

好的,固定的。我碰到這個帖子別人遷移Vaadin 7〜8,並有一些問題與視窗元件:https://vaadin.com/forum/#!/thread/15031831/15036434

而第一個回覆(我在這裏引用)解決我的問題:

嗨,好知道你正在享受新版本:)檢查以下內容:

  • 你必須更換vaadin-compatibility-servervaadin-server依賴。
  • 如果您使用的是默認視窗元件(你是不是自己編譯吧):
    • 替換vaadin-compatibility-client-compiledvaadin-client-compiled依賴。
    • @Widgetset("com.vaadin.v7.Vaadin7WidgetSet")添加到您的UI實現中。
  • 如果您使用的是自定義的視窗元件:
    • 替換vaadin-compatibility-clientvaadin-client依賴。
    • 重新編譯它。

所以我在我們視窗元件的pom.xmlvaadin-compatibility-client改變vaadin-client現在<inherits> - 標籤仍然存在。