1

I have some Domain classes such as Student, User etc which are used on server and client (gwt) sides.

Can I exclude this domain classes to separate maven-module, so I can add this module as dependency to other maven-modules (i.e. add this module as dependency to maven-module which contains gwt related stuff, so this domain classes will be generated to JavaScript, and add this module as dependency to "normal" (not gwt) Java maven-modules, so this domain classes won’t be generated to JavaScript)?

WelcomeTo
  • 19,843
  • 53
  • 170
  • 286

1 Answers1

3

Yes sure, why not? Consider the following structure:

root-pom--->common
        |
        +-->frontend
        |
        +-->backend

Have frontend and backend depend on common and put your domain objects in common.

You should remember to have *.gwt.xml file exposing your VO's in the common project and include that in your frontend's gwt.xml descriptor, eg.

<module>
    <source path="your.vo.package" />
</module>

And - as Thomas Broyer points out - remember to make the source code available to frontend, this does not necessarily have to be in a separate jar, though. You can package the source with the .class files. The gwt-maven-plugin's gwt:resources goal is useful for this purpose:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    </plugins>
</build>

Cheers,

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
  • Note you have to generate the -sources.jar for `common` and have `frontend` depend on both `common` "normal" and `common` -sources.jar. For an example of that, see https://github.com/tbroyer/gwt-maven-archetypes – Thomas Broyer Nov 07 '12 at 11:01
  • thanks for reply. But I have a problem with this solution. I created new question. Please, view it http://stackoverflow.com/questions/13381493/gwt-maven-gwt-module-module-name-not-found-in-project-sources-or-resources – WelcomeTo Nov 14 '12 at 15:13