我有一个项目,其中包括 GWT 客户端和 Tomcat 服务器端。所有内容都使用 Maven 进行设置。然而,我想把客户端的 HTML 和 CSS 文件(位于资源文件夹中)复制到服务器项目的 webapp 目录中。我一直在研究 maven-dependency-plugin,但无法使其正常工作。我似乎找不到指定源路径和目标路径的方法。如果有人能指点我正确的方向,我将不胜感激。
谢谢。
谢谢。
<!-- Use the following to extract all files from the dependent jar or war (see type) : -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>target/exploded-artifact-id-jar</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- then copy the neccessary files to the webapp directory -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-webapp-resources</id>
<phase>generate-resources</phase>
<configuration>
<tasks>
<copy todir="target/webapp" filtering="false">
<fileset dir="target/exploded-artifact-id-jar/path-to-files"/>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<module_name>.gwt.xml
模块配置文件相同的级别上创建一个public
文件夹。也就是说:+src/main/resources
|-<module_name>.gwt.xml
|-+public
|-<static resources>
这样,在gwt编译后,所有资源都将进入 src/main/webapp/<module_name>/
。这个文件夹是maven(通过插件)或您(手动)用来创建最终web应用程序的文件夹。
希望这可以帮到您。
祝好
pom.xml
文件中,你可以指定需要使用的资源。例如:<build>
<!-- Resources to be bundeled with the final WAR -->
<resources>
<resource>
<directory>config</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html