管理maven依赖关系 - 新版本和非Repo库 [英] Managing maven dependancies - New Versions and Non-Repo libraries

查看:128
本文介绍了管理maven依赖关系 - 新版本和非Repo库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告:我刚刚拿起Maven,所以提到的事情可能是错误的或不是最佳做法。



我有一个中等大小我从基本的
NetBeans项目管理迁移到Maven的开源项目。这不是开发团队共享同一个房间,这是互联网共享一个SVN repo的1-5个人。阅读依赖关系的方法,似乎获取依赖关系的唯一方法是让他们从在线回购或在本地安装。



这不是我要找的。我想保持SVN中的所有依赖关系,包括可移植性(任何人都可以通过,查看repo,构建和使用)的所有依赖关系,所有这些都不需要手动添加到本地的repo和whatnot),获取更新的版本(下面讨论) ,和手动版本。



我与maven存储库的另一个问题是它们在版本中相当落后。回溯例如是 0.9.18 in mvnbrowser ,但 0.9.24正式 。 PircBot是 1.4.6 in mvnbrowser ,但 1.5.0正式。为什么这样的旧版本?



问题3是我的依赖关系甚至不存在于回馈中,如更容易的Java持久性



所以


  1. 如何强制所有依赖项来自 / lib 例如

  2. 在相关的笔记中,可以直接从图书馆的SVN repo建立mvn吗?只是好奇

  3. 如果他们也使用Maven,是否有自动方式直接从依赖网站/ svn repo获取最新版本? IE库如commons-lang或logback

  4. 有更好的管理依赖关系的方法吗? (IE常春藤或一些奇怪的POM选项我缺少)

FYI,这是一个Java项目,有3个模块,项目全局依赖和/或

如果可以使用NetBeans附带的Maven捆绑版本,则可以获得积分。



不重复




解决方案


不是我在找什么我想保持SVN中的所有依赖关系有很多原因(...)


我会回来,但解决方案我在 Maven中添加一个依赖关系通过相对路径(使用基于文件的存储库)可以实现这样的解决方案。


我与maven存储库的另一个问题是它们在版本中相当落后。例如,在mvnbrowser中为0.9.18,而正式为0.9.24。 PircBot在mvnbrowser中为1.4.6,但是正式为1.5.0。为什么这样的旧版本?


看起来像 mvnbrowser 指数完全过时(使其无用作为存储库搜索引擎),因为 maven中央存储库确实有 logback-core-0.9.24.jar (logback项目正在做必须做的事情,以实现这一点)但只有一个旧的 pircbot-1.4.2。罐 。为什么?问pircbot团队无论如何,你是对的,中央存储库可能并不总是具有最终版本。


问题3是我没有依赖关系甚至存在于垃圾回收中,比如更容易的Java持久性。


是的,这也发生了。


如何强制所有依赖项来自/ lib例如


如以前暗示的,您应该仔细阅读解决方案在 Maven:添加依赖关系到jar相对路径。关于将库安装到本地存储库而言,此解决方案不是,而是关于使用基于文件的存储库(因此可以存储在SVN中) 。你可能错过了这一点,这符合你的用例。并检查 Brett的回答一个变体。


在相关的笔记中,可以直接从图书馆的SVN repo建立mvn吗?只是好奇


没有得到那个。你可以澄清一下吗?


如果他们也使用Maven,是否有自动方式直接从依赖网站/ svn repo获取最新版本? IE库,如commons-lang或logback $ /

Maven支持版本范围,您可以使用允许使用任何版本大于X的语法。但是,为了构建可重复性,我根据推荐使用版本范围。你不想让构建突然失败,因为你的背部发生了一些自动更新。只有在需要修复错误或新功能时,才能进行升级,但要明确地进行升级(如果没有破坏,请不要修复它))。



您可能还会发现 LATEST 和 RELEASE 提及 $ c>版本标记。我不建议他们,因为与他们从Maven 3.x 中删除。


