0

我有一个 GWT 项目,我想使用其他一些内部 GWT 库作为依赖项。

我们不想在最终构建中包含源代码。大多数开源 GWT 库都在 JAR 中包含源代码,但我们希望将源代码分开,使用它们进行编译,然后将它们丢弃。

有没有办法用 Maven 做到这一点?

4

3 回答 3

3

Brad's answer will fix the problem in a very narrow scenario. Setting the scope to provided totally avoids the jar from being pushed into War's lib. This is not what you would need in use case of the "lib" on to server side code. This usually happens 1) Constants. 2) DTO's/Beans. 3) RPC service interfaces 4) Request Factory proxy declarations

You have to have a mix of approaches.

1) Brad's approach when the "lib" in purely client and has no chance of being used in server clode.

2) Modularize code to have Constants/DTO's/Proxy/RF related interfaces and any such code in a project that generates two artifact jars.

   A) One with classes only - to be used to push stuff in to web-inf/lib i.e scope compile/runtime.

   B) Another with sources/classess - to be used with gwt compilation i.e scope provided.

Generating two jars might seem redundant. This is the only sane option i have tried. Keen on check whether there is any other option that will be suggested.

于 2012-12-18T03:46:49.227 回答
3

将范围设置为provided

<dependency>
  <groupId>com.you.gwt</groupId>
  <artifactId>gwt-ui</artifactId>
  <version>1.0.0</version>
  <scope>provided</scope>
</dependency>
于 2012-12-17T22:59:51.727 回答
0

GWT 中有两种库(打包在 jar 文件中):

  • 像“gwt-servlet.jar”这样的服务器端库在 jar 文件中不包含源代码,您可以在 pom 中添加这样的 maven 依赖项:
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-servlet</artifactId>
  <version>${gwtVersion}</version>
  <scope>runtime</scope>
</dependency>
  • 像“gwt-user.jar”这样的客户端库在jar文件中包含源代码,这种库不需要打包在你的war文件中,你可以在你的pom中添加这样的maven依赖:
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-user</artifactId>
  <version>${gwtVersion}</version>
  <scope>provided</scope>
</dependency>

玩得开心。

于 2012-12-18T10:28:24.783 回答