【问题标题】:Breaking out Vaadin widgetset compilation突破 Vaadin 小部件集编译
【发布时间】:2013-08-16 09:55:16
【问题描述】:

为了节省编译时间,我试图将小部件集的编译分解为它自己的 TeamCity 构建项目,我们使用 nexus 作为 repo。 Vaadin“基础项目”将包含对 widgetset 工件的依赖项以获取当前版本。我敢肯定这之前已经做过了。

widgetset 项目在 TeamCity 中构建良好。 jar 和 pom 已正确上传到 nexus。我已经打开了罐子的包装,以确保一切都在原位。到目前为止一切顺利。

在 Eclipse 中,基础项目会获取 widgetset 工件并将其包含在其库中。看起来不错。

但是,当我从 eclipse 对基础项目执行“mvn clean package”并在 Tomcat 上运行它时,我在 Web 浏览器中收到以下错误:

Failed to load the widgetset: ./VAADIN/widgetsets/com.example.somerandomapp.web.AppWidgetSet/com.example.somerandomapp.web.AppWidgetSet.nocache.js?1376642850734

当我检查项目结构时,我发现目标文件夹下没有 VAADIN/widgetset-folder。此外,在 maven 依赖 jar 文件中,有一个包含 gwt-unitCache 的 VAADIN 文件夹和一个包含 widgetset-goodies 的 VAADIN.widgetsets-folder,以及上述错误消息中提到的文件。

我无法理解这一点。我不是专家,所以我可能错过了一些琐碎的事情。另外我不是 Vaadin 专业人士,所以我可能错过了一些同样琐碎的事情。

我真的希望有人能帮我把这艘船弄到水里。我将不胜感激!

Vaadin 版本:7.1.1 Maven 版本:3.0.4

我的基础项目的 pom.xml(为简洁起见省略了一些内容):

