GWT-Maven-plugin: Link GWT 编译文件到指定目录
GWT-Maven-plugin: Link GWT compiled files into a defined directory
我有一个 GWT 项目,我想移动到 Maven。
1) 在使用 Maven 之前,为了编译 GWT,我曾经使用以下代码执行一个 .bat 文件:
/thisFolder是我期望的编译文件目录
call env
cd "\thisFolder"
%JAVA_HOME_GWT%/java -Xmx1024m -Dgwt.nowarn.legacy.tools -cp %GWT_HOME%/gwt-user.jar;%GWT_HOME%/gwt-dev.jar;%GWT_HOME%/validation-api-1.0.0.GA.jar;%GWT_HOME%/validation-api-1.0.0.GA-sources.jar;%GWT_EXT%/gwtext.jar" com.google.gwt.dev.Compiler -war "%URL_PROJECT_BASE%/%URL_COMPILE_PROJECT_CLIENT%" %* -style OBF com.myproject.client.gwt.ProjectClient
pause
由于第二行改变了目录,编译后的文件被创建到这个directory: ...\thisFolder\com.myproject.client.gwt.ProjectClient
2) 现在我想做同样的事情,但是使用 gwt-maven-plugin,所以根据我发现的一些帖子,我对插件配置做了一些更改为了将 *.cache.html
文件输出目录设置为 ...\thisFolder
These are some of the labels I tried to use:
- <hostedWebapp>${project.build.directory}/thisFolder</hostedWebapp>
- <extraJvmArgs>-Djava.io.tmpdir=${project.build.directory}/thisFolder</extraJvmArgs>
- <outputDirectory>${project.build.directory}/thisFolder</outputDirectory>
- <war>${project.build.directory}/thisFolder</war>
- <deploy>${project.build.directory}/thisFolder</deploy>
但是在编译 GWT 之后,它显示了一条消息,其中 directory 放置了 *.cache.html (or *.cache.js)
,这不是我期望的路径 (最后一行控制台输出).
[INFO] Compiling permutation 10...
[INFO] Compiling
[INFO] Compiling permutation 11...
[INFO] Compiling
[INFO] Compiling permutation 12...
[INFO] Compiling
[INFO] Compiling permutation 13...
[INFO] Compiling permutation 14...
[INFO] Compile of permutations succeeded
[INFO] Compilation succeeded -- 54,216s
[INFO] Linking into D:\Java\MyProject\mainProject\target\mainProject\com.myproject.client.gwt.ProjectClient
设置 *.cache.html
文件输出目录的正确方法是什么?
这是 pom.xml
gwt 插件配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<extraJvmArgs>-Xmx1024m -Xss1024k -Dgwt.nowarn.legacy.tools</extraJvmArgs>
<draftCompile>true</draftCompile>
<debugSuspend>false</debugSuspend>
<logLevel>INFO</logLevel>
<style>OBF</style>
<noServer>true</noServer>
<runTarget>http://localhost:${glassfish.port}/${project.build.finalName}/${project.build.finalName}.html</runTarget>
<buildOutputDirectory>${project.build.outputDirectory}</buildOutputDirectory>
<deploy>${project.build.outputDirectory}/deploy</deploy>
<copyWebapp>true</copyWebapp>
</configuration>
</plugin>
来自 https://gwt-maven-plugin.github.io/gwt-maven-plugin/compile-mojo.html、
的文档
webappDirectory File - Location on filesystem where GWT will write output files (-out option to GWTCompiler).
Default value is: ${project.build.directory}/${project.build.finalName}.
User property is: gwt.war.
您似乎使用的是 -war
,我认为这是 -out
的更旧版本,但在您的配置中添加 <webappDirectory>${project.build.directory}/thisFolder</webappDirectory>
应该可以达到预期的效果。
我有一个 GWT 项目,我想移动到 Maven。
1) 在使用 Maven 之前,为了编译 GWT,我曾经使用以下代码执行一个 .bat 文件:
/thisFolder是我期望的编译文件目录
call env
cd "\thisFolder"
%JAVA_HOME_GWT%/java -Xmx1024m -Dgwt.nowarn.legacy.tools -cp %GWT_HOME%/gwt-user.jar;%GWT_HOME%/gwt-dev.jar;%GWT_HOME%/validation-api-1.0.0.GA.jar;%GWT_HOME%/validation-api-1.0.0.GA-sources.jar;%GWT_EXT%/gwtext.jar" com.google.gwt.dev.Compiler -war "%URL_PROJECT_BASE%/%URL_COMPILE_PROJECT_CLIENT%" %* -style OBF com.myproject.client.gwt.ProjectClient
pause
由于第二行改变了目录,编译后的文件被创建到这个directory: ...\thisFolder\com.myproject.client.gwt.ProjectClient
2) 现在我想做同样的事情,但是使用 gwt-maven-plugin,所以根据我发现的一些帖子,我对插件配置做了一些更改为了将 *.cache.html
文件输出目录设置为 ...\thisFolder
These are some of the labels I tried to use:
- <hostedWebapp>${project.build.directory}/thisFolder</hostedWebapp>
- <extraJvmArgs>-Djava.io.tmpdir=${project.build.directory}/thisFolder</extraJvmArgs>
- <outputDirectory>${project.build.directory}/thisFolder</outputDirectory>
- <war>${project.build.directory}/thisFolder</war>
- <deploy>${project.build.directory}/thisFolder</deploy>
但是在编译 GWT 之后,它显示了一条消息,其中 directory 放置了 *.cache.html (or *.cache.js)
,这不是我期望的路径 (最后一行控制台输出).
[INFO] Compiling permutation 10...
[INFO] Compiling
[INFO] Compiling permutation 11...
[INFO] Compiling
[INFO] Compiling permutation 12...
[INFO] Compiling
[INFO] Compiling permutation 13...
[INFO] Compiling permutation 14...
[INFO] Compile of permutations succeeded
[INFO] Compilation succeeded -- 54,216s
[INFO] Linking into D:\Java\MyProject\mainProject\target\mainProject\com.myproject.client.gwt.ProjectClient
设置 *.cache.html
文件输出目录的正确方法是什么?
这是 pom.xml
gwt 插件配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<extraJvmArgs>-Xmx1024m -Xss1024k -Dgwt.nowarn.legacy.tools</extraJvmArgs>
<draftCompile>true</draftCompile>
<debugSuspend>false</debugSuspend>
<logLevel>INFO</logLevel>
<style>OBF</style>
<noServer>true</noServer>
<runTarget>http://localhost:${glassfish.port}/${project.build.finalName}/${project.build.finalName}.html</runTarget>
<buildOutputDirectory>${project.build.outputDirectory}</buildOutputDirectory>
<deploy>${project.build.outputDirectory}/deploy</deploy>
<copyWebapp>true</copyWebapp>
</configuration>
</plugin>
来自 https://gwt-maven-plugin.github.io/gwt-maven-plugin/compile-mojo.html、
的文档webappDirectory File - Location on filesystem where GWT will write output files (-out option to GWTCompiler). Default value is: ${project.build.directory}/${project.build.finalName}. User property is: gwt.war.
您似乎使用的是 -war
,我认为这是 -out
的更旧版本,但在您的配置中添加 <webappDirectory>${project.build.directory}/thisFolder</webappDirectory>
应该可以达到预期的效果。