0

I'm trying to reduce the compilation time of a gwt project using a maven profile to set whether I want all the permutations or just some of them.

I followed the tutorial here: http://www.bonitasoft.org/blog/tutorial/speed-up-gwt-i18n-compilation-using-maven-profiles/

however it does not say how to create the two modules (production and development). Are these application.gwt.xml files, and if so, where to put them ? I keep getting compilation errors if I use two application.gwt.xml files in the same directory.

Please give me more detailed information to be able to achieve these 2 maven profiles.

falconbur
  • 315
  • 1
  • 4
  • 6

1 Answers1

0

The simple thing you can do, is to use maven replace plugin and to inject during compilation (for development profile) the user.agent property.

  1. Put in your *.gwt.xml file one comment:
<module ...>
  ...
  <!-- Speed up compilation just for Chrome and Safari on development machines by reducing permutations-->
  <!-- REPLACE -->
  ....
</module>
  1. In the maven pom.xml define a development profile, that can be activated manually through property (or by explicitly telling maven to do so)
<profiles>
    <profile>
        <id>dev-build</id>
        <activation>
            <property>
                <name>gwtUserAgent</name>
                <value>overwrite</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.google.code.maven-replacer-plugin</groupId>
                    <artifactId>maven-replacer-plugin</artifactId>
                    <version>1.3.5</version>
                    <executions>
                        <execution>
                            <id>devChromeGWTCompileReplace</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>replace</goal>
                            </goals>
                            <configuration>
                                <file>PATH_TO_YOUR_GWT_FILE.gwt.xml</file>
                                <replacements>
                                    <replacement>
                                        <token>&lt;!-- REPLACE --&gt;</token>
                                        <value>&lt;set-property name="user.agent" value="safari" /&gt;</value>
                                    </replacement>
                                </replacements>
                            </configuration>
                        </execution>
                        <execution>
                            <id>devChromeGWTCompileReplaceReverse</id>
                            <phase>install</phase>
                            <goals>
                                <goal>replace</goal>
                            </goals>
                            <configuration>
                                <file>PATH_TO_YOUR_GWT_FILE.gwt.xml</file>
                                <replacements>
                                    <replacement>
                                        <token>&lt;set-property name="user.agent" value="safari" /&gt;</token>
                                        <value>&lt;!-- REPLACE --&gt;</value>
                                    </replacement>
                                </replacements>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Note to replace PATH_TO_YOUR_GWT_FILE.gwt.xml with your GWT file.

What this will do when you execute

mvn install -DgwtUserAgent=overwrite

or

mvn install -P dev-build

on validation (first phase) - change the replacement token

<!-- REPLACE -->

to

<set-property  name="user.agent" value="safari" />

Then it will build the artifact with active user.agent property

At the end (on install phase) it will put back the initial token

<!-- REPLACE -->

so that your sources remain unchanged.

npenkov
  • 81
  • 3