使用 Maven 只是为了获取一些库 jar
我们在构建过程中使用 ANT,并且没有计划在不久的将来改变这一点。
是否可以使用 Maven 只获取常见的开源 jar 文件(例如 Log4J、SWT、JFace)并将它们放在我们项目的正确位置,这样我们就不必将它们存储在我们的版本控制——最好不要在主目录中创建典型的 Maven 缓存?
We are using ANT for our build process and don't have plans to change this in the near future.
Is it possible to use Maven to just fetch common Open Source jar files (e.g. Log4J, SWT, JFace) and put them in the right location of our project, so we don't have to store them in our version control — preferable without creating the typical Maven-cache in the home directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不不不大家!
如果您使用 Ant,使用 Maven 存储库下载 jar 依赖项的最佳方法是将 Ivy 与 Ant 结合使用。这正是 Ivy 的用途。
安装 Ivy 并开始使用当前的 Ant 项目很简单。如果您使用 Nexus 和 Artifactory 作为本地 Maven 存储库,它可以与 Nexus 和 Artifactory 配合使用。
看看常春藤。这可能正是您想要的。
NO NO NO Everyone!
If you're using Ant, the best way to use Maven repositories to download jar dependencies is to use Ivy with Ant. That's exactly what Ivy is for.
Installing Ivy and getting to work with current Ant projects is simple to do. It works with Nexus and Artifactory if you use those as your local Maven repositories.
Take a look at Ivy. It is probably exactly what you want.
org.life.java 的答案,我不会执行
mvn install
。相反,我会在 pom.xml 中添加以下内容:
现在您只需要执行
mvngenerate-sources
,这比完整的mvn install
快得多,并且所有依赖项都会被复制到指定目录。哦,顺便说一句,这不是 Apache Ivy 的意思吗?扩展Ant以了解Maven的依赖管理?
In variation of org.life.java's answer, I would not do
mvn install
.Instead, in the pom.xml I would add the following bit:
Now you just need to do
mvn generate-sources
, which is a lot faster than the fullmvn install
, and all dependencies will be copied to the specified directory.Oh btw, isn't that what Apache Ivy is about? Extending Ant to understand Maven's dependency management?
有可能,您应该使用 maven-ant-tasks。
特别是它的
dependency
ant 任务。通过此设置,不需要安装 Maven。您应该签入项目的唯一二进制文件是
maven-ant-tasks.jar
。实际上在我们的项目中我使用了 Sonatype Nexus ( 文档 ) Maven 存储库管理器,用于集中对不同存储库的访问,甚至维护一些我们环境特有的二进制文件。在 Nexus 的帮助下,我只需从已知 URL 中使用 ant 的
任务获取maven-ant-tasks.jar
即可。您不必使用 Nexus,但它可以大大加快构建速度,因为它将二进制文件缓存在靠近开发人员计算机的位置。It's possible, you should use maven-ant-tasks.
In particular its
dependencies
ant task. With this setup no Maven install is required.The only binary you should check into your project is
maven-ant-tasks.jar
.Actually in our project I used Sonatype Nexus ( documentation ) Maven repository manager to centralize access to different repositories and even maintain some binaries unique to our environment. With Nexus' help I just fetch
maven-ant-tasks.jar
with ant's<get>
task from a known URL. You don't have to use Nexus, but it greatly speeds up builds, because it caches binaries close to your developer's machines.艾维就是这么做的,
当它自我引导时:
http://ant.apache.org/ivy/history/latest -milestone/samples/build.xml
Ivy does just this,
when it bootstraps itself:
http://ant.apache.org/ivy/history/latest-milestone/samples/build.xml