我需要将Maven设置为:
a)编译GWT模块
b)复制jar中的* .java文件(因此可以在另一个GWT模块中导入)
c)复制jar中编译步骤的结果(因此它可以在服务器上使用)
有谁知道如何做到这一点?
基本的想法是,我想将我的GWT项目与我的Spring MVC项目分离,并删除Spring应用程序可能具有的所有依赖项,以及GWT jar和amp;插件.
这样我就可以将GWT模块用作纯javascript库,并直接从Jar文件中加载org.springframework.js.resource.ResourceServlet,同时仍保持在其他GWT项目中重用模块的灵活性.
任何帮助,将不胜感激.
最佳答案 我附上了我提出的解决方案,以便其他人可以使用它:
<!-- Set the output directory to something gwt:run can use in hosted mode -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<finalName>gwt-build-name</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
</configuration>
</plugin>
<!-- Attach the resources plugin to the prepare-package phase to include the host page & generated javascript files -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>package-generated-javascript</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- shove everything the compiler produced into the JAR/META-INF/ folder so that Spring resourceServlet can find it -->
<outputDirectory>${project.build.outputDirectory}/META-INF</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}</directory>
<includes>
<include>org.yournamehere.Main/**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>include-host-page</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
上面做的是将输出目录更改为target / finalName,以便所有内容都在同一目录下,并将资源插件附加到compile,prepare-package阶段,以将GWT编译器输出复制到构建目录.一旦所有东西都存在,它将默认结束在最后一个jar中.
这样,构建目录包含托管模式需要运行的所有内容以及Spring资源servlet需要为GWT模块提供服务而不与GWT直接相关的所有内容.