Reputation: 1342
I am building a GWT project with Maven. I have added the gwt-maven-plugin for GWT compilation as shown below :
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<configuration>
<module>com.karthik.ui.MainWidgets</module>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I have included compile goal under executions tag expecting to execute GWT compilation during compile phase. But GWT compilation is getting executed only during package phase or when I run mvn package command.
Also I am getting a warning as shown below even though provided scope is set for gwt-dev dependency.
[WARNING] Don't declare gwt-dev as a project dependency. This may introduce complex dependency conflict
1) Why GWT compilation is not executed during compile phase?
2) What scope should I set for GWT(gwt-user, gwt-dev) dependencies to overcome the warning?
Upvotes: 0
Views: 1180
Reputation: 18331
[WARNING] Don't declare gwt-dev as a project dependency. This may introduce complex dependency conflict
This is advice, and not a requirement. There are good reasons for adding gwt-dev though:
If you do these things, be sure to mark gwt-dev as <scope>provided</scope>
. The gwt-user dependency should also be marked as provided, generally speaking.
If you do not do these things, you should not need to include gwt-dev as a project dependency, though it might be helpful as a dependency to your plugin if you like to mix gwt-maven-plugin and gwt versions.
Why not include gwt-dev? Aside from the cases above, there are no times when you might need to reference classes in that jar - everything you need is in gwt-user (or gwt-servlet at runtime on the server). The gwt-maven-plugin will automatically add gwt-dev to your classpath so that the compiler can be run correctly.
As for the "Why GWT compilation is not executed during compile phase?":
You have specifically configured the gwt-maven-plugin to run gwt:compile
, but you forgot to tell it when to run it, so it is running it at the default time - during prepare-package
. Instead, you need to specify <phase>compile</phase>
in the <execution>
tags.
However, the compile
phase might be too early - if it happens to run before your .java files are compiled to .class bytecode, the compiler will fail. Consider another time, like process-classes
or later, from the lifecycle document https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html:
process-classes
post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.
Upvotes: 1