在Maven构建阶段复制文件 [英] Copy a file during maven build phase
本文介绍了在Maven构建阶段复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的情况是:
- 我有一个Maven项目,我的Java类在/app/src/main/java 中,我的资源在/app/src/main/resources 中,我的Webapp文件位于/app/src/main/webapp
- 我在/common/script.js 中有一个javascript文件
- I have a Maven project, I have my java classes in /app/src/main/java, my resources in /app/src/main/resources and my webapp files in /app/src/main/webapp
- I have a javascript file in /common/script.js
现在,我要在maven的构建阶段将javascript文件包含(复制)到war文件中.确切地说,我希望将 script.js 放到战争档案的/js/目录中,就像放置在/app/src/中一样main/webapp/js .开始构建之前.
Now what I want is to include (copy) the javascript file to the war file during the build phase of maven. To be precise, I want the script.js to land in /js/ directory of the war archive, just as it was placed in /app/src/main/webapp/js before starting the build.
我需要在许多Web应用程序之间共享一种版本的资源文件.
I need this to share one version of resource files among many web-apps.
亲切的问候, 问
推荐答案
You could do something like this, as documented here.
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>../common</directory>
<targetPath>/js</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
这篇关于在Maven构建阶段复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文