Maven中如何配置WAR依赖WAR和JAR的多模块项目结构
要使用的Warpath插件包括以下插件配置元素在你的pom.xml
[...]<build> <plugins> <plugin> <groupId>org.appfuse</groupId> <artifactId>maven-warpath-plugin</artifactId> <version>1.0-SNAPSHOT</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>add-classes</goal> </goals> </execution> </executions> </plugin> </plugins></build>[...]
[...]<dependencies> <dependency> <groupId>org.appfuse</groupId> <artifactId>appfuse-web</artifactId> <version>2.0</version> <type>war</type> </dependency> <dependency> <groupId>org.appfuse</groupId> <artifactId>appfuse-web</artifactId> <version>2.0</version> <type>warpath</type> </dependency></dependencies>[...]
[...]<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <dependentWarExcludes>WEB-INF/lib/*</dependentWarExcludes> </configuration> </plugin> </plugins></build>[...]
<dependency> <groupId>com.isoftstone.gads</groupId> <artifactId>common-web</artifactId> <version>0.0.1-SNAPSHOT</version> <type>war</type></dependency><dependency> <groupId>com.isoftstone.gads</groupId> <artifactId>common-web</artifactId> <version>0.0.1-SNAPSHOT</version> <type>warpath</type></dependency> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1-beta-1</version> <configuration> <!- 必须指定,否则默认会变成在target/war/work 导致被打包进war文件,指定后为target/work -> <workDirectory>${project.build.directory}/work</workDirectory> <webappDirectory>WebContent</webappDirectory> <useCache>false</useCache> <archive> <addMavenDescriptor>true</addMavenDescriptor> </archive> <overlays> <overlay> <groupId>com.isoftstone.gads</groupId> <artifactId>ebiz-common-web</artifactId> </overlay> <overlay> <!-- empty groupId/artifactId is detected as the current build --> <!-- 代表当前WAR项目,默认情况下当前WAR项目是先被拷贝的,如果要控制其顺序,则使用空的overlay --> <!-- any other overlay will be applied after the current build since they have not been configured in the overlays element --> </overlay> </overlays> <dependentWarExcludes>*/web.xml,WEB-INF/lib/*,/sql-map-config.xml,/jdbc.properties,/META-INF/*</dependentWarExcludes> </configuration> </plugin><plugin> <groupId>org.appfuse.plugins</groupId> <artifactId>maven-warpath-plugin</artifactId> <version>2.1.0-M1</version> <extensions>true</extensions> <executions> <execution> <goals> <goal>add-classes</goal> </goals> </execution> </executions> <configuration><!-- below WEB-INF/classes --> <warpathExcludes>**/logback-test.xml</warpathExcludes> </configuration></plugin>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-websources-plugin</artifactId> <version>0.0.1-SNAPSHOT</version> <executions> <execution> <goals> <goal>webSources</goal> </goals> </execution> </executions></plugin>