[英]Maven - Copying resources from client project to webapp
我有一个由GWT客户端和Tomcat服务器端组成的项目。 一切都是使用maven设置的。 但是,我希望将客户端的HTML和CSS文件(位于resources文件夹中)复制到服务器项目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>
您应该创建一个public
处于同一级别的文件夹<module_name>.gwt.xml
模块的配置文件。 那是:
+src/main/resources
|-<module_name>.gwt.xml
|-+public
|-<static resources>
这样,在gwt编译之后,所有资源都将转到src/main/webapp/<module_name>/
。 该文件夹是maven(通过插件)或您(手动)将用于创建最终webapp的文件夹。
希望这可以帮助。
问候
看看Apache Maven上的maven-war-plugin页面:
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
在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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.