有没有办法使用maven在生产模式下编译GWT代码

时间:2013-11-21 00:35:43

标签: maven gwt

我正在尝试在生产模式下编译GWT代码,以便在我生成的JavaScript文件中没有任何开发模式代码。我将生产模式设置为pom文件中的gwt-maven-plugin,如下所示。但是,我仍然会生成托管模式代码。我该怎么做,使用maven在生产模式下编译?我可以在我的pom文件或* .gwt.xml文件中或其他地方设置一个标志/属性吗?

        <!-- Compile Using GWT -->

        <plugin>

            <groupId>org.codehaus.mojo</groupId>

            <artifactId>gwt-maven-plugin</artifactId>

            <version>2.5.1</version>

            <executions>

                <execution>

                    <goals>

                        <goal>compile</goal>

                    </goals>

                    <configuration>

                    <productionMode>true</productionMode>

                        <classifier>war</classifier>

                        <warSourceDirectory>src/main/webapp</warSourceDirectory>

                        <webappDirectory>war</webappDirectory>

                        <module>${Module.name}</module>

                        <extraJvmArgs>${gwt.extraJvmArgs}</extraJvmArgs>

                    </configuration>

                </execution>

            </executions>

        </plugin>

我看到在GWT示例中使用Ant在生产中进行编译。在生产模式下编译时,会在其build.xml文件中调用以下内容。我在maven做这个吗?如果这是特定于Ant的,是否有一个示例在不改变现有maven结构的情况下将Ant与Maven一起使用?

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">

  <classpath>

    <pathelement location="src"/>

    <path refid="project.class.path"/>

    <pathelement location="../../validation-api-1.0.0.GA.jar" />

    <pathelement location="../../validation-api-1.0.0.GA-sources.jar" />

  </classpath>

  <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->

  <jvmarg value="-Xmx256M"/>

  <arg line="-war"/>

  <arg value="war"/>

  <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->

  <arg line="${gwt.args}"/>

  <arg value="com.google.gwt.sample.hello.Hello"/>

</java>

1 个答案:

答案 0 :(得分:0)

Maven可以很好地编译它 - 你为了执行什么样的例子,这样你就错过了phase标签?

尝试在<phase>prepare-package</phase>块之前或之后添加goals,然后执行正常的maven安装 - 它应该在构建war文件之前运行gwt:compile。