无论您是在客户端还是在服务器端,我如何为 GWT 提供 2 种不同的代码实现

How can I have 2 different code implementations for GWT whether you're on the client or on the server side

我有一个日志记录库(除其他外),它使用网络等功能非常强大。我们所有的代码都在使用它。我们的一些代码很简单,应该在 GWT 的客户端使用,但是由于它调用了这个库,所以编译失败。

我想我可以编写一个具有相同调用/API但指向不同实现的特定库。

我天真地看着:

<replace-with class="someClass">
    <when-type-is class="javax.validation.ValidatorFactory" />
</replace-with>

但我想先得到一些反馈。

"super source" 好吧!

参见 “用另一个覆盖一个包实现” http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html