GWT compile fails with default Maven directory structure

195 views
Skip to first unread message

Phineas Gage

unread,
Nov 20, 2014, 12:05:27 PM11/20/14
to google-we...@googlegroups.com
I'm in the process of Maven-izing my GWT 2.6.1 project (an intermediate step to start using GWT 2.7.0), and as a first step want to switch to maven style directory structure (as suggested by the Maven GWT Plugin documentation), so I make two simple moves:

[project]/src => [project]/src/main/java

[project]/test => [project]/src/test/java

But what happens when I do this is that the regular "GWT Compile" from the Google Plugin for Eclipse fails with the -strict option, because it tries to compile my test classes as GWT source code, and of course can't find the classes they reference, for example (source files names obfuscated with extra ...'s):

      [ERROR] Errors in 'file:/.../src/test/java/.../...Test.java'
         [ERROR] Line 20: No source code is available for type org.junit.Assert; did you forget to inherit a required module?
      (... repeated with many other files)

I'm confused because this doesn't happen with my old directory structure, and I don't know why the GWT compiler would go back up into my test directory to compile classes there. Strangely, it also doesn't happen with this structure, which I accidentally moved to once:

[project]/src => [project]/src/java/main

[project]/test => [project]/src/java/test

It almost seems like the GWT compiler is doing something special with the default Maven directory structure. And any of the solutions I can think of are not very clean:

- Not use the Google Plugin for Eclipse, but only use the Maven GWT Plugin, but then I lose some features from the Google Plugin for Eclipse that I want
- Not compile with -strict, but then I don't catch other warnings as easily
- Use an exclude in my *.gwt.xml source paths to exclude **/*Test.java, but then I might still catch some unintended utility classes in my test package
- Not use a parallel package structure for my tests, but then it's not possible to test package protected classes and methods
- Not make [project]/src/test/java a source directory in Eclipse, but I don't know what the side effects of that are

How are people handling this, or am I missing something?

Colin Alworth

unread,
Nov 20, 2014, 2:47:35 PM11/20/14
to google-we...@googlegroups.com
It sounds like you have non-gwt-capable classes in packages meant for GWT - is that deliberate? For example, test classes to make sure the various server components in your project work, but they are in your .client or .shared package?

If they are not, then GWT will totally ignore them, as no .gwt.xml as indicated that those packages are able to be compiled at all.

Thomas Broyer

unread,
Nov 21, 2014, 2:18:19 AM11/21/14
to google-we...@googlegroups.com
Sounds like a bug or misconfiguration of the GPE. Is the project a "Maven project" in Eclipse? There might be some hard-coded paths in the GPE (because of limitations of Eclipse) that are only triggered in one or the other "mode" (Maven vs. "simple" Eclipse project). E.g. "/test" being excluded from the GWT Compiler and DevMode classpath in "simple" projects, and the test sources (defaulting to "src/test/java" and "src/test/resources"), as declared in your Maven POM, in Maven projects.
Also, this being a GPE issue, you might have better luck in the dedicated Google Group <https://groups.google.com/d/forum/google-plugin-eclipse> or on StackOverflow.

Phineas Gage

unread,
Nov 21, 2014, 2:36:07 AM11/21/14
to google-we...@googlegroups.com
On Thursday, November 20, 2014 8:47:35 PM UTC+1, Colin Alworth wrote:
It sounds like you have non-gwt-capable classes in packages meant for GWT - is that deliberate? For example, test classes to make sure the various server components in your project work, but they are in your .client or .shared package?

If they are not, then GWT will totally ignore them, as no .gwt.xml as indicated that those packages are able to be compiled at all.

 Yes, I have my test classes in the same packages as the classes they test, but the test classes are in a different source directory. It's always been that way, and I like it because tests are easy to find and they have access to package protected classes and methods.

Phineas Gage

unread,
Nov 21, 2014, 2:53:58 AM11/21/14
to google-we...@googlegroups.com
On Friday, November 21, 2014 8:18:19 AM UTC+1, Thomas Broyer wrote:
Sounds like a bug or misconfiguration of the GPE. Is the project a "Maven project" in Eclipse? There might be some hard-coded paths in the GPE (because of limitations of Eclipse) that are only triggered in one or the other "mode" (Maven vs. "simple" Eclipse project). E.g. "/test" being excluded from the GWT Compiler and DevMode classpath in "simple" projects, and the test sources (defaulting to "src/test/java" and "src/test/resources"), as declared in your Maven POM, in Maven projects.
Also, this being a GPE issue, you might have better luck in the dedicated Google Group <https://groups.google.com/d/forum/google-plugin-eclipse> or on StackOverflow.
 
It was created as a Google -> Web Application Project. I think you have it here, it seems that when the source folder base name is 'test', it's excluded from the GWT Compiler, but that's not the case for the default Maven style directory structure.

Just as a general question, do you keep the GPE installed when you use Maven? Where I'm heading is that maybe I only need GPE for the UiBinder auto-completion and editor features. Compiling, DevMode and testing can all be handled with Maven. GPE doesn't seem to keep up with GWT releases anyway.

Thanks for the help...

Thomas Broyer

unread,
Nov 21, 2014, 5:33:48 AM11/21/14
to google-we...@googlegroups.com
When you use Maven and Eclipse, you "import a Maven project" (ou create one from within Eclipse), and the GPE detects the use of the gwt-maven-plugin and auto-configures itself, using the GWT dependencies from your Maven project rather than a "GWT SDK" (so you can really use any GWT version that's available in the Central Repository, whether it's available as an "Eclipse plugin" or not is irrelevant).
I like launching DevMode using the GPE even when using Maven, because it's simpler and more integrated to Eclipse.

Phineas Gage

unread,
Nov 21, 2014, 12:54:29 PM11/21/14
to google-we...@googlegroups.com
On Friday, November 21, 2014 11:33:48 AM UTC+1, Thomas Broyer wrote:
When you use Maven and Eclipse, you "import a Maven project" (ou create one from within Eclipse), and the GPE detects the use of the gwt-maven-plugin and auto-configures itself, using the GWT dependencies from your Maven project rather than a "GWT SDK" (so you can really use any GWT version that's available in the Central Repository, whether it's available as an "Eclipse plugin" or not is irrelevant).
I like launching DevMode using the GPE even when using Maven, because it's simpler and more integrated to Eclipse.

Thanks, that got me to where gwt:compile is working from the command line or GPE (save the test code path issue I posted about originally, which I'll go to GPE about). I'll work on running stuff later.

Here are a few of the main hurdles I ran into:

- I had to manually change the build order in Java Build Path -> Order and Export to put my Maven Dependencies below everything else, which seems a little strange.

- Where to put resources. I started with everything in src/main/resources to be Maven-like, but realized for GPE and compiling from maven to work, all stuff that needs to be processed by the GWT compiler needs to go in src/main/java. This was an entertaining read.

- The MobileWebApp sample pom.xml references the maven-gae-plugin, but it seems like that's been superseded by appengine-maven-plugin.

- You still want separate GWT and app engine SDKs installed in Eclipse, even though you've also got them in your local maven repository.

- In the end, I was better off starting a new Maven project from scratch then trying to migrate my existing one, especially with my connection to a local Subversion repository. Subclipse didn't handle the moves very well and my working copy got corrupted.

Thomas Broyer

unread,
Nov 21, 2014, 2:03:42 PM11/21/14
to google-we...@googlegroups.com


On Friday, November 21, 2014 6:54:29 PM UTC+1, Phineas Gage wrote:
- You still want separate GWT and app engine SDKs installed in Eclipse, even though you've also got them in your local maven repository.

I can't tell for App Engine, but why would you want a GWT SDK?

Phineas Gage

unread,
Nov 22, 2014, 5:43:02 AM11/22/14
to google-we...@googlegroups.com
On Friday, November 21, 2014 8:03:42 PM UTC+1, Thomas Broyer wrote:
I can't tell for App Engine, but why would you want a GWT SDK?

You're right, I was able to remove the GWT SDK plugin from Eclipse, and it still works using the one from my maven repository.

That's not the case for GAE. If I remove it, I get the same error that I fixed yesterday by changing the build order to move my Maven Dependencies below everything else, as I mentioned earlier:

GAE SDK /Users/.../.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.15/appengine-api-1.0-sdk-1.9.15.jar failed validation
SDK location '/Users/.../.m2/repository/com/google/appengine/appengine-api-1.0-sdk/1.9.15/appengine-api-1.0-sdk-1.9.15.jar' is not a directory

To get it working again, I need to:
- Reinstall the GAE SDK from GPE
- Change the project to use this SDK temporarily in Project Properties > Google > App Engine. The change won't persist, but it will add the GAE jars to your build classpath.
- Again, move the Maven Dependencies below everything else in Project Properties > Java Build Path > Order and Export

This is a GAE things, but I think more GWT users might run into this. So I can ask the GAE guys about it, but it looks like it's been an issue since at least 2011, so maybe there's a reason why things are the way they are.

Thanks!
Reply all
Reply to author
Forward
0 new messages