有没有更好的管理方式依赖呢? (IE常春藤或一些奇怪的POM选项我失踪)


不能说为常春藤。但是在Maven的土地上,如果您无法为您的项目(Nexus,Archiva,Artifactory)启动企业存储库,那么基于文件的存储库就是IMO最好的方法。


Warning: I have just picked up Maven, so things mentioned might be wrong or not best practice.

I have a medium size open source project that I am migrating to Maven from the basic NetBeans project management. This is not a developer team sharing the same room, this is 1-5 people over the internet sharing a SVN repo. Reading over the how-tos on dependencies, it seems that the only way to get dependencies is to get them from an online repo or install them locally.

This is not what I was looking for. I want to keep all dependencies in the SVN for many reasons including portability (anybody can pass by, check out the repo, build, and use; all that simply without manual adding to local repo's and whatnot), getting newer versions (discussed below), and manual versioning.

The other issue I have with the maven repository is that they are quite behind in versions. Logback for example is 0.9.18 in mvnbrowser but 0.9.24 officially. PircBot is 1.4.6 in mvnbrowser but 1.5.0 officially. Why such old versions?

Issue 3 is that I have dependencies that don't even exist in the repos, like Easier Java Persistence.

So

  1. How can I force all dependencies to come from /lib for example
  2. On a related note, can mvn build from library's SVN repo directly? Just curious
  3. Is there an automatic way to get the newest version directly from a dependencies site/svn repo if they also use Maven? IE libraries like commons-lang or logback
  4. Is there a better way of managing dependencies? (IE Ivy or some weird POM option I'm missing)

FYI, this is a Java project with 3 modules, project global dependencies and module specific dependencies.

Bonus points if it can work with the bundled version of Maven that comes with NetBeans.

Not a duplicate of

解决方案

This is not what I was looking for. I want to keep all dependencies in the SVN for many reasons (...)

I will come back on this but the solution I described in Maven: add a dependency to a jar by relative path (using a file-based repository) allows to implement such a solution.

The other issue I have with the maven repository is that they are quite behind in versions. Logback for example is 0.9.18 in mvnbrowser but 0.9.24 officially. PircBot is 1.4.6 in mvnbrowser but 1.5.0 officially. Why such old versions?

It looks like mvnbrowser indices are totally out of date (making it useless as repository search engine) because the maven central repository does have logback-core-0.9.24.jar (the logback project is doing what has to be done to make this happen) but only has an old pircbot-1.4.2.jar. Why? Ask the pircbot team. Anyway, you're right, the central repository might not always have ultimate versions.

Issue 3 is that I have dependencies that don't even exist in the repos, like Easier Java Persistence.

Yeah, this happens too.

How can I force all dependencies to come from /lib for example

As previously hinted, you should re-read carefully the solution suggested in Maven: add a dependency to a jar by relative path. This solution is not about installing libraries to the local repository but is about using a file-based repository (that could thus be stored in SVN). You might have missed the point, this matches your use case. And also check Brett's answer for a variation.

On a related note, can mvn build from library's SVN repo directly? Just curious

Didn't get that one. Can you clarify?

Is there an automatic way to get the newest version directly from a dependencies site/svn repo if they also use Maven? IE libraries like commons-lang or logback

Maven supports version ranges and you could use a syntax allowing to use "any version greater than X". But I do NOT recommend using version ranges at all, for the sake of build reproducibility. You don't want the build to suddenly fail because of some automatic update that happened on your back. Only upgrade if you need bug fixes or new features, but do it explicitly (if it ain't broke, don't fix it).

You might also find mentions of the LATEST and RELEASE version markers. I don't recommend them neither for the same reasons as above and even less since they're removed from Maven 3.x.

Is there a better way of managing dependencies? (IE Ivy or some weird POM option I'm missing)

Can't say for Ivy. But in the Maven land, if you can't host up a "corporate" repository for your project (Nexus, Archiva, Artifactory), then the file-based repository is IMO the best approach.

这篇关于管理maven依赖关系 - 新版本和非Repo库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