Maven gwt:compile不生成托管的html文件

时间:2014-04-30 09:53:06

标签: maven gwt

我使用带有-maven选项的webAppCreator创建了一个测试gwt项目。

当我使用mvn gwt:compile编译项目时,我成功编译了我的文件,但是hosted.html丢失了,所以我无法启动我的应用程序。在开发模式中,一切正常。我该如何解决?

以下是pom.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/maven-v4_0_0.xsd">

  <!-- POM file generated with GWT webAppCreator -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.damluar</groupId>
  <artifactId>stockwatcher</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>com.damluar.stockwatcher</name>

  <properties>
    <!-- Convenience property to set the GWT version -->
    <gwtVersion>2.6.0</gwtVersion>
    <!-- GWT needs at least java 1.6 -->
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>${gwtVersion}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwtVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <version>${gwtVersion}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <classifier>sources</classifier>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <!-- Generate compiled stuff in the folder used for developing mode --> 
    <outputDirectory>target/www/WEB-INF/classes</outputDirectory>

    <plugins>

      <!-- GWT Maven Plugin-->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
    <version>2.2.0</version>
    <dependencies>
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwtVersion}</version>
          </dependency>
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwtVersion}</version>
          </dependency>
          <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwtVersion}</version>
          </dependency>
    </dependencies>
        <!-- JS is only needed in the package phase, this speeds up testing --> 
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <!-- Plugin configuration. There are many available options, 
             see gwt-maven-plugin documentation at codehaus.org --> 
        <configuration>
          <!-- URL that should be automatically opened in the GWT shell (gwt:run). -->
          <runTarget>stockwatcher.html</runTarget>
          <!-- Location of the develop-mode web application structure (gwt:run). -->
          <hostedWebapp>target/www</hostedWebapp>
          <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
          <compileReport>true</compileReport>
        </configuration>
      </plugin>

      <!-- Add source folders to test classpath in order to run gwt-tests as normal junit-tests -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
    <version>2.5</version>
        <configuration>
          <additionalClasspathElements>
            <additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
            <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
          </additionalClasspathElements>
          <useManifestOnlyJar>false</useManifestOnlyJar>
          <forkMode>always</forkMode>

          <!-- Folder for generated testing stuff --> 
          <systemProperties>
            <property>
              <name>gwt.args</name>
              <value>-war target/www</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>

      <!-- Copy static web files before executing gwt:run -->
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.2</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>target/www</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/webapp</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Delete gwt generated stuff -->
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
    <version>2.3</version>
        <configuration>
          <filesets>
            <fileset><directory>src/main/webapp/stockwatcher</directory></fileset>
            <fileset><directory>src/main/webapp/WEB-INF/classes</directory></fileset>
            <fileset><directory>tomcat</directory></fileset>
            <fileset><directory>www-test</directory></fileset>
            <fileset><directory>.gwt-tmp</directory></fileset>
          </filesets>
        </configuration>
      </plugin>

      <plugin>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.7</version>  <!--  Note 2.8 does not work with AspectJ aspect path -->
    <configuration>
          <downloadSources>true</downloadSources>
          <downloadJavadocs>false</downloadJavadocs>
          <wtpversion>2.0</wtpversion>
          <additionalBuildcommands>
            <buildCommand>
              <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
            </buildCommand>
          </additionalBuildcommands>
          <additionalProjectnatures>
            <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
          </additionalProjectnatures>
    </configuration>
      </plugin>

    </plugins>
  </build>
</project>

1 个答案:

答案 0 :(得分:1)

hosted.html仅用于 DevMode,因此其缺席不应阻止您在生产模式下加载应用。

如果您切换了链接器(例如切换到xsiframe链接器),则所需的文件将不同(对于xsiframe链接器,它是devmode.js)。

这与 HTML主页不同,必须在src/main/webapp中提供(一个应由{{1}为您生成在你的情况下,webAppCreator)。这是您将为DevMode和生产模式加载的页面(两者之间的切换由URL中的src/main/webapp/stockwatcher.html触发。)