我需要将Maven设置为:
a)编译GWT模块
b)复制jar中的* .java文件(因此可以在另一个GWT模块中导入)
c)复制jar中编译步骤的结果(因此它可以在服务器上使用)
有人知道如何做到这一点吗?
基本思想是我想将我的GWT项目与我的Spring MVC项目分离,并删除Spring应用程序可能拥有的任何依赖关系到GWT jar&插件。
这样我可以将GWT模块用作纯javascript库,并直接从Jar文件加载org.springframework.js.resource.ResourceServlet,同时仍保持在其他GWT项目中重用模块的灵活性。
任何帮助都将不胜感激。
答案 0 :(得分:2)
我正在附上我提出的解决方案,以便其他人可以使用它:
<!-- 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编译器输出复制到构建目录。一旦一切都在那里,默认情况下它将最终进入最后一个罐子里。
这样构建目录包含托管模式需要运行的所有内容以及Spring资源servlet需要为GWT模块提供服务的所有内容,而不会直接依赖于GWT。