Oscar Londoño
Oscar Londoño

Reputation: 75

GWT-Maven-plugin: Link GWT compiled files into a defined directory

I hava a GWT project that I want to move to Maven.

1) Before using Maven, in order to compile GWT I used to execute a .bat file with this code:

/thisFolder is the compiled files directory I expect

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

Since the second line changes the directory, the compiled files are created into this directory: ...\thisFolder\com.myproject.client.gwt.ProjectClient

2) Now I want to do the same, but using gwt-maven-plugin, so according to some posts I have found, I did some changes on plugin configurations in order to set *.cache.htmlfiles output directory to ...\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>

But after compiling GWT, it shows a message with the directory where *.cache.html (or *.cache.js) are placed, and it is not the path I excpected to be (last line in this console output).

[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

What is the proper way to set that *.cache.html files output directory?


This is the pom.xml gwt plugin configuration:

<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>

Upvotes: 3

Views: 844

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

From the documentation at 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.

You appear to be using -war instead, which I believe is the much older version of -out, but adding <webappDirectory>${project.build.directory}/thisFolder</webappDirectory> to your configuration should achieve the desired result.

Upvotes: 1

Related Questions