Maven:使用 exec 插件复制目录
我正在使用 Maven 3.0.3。我在使用 Maven exec 插件将一个目录的内容复制到另一个目录时遇到问题。遗憾的是,当我将此插件包含在我的 pom.xml 中时……
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<executable>cp</executable>
<arguments>
<argument>-r</argument>
<argument>web-app/*</argument>
<argument>src/main/webapp</argument>
</arguments>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
它不起作用。我收到以下错误...
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:exec (default-cli) on project jx: Result of /bin/sh -c cd /Users/davea/Documents/workspace/mycoUSA2/Technology/nna/myco2usa/jx && cp -r 'web-app/*' src/main/webapp execution is: '1'. -> [Help 1]
有谁知道如何修改我的插件配置以将一个目录的内容复制到另一个目录?谢谢,-戴夫
I'm using Maven 3.0.3. I'm having trouble using the Maven exec plugin to copy the contents of one directory to another. Sadly, when I include this plugin in my pom.xml …
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<executable>cp</executable>
<arguments>
<argument>-r</argument>
<argument>web-app/*</argument>
<argument>src/main/webapp</argument>
</arguments>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
It isn't working. I get the error below …
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:exec (default-cli) on project jx: Result of /bin/sh -c cd /Users/davea/Documents/workspace/mycoUSA2/Technology/nna/myco2usa/jx && cp -r 'web-app/*' src/main/webapp execution is: '1'. -> [Help 1]
Does anyone know how I can modify my plugin config to copy the contents of one directory to another? Thanks, - Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 bash,请尝试以下操作:
这会生成一个新的 bash 并为其提供命令 cp -r web-app/* src/main/webapp 来执行。
您还可以通过先将其输入到普通终端窗口来测试它是否适合您:
bash -c "cp -r web-app/* src/main/webapp"
请注意,
"
符号确实会产生影响,因为exec-maven-plugin
会自动插入它们,因此它们不包含在
标签中。If you are using bash, try the following:
This spawns a new bash and gives it the command
cp -r web-app/* src/main/webapp
to execute.You can also test if it works for you by inputting this into a normal Terminal window first:
bash -c "cp -r web-app/* src/main/webapp"
Note that the
"
signs do make a difference as theexec-maven-plugin
does insert them automatically, thus they are not included in the<argument>
-tag.请注意它运行的命令。从错误输出中:
特别注意它尝试复制的
'web-app/*'
文件。因为它引用了此参数,所以cp
命令正在 web-app 目录中查找名为*
的特定文件。由于您没有具有此名称的文件,因此该文件已退出并显示错误代码1
。maven-resources-plugin 有一个旨在执行此任务的目标。为什么不尝试一下呢?它还有一个额外的好处,那就是使您的构建平台独立。
Note the command it ran. From the error output:
Note in particular the
'web-app/*'
file it has tried to copy. Because it has quoted this argument thecp
command is looking for a specific file with the name*
in the web-app directory. Because you don't have a file with this name it has exited with the error code1
.The maven-resources-plugin has a goal designed to perform this task. Why not give it a try? It would have the added benefit of making your build platform independent.
mvn -X 可能更具启发性
许多人会使用 maven-antrun-plugin 并在 ant 中编写脚本,以获得可移植的解决方案。
mvn -X might be more revealing
Many people would use the maven-antrun-plugin and script this in ant so as to get a portable solution.