mavengwtguicegwt-ginowl-api

GWT (Maven) project: Dependency conflict


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>

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


Solution

  • 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).