1

I have a GWT project with the following dependencies

    <dependency>
        <groupId>com.google.gwt.inject</groupId>
        <artifactId>gin</artifactId>
        <version>2.1.2</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-distribution</artifactId>
        <version>4.0.2</version>
    </dependency>
  • gin 2.1.2 depends on guice 3.0 while owlapi 4.0.2 depends on guice 4.0-beta.

  • gin is used on the client side while owlapi is used on the server side.

  • Compilation fails when I force guice 4.0-beta to be used. Caused by java.lang.ClassNotFoundException: com.google.inject.internal.util.$Maps

  • Compilation succeeds when I force guice 3.0 to be used, but fails at run-time caused by java.lang.ClassNotFoundException: com.google.inject.internal.guava.collect.$ImmutableList

  • Downgrading the version of owlapi is not an option.

What options do I have to make this work? Can I use dependency scopes somehow while still retaining a functioning GWT DevMode?

hansi
  • 2,278
  • 6
  • 34
  • 42

3 Answers3

4

Split your project in distinct modules. Given Maven's limited (by design) dependency scoping options, this is really the way to go.

Use one module for client-side code, using only client dependencies (GIN with Guice 3), and one module for server-side code, using only server dependencies (OWLAPI with Guice 4); and have your client module compile your code to JS and package them as a WAR, that you can use as an "overlay" in the server module (or possibly use a third module that depends on both client and server if you prefer). If you have shared code, use a third/fourth shared module that both client and server modules depend on; the shared module would call maven-source-plugin's jar-no-fork goal so the client module could depend on the shared sources.

You can find archetypes following this approach at https://github.com/tbroyer/gwt-maven-archetypes. They use my Maven Plugin for GWT, but earlier versions (you'd have to clone and mvn install the project then from the appropriate commit) relied on Mojo's Maven Plugin for GWT (my plugin is designed with multi-module projects in mind, and removed a lot of hacks that were needed previously when using Mojo's plugin).

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
1

This is a complex scenario for my maven experience with scopes for dependencies.

Given that the error you get mentions guava, you may get lucky forcing the latest guava to be used - owlapi should work with 17 or 18.

Another option might be to try and recompile gin with guice 4 (and maybe contribute the changes upstream). I've got no idea how hard this can be though. You'd also have to ensure your snapshots are released with your app and accessible to others in your team who might need them.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
0

For what it's worth. I spent a few minutes and "ported" it over to guice 4.0. Luckily it was pretty easy. I mavenized it otherwise there were virtually no changes to the code base.

https://github.com/chinshaw/google-gin

Chris Hinshaw
  • 6,967
  • 2
  • 39
  • 65