<dependencies>

    <!-- Some Random App - Commons -->
    <dependency>
        <groupId>com.example.somerandomapp.common</groupId>
        <artifactId>somerandomapp-common-widgetset</artifactId>
        <version>0.0.5-SNAPSHOT</version>
    </dependency>

    <!-- Vaadin -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-push</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
        <version>${vaadin.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${javax-servlet-api.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven-war-plugin.version}</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

我的 widgetset-pom(为简洁起见省略了一些内容):

<!-- same Vaadin-plugins as in the "base project" -->
<!-- maven compiler, release, javadoc, deploy and source artifacts -->
    <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>${maven-clean-plugin.version}</version>
        <configuration>
            <filesets>
                <fileset>
                    <directory>src/main/webapp/VAADIN/widgetsets</directory>
                </fileset>
            </filesets>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${maven-jar-plugin.version}</version>
        <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
            <excludes>
                <exclude>VAADIN/widgetsets/WEB-INF/**</exclude>
            </excludes>
        </configuration>
    </plugin>

    <plugin>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-maven-plugin</artifactId>
        <version>${vaadin-plugin.version}</version>
        <configuration>
            <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
            <!-- <runTarget>mobilemail</runTarget> -->
            <!-- We are doing "inplace" but into subdir VAADIN/widgetsets. This 
                 way compatible with Vaadin eclipse plugin. -->
            <webappDirectory>${project.build.outputDirectory}/VAADIN/widgetsets</webappDirectory>
            <hostedWebapp>${project.build.outputDirectory}/VAADIN/widgetsets</hostedWebapp>
            <noServer>true</noServer>
            <!-- Remove draftCompile when project is ready -->
            <draftCompile>false</draftCompile>
            <compileReport>true</compileReport>
            <style>OBF</style>
            <strict>true</strict>
            <runTarget>http://localhost:8080/</runTarget>
        </configuration>
        <executions>
            <execution>
                <goals>
                   <goal>clean</goal>
                    <goal>resources</goal>
                    <goal>update-theme</goal>
                    <goal>update-widgetset</goal>
                    <goal>compile-theme</goal>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
<pluginManagement>
    <plugins>    
        <!--This plugin's configuration is used to store Eclipse m2e settings 
            only. It has no influence on the Maven build itself. -->
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>com.vaadin</groupId>
                                <artifactId>vaadin-maven-plugin</artifactId>
                                <versionRange>[7.1.1,)</versionRange>
                                <goals>
                                    <goal>update-theme</goal>
                                    <goal>resources</goal>
                                    <goal>compile-theme</goal>
                                    <goal>update-widgetset</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>
</build>

更新: 我已经像这样设置了我的 MainUI 类:

@WebServlet(value = {"/foo/*", "/VAADIN/*"} , asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MainUI.class, widgetset = "com.example.somerandomapp.common.widgetset.AppWidgetSet")

我意识到这与它有关,并将其更改为正确的小部件集。但我仍然得到同样的错误:

Failed to load the widgetset: ./VAADIN/widgetsets/com.example.somerandomapp.common.widgetset.AppWidgetSet/com.example.somerandomapp.common.widgetset.AppWidgetSet.nocache.js?1376662202437

现在,这个错误显示了类路径中 nocache-file 的正确路径,这让我很困惑,因为该文件在 lib 文件夹中。 我希望这不会让你更加困惑......

更新 2: 其实这样就够了:

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MainUI.class, widgetset = "com.example.somerandomapp.common.widgetset.AppWidgetSet")

【问题讨论】:

    标签: maven maven-3 vaadin vaadin7


    【解决方案1】:

    您在我的 OP 更新后看到的更改是缺失的。

    我不确定为什么 Vaadin 一开始没有找到资源,但是在我从磁盘上擦除“基础项目”并从 SVN 重新获取它之后,做了一个清理项目并对其进行了 maven 更新,如以及干净的 Tomcat 工作目录,它神奇地工作。我猜周围有一些缓存的内容。我希望这可以帮助任何想要将 Vaadin 小部件集分解为自己的项目的人!

    【讨论】:

      【解决方案2】:

      参考Vaadin wiki(您可以在此处找到 pom.xml 示例)

      如果您的项目使用自定义 GWT 小部件,则需要编译它们 使用 GWT 编译器。这可以使用 Codehaus GWT Maven 来完成 插件。

      您必须使用GWT maven plugin 编译小部件集(这个插件有点棘手,因为我认为您必须下载 GWT SDK)

      如果使用了 'vaadin-maven-plugin',widgetset(如果有的话)可以是 根据项目依赖自动更新。这是实现的 Maven 目标 'vaadin:update-widgetset' 后跟 'gwt:编译'。在之前运行目标 clean(或 gwt:clean) 推荐使用 vaadin:update-widgetset。

      【讨论】:

      • 我不完全确定是否需要使用 Vaadin 7.1.1。我见过的所有例子都是使用 vaadin-maven-plugin。您链接的示例都来自 Vaadin 6,当时 GWT 还不是 Vaadin 的核心组件。同样,一切都编译得很好。问题在于 Vaadin 无法在库中找到小部件集。
      • 好吧,从 GWT 的角度来看,我认为 6 和 7 之间没有太大区别。小部件集的使用方式相同。如果你想使用自己的小部件集,你需要用 GWT 编译它,我想没有其他方法。
      • 我的目标不是使用“我自己的”小部件集。我现在什至没有使用任何小部件/插件/插件。事实上,widgetset 和它的构建过程与我第一次创建项目时非常相似。我正在寻找的是将小部件集从我的主项目中拆分为一个自己的项目,以便我可以在单独的构建过程中运行小部件集。对于 Vaadin,在这种情况下,无论您在哪里编译它,它都是同一个小部件集,不是吗?也许我误解了您要告诉我的内容。在那种情况下,我道歉!
      • Roger,默认 Vaadin 小部件的名称是 com.vaadin.DefaultWidgetSet。所以,我想使用名称为com.example.somerandomapp.common.widgetset.AppWidgetSet 的小部件集,它是“你自己的”小部件集,尽管它仅继承自默认的 vaadin 小部件集。 所以,无论如何你必须用 GWT 编译它。或者我不知道它是否可行,但您可以将默认小部件从 vaadin-client-compiled 复制到 webapps/VAADIN 并将其重命名为您的命名空间。
      • 感谢您的努力,米兰!如果您阅读我两天前在 OP 中所做的更新,您会看到 widgetset-name 是我缺少的东西之一。它不起作用的原因一定是一些缓存的内容(阅读我的答案)。我仍然没有使用 GWT 本身,我认为 V7 中的“vaadin-maven-plugin”会自动处理(即“内置”)(如果我错了,请纠正我)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-12
      • 2019-04-23
      相关资源
      最近更新 更多