在 Maven 中,如何使用 wagon 插件复制文件?
摘要: 如何使用 Maven 将一些生成的文件复制到 Web 服务器(例如 IIS 或 Apache)目录中?
细节: 我有一个在 Maven 中构建的工作应用程序。我已经设法使用 webstart-maven-plugin 构建它在目录 target/jnlp
中生成所有需要的文件(.jar 和 .jnlp)。它还创建一个 zip 文件,将它们全部放在 target/foo-1.0.zip
中。
目前,webstart 插件没有 deploy
目标 - 对它的请求已结束于 常见问题解答(问题 3)。将来可能会实现,但暂时建议使用 wagon- maven-插件。
我从来没有用过瓦格。首先,我只想将文件复制到网络服务器提供的本地目录中。稍后我想远程复制它们,可能使用 ftp。有人可以举例说明我需要添加到 pom.xml 中才能使本地副本正常工作(希望还有 ftp 示例吗?)。我在文档中找不到它。通过阅读,我认为我可能还需要 Wagon Maven File Provider 但是因为这似乎几乎没有文档,我不确定。
Summary: How do I copy some generated files into a webserver (eg IIS or Apache) directory using Maven?
Details:
I have a working application that builds in Maven. I've managed to get it building using the webstart-maven-plugin which produces all the needed files (.jar and .jnlp) in a directory target/jnlp
. It also creates a zip file with them all in at target/foo-1.0.zip
.
At the moment the webstart plugin does not have a deploy
goal - the request for it has ended up on the FAQ (question 3). It may be implemented in future, but the suggestion for the time being is to use wagon-maven-plugin.
I've never used Wagon. To start with I'd like to just copy the files to a local directory served up by a webserver. Later I'd like to copy them remotely, probably using ftp. Can someone give an example to what I need to add to the pom.xml
to get the local copy working (and hopefully an ftp example too?). I can't find it in the documentation. From reading I think I might also need the Wagon Maven File Provider but as this seems to have almost no documentation I'm not sure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Wagon 提供商仅提供额外的网络协议支持(例如 FTP)。
如果您想将文件复制到网络服务器(本地或远程),您可以使用 Maven 上传插件:
在父 pom 中:
为了以智能方式配置参数,我使用 Maven 配置文件(在父 pom 中):
我创建了一个“ ant launcher”,通过在 Eclipse ant 视图下单击来使用它:
但您可以简单地在命令行上运行它:
编辑:顺便说一下,对于远程部署,您可能需要 scp 的登录密码到 工作。您必须将它们添加到 Maven settings.xml 文件中:
编辑:您需要添加 Atlassian 存储库:
编辑:取决于您将拥有的远程协议要添加 Wagon 扩展,请参阅 使用 sftp 上传目录Maven
Wagon providers are only there to provide additional network protocol supports (such as FTP).
If you want to copy file to a webserver (local or distant) you can use Maven upload plugin :
In parent pom :
And to configure parameters in a smart way, I use maven profiles (in parent pom) :
I've created an "ant launcher", to use it by clicking under Eclipse ant view :
But you can simply run it on a command line :
EDIT : By the way, for distant deployment, you may need a login password for scp to work. You have to add them to you Maven settings.xml file :
EDIT: You'll need to add the Atlassian repository:
EDIT: depending upong the remote protocol you'll have to add wagon extensions, see Uploading a directory using sftp with Maven
最后我没有使用 Maven 上传插件 - 它似乎有点有限,并且不是主要 Maven 发行版的一部分。我按照建议使用了 Maven Wagon 插件。这是我可以做到的最简单的 pom。希望其他人会发现它有用,因为我无法轻松找到类似的东西。
对于远程分发,您只需更改 URL 类型,并可能根据需要添加货车扩展。
In the end I didn't use the Maven upload plugin - it seemed a bit limited and not part of the main maven distribution. I used the maven wagon plugin as suggested. Here is the simplest possible pom that I could make that worked. Hopefully others will find it useful, as I couldn't find anything similar easily.
For remote distributions, you just change the URL type, and possibly add wagon extensions as necessary.