tbroyer / gwt-maven-archetypes

Apache License 2.0
152 stars 39 forks source link

fix dependency for DevMode with RequestFactory #16

Closed a14n closed 12 years ago

a14n commented 12 years ago

When running DevMode with RequestFactory, there is the following error :

java.lang.NoClassDefFoundError: org/json/JSONException
jgonian commented 12 years ago

+1, I had the same issue when I tested modular-requestfactory and guice-rf-activities.

tbroyer commented 12 years ago

I'd rather add org.json:json as a dependency than com.google.web.bindery:requestfactory-client (because requestfactory-client is already included in gwt-user, all we need is the transitive dependency on org.json). Put differently, gwt-user's POM should have declared org.json as an optional dependency; and if it had been the case, we would have had to explicitly declare org.json as a dependency as we need it.

What do you think?

a14n commented 12 years ago

Using org.json:json was what I did initially. But, using com.google.web.bindery:requestfactory-client dependency avoids asking to user the version of org.json:json to use (as gwt version is configurable on projet generation, org.json:json should be too). I agree it would be easyer if gwt-user's POM had declared org.json:json as an optional dependency.

tbroyer commented 12 years ago

AFAICT, if gwt-user declared org.json as an optional dependency, you'd have to include the version of org.json when adding it to your POM. Optional dependencies are hardly more than documentation.

Given that we use the exact same version for requestfactory-client and gwt-user and we know they're released from the same sources, we know their classes won't conflict, whichever one comes first in the classpath.

I'm still hesitant to add a dependency on requestfactory-client though. I'll report the issue to the GWT Team (the GWT SDK doesn't contain org.json, making it impossible to use RequestFactory out-of-the-box) and see the outcome before fixing it (unless it takes a bit long, in which case we'll fix it here and track the issue to possibly update the workaround, and then wait for a GWT version that really fixes the packaging/dependencies)

a14n commented 12 years ago

You are right on optional dependency ; I thought version could be omitted, but it couldn't.

Otherwise, I agree with what you said.

An alternative solution could be to use an archetype numbering that follows GWT version number (like gwt-maven-plugin) e.g. net.ltgt.gwt.archetypes:modular-requestfactory:2.4. Thus for GWT 2.4, we could add directly org.json:json:20090211 to POM. When GWT 2.5 will be out, that dependency could be removed if it is transitively pulled. That said, I'm not a big fan of that solution because of code duplications it involves.

What do you think?

tbroyer commented 12 years ago

Archetypes are made of Velocity templates so we can probably make the json dependency conditional, depending on the version of GWT being used.

tbroyer commented 12 years ago

https://groups.google.com/d/topic/google-web-toolkit-contributors/yF5glS2nXIQ/discussion

tbroyer commented 12 years ago

Would you mind updating the pull request with a FIXME comment near the additional dependencies:

<!-- FIXME: used to pull in RF dependencies; should no longer be necessary with GWT 2.5 onwards -->

Also, given that 2.5 will bring so many fixes to RF, I'm inclined to only support 2.5 out-of-the-box when it's released, and add a note in the README about the missing dependency in GWT 2.4.

a14n commented 12 years ago

Done

buildhive commented 12 years ago

Thomas Broyer » gwt-maven-archetypes #3 SUCCESS This pull request looks good (what's this?)