我有一个 GWT 项目,我想使用其他一些内部 GWT 库作为依赖项。
我们不想在最终构建中包含源代码。大多数开源 GWT 库都在 JAR 中包含源代码,但我们希望将源代码分开,使用它们进行编译,然后将它们丢弃。
有没有办法用 Maven 做到这一点?
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.
将范围设置为provided
<dependency>
<groupId>com.you.gwt</groupId>
<artifactId>gwt-ui</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
GWT 中有两种库(打包在 jar 文件中):
<dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwtVersion}</version> <scope>runtime</scope> </dependency>
<dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwtVersion}</version> <scope>provided</scope> </dependency>
玩得开心。