Reputation: 1096
I need to compile a GWT application without obfuscating Javascript, but I never worked with GWT before.
After a bit of research, I found out about the -style
flag (http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideCompilerOptions) to inform GWT to avoid obfuscating Javascript.
We also have a pom.xml
file in our project. Let us assume it looks like that:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-codeserver</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<module>com.example.test.Test</module>
</configuration>
</plugin>
</plugins>
</build>
</project>
Is this the place where I am supposed to put the -style
flag? If so, where exactly in the XML tree should I put it?
Upvotes: 1
Views: 441
Reputation: 4899
You should put the flag in the gwt compile plugin configuration
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<configuration>
<style>${gwtcompiler.style}</style>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<module>com.example.test.Test</module>
</configuration>
</plugin>
</plugins>
</build>
And you define the variable earlier in your pom, just uncomment the line you want to use.
<properties>
<gwtcompiler.style>PRETTY</gwtcompiler.style>
<!-- <gwtcompiler.style>OBFUSCATED</gwtcompiler.style> -->
</properties>
or use profiles to set it from the command line.
Upvotes: 2