brainwash
brainwash

Reputation: 689

Override org.joda.time.LocalDate with org.gwttime.time.LocalDate

I'm trying to develop a generic module that is independent of GWT until it is actually used in a GWT application. The problem is that GWT does not support joda and my module does not use GWT.

What I'm trying to achieve (this will not work):

<replace-with class="org.gwttime.time.LocalDate">
    <when-type-is class="org.joda.time.LocalDate" />
</replace-with> 

Last resort would be to add custom parsing and some smart rules at runtime, but I would like to avoid that and solve this problem at compile time.

Is there any way to easily specify the gwttime as emulation for the joda time?

Upvotes: 0

Views: 581

Answers (1)

brainwash
brainwash

Reputation: 689

I solved it using the <super-source> .gwt.xml directive.

I checked out the gwttime project, renamed all the package and imports declarations from org.gwttime.time to org.joda.time then added an Emulation.gwt.xml to the parent source folder where the gwttime files were located with the following content:

<module>
   <super-source/>
</module>

Then the package structure was identical to org.joda.time.

This way I can use the same imports on the client and on the server side and the replacement will happen at compile-time.

Upvotes: 1

Related Questions