Question

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)?

Was it helpful?

Solution

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,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top