如果我的开源项目受到maven的管理,并且依赖于不在maven存储库中的库,该怎么办? [英] what if my open source project is managaed by maven and depends on a library not in maven repository?

查看:83
本文介绍了如果我的开源项目受到maven的管理,并且依赖于不在maven存储库中的库,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下这种情况.我有一个使用Maven管理的开源项目,它依赖于不在maven存储库中的知名库(例如jpathwatch).我该如何运作?

Imagine this case. I have an open source project which I manage with Maven, and it depends on a well-known library (jpathwatch, e.g.) not in maven repository. How can I make it work?

直接的方法是将jpathwatch安装到本地Maven存储库.但是,这给检出我的项目源代码并希望由他们自己构建代码的人带来负担.他们将遇到一个maven错误,然后查看README文件,或者只是放弃尝试.

The straightforward way is to install jpathwatch to local maven repository. However, that imposes a burden for people who check out my project's source code and want to build them by themselvz. They'll encounter an maven error and then look into the README file, or just give up trying.

我有一种干净的解决方法吗?我必须回到ANT吗?

Is there a clean way for me to work it around? Do I have to go back to ANT ?

推荐答案

最简单的方法是将库上载到中心(或者,如果您的项目不是开源的,则将库上载到项目的Maven存储库中)托管在)上.

The cleanest way to do this is to upload the library to central (or failing that, if your project is not open source, to the maven repository that your project is hosted on).

关于上传的指南第三方工件到中心,其中详细说明了如果原始项目不想要的话如何上传工件.

There is the guide on uploading 3rd party artifacts to central which details how to upload the artifact if the originating project doesn't want to.

还有一种可能性,就是将工件部署在您自己的groupId下...更多是不得已而为之,或者如果官方方式对您而言太慢的话,则是优先考虑.

There is also the possibility of just deploying the artifact under your own groupId... more of a last resort, or first resort if the official way seems too slow for you.

如果您想成为一名优秀的开源公民,请将其上传到Central,以便其他人受益.

If you want to be a good open source citizen, upload that stuff to central, so that others will benefit.

类似项目内存储库对于住在公司资源库管理器后面且在~/.m2/settings.xml中有<mirrorOf>*</mirrorOf>的人(应该是他们)应该不会起作用

Hacks like in-project repositories won't work for people who live behind a corporate repository manager and have <mirrorOf>*</mirrorOf> in their ~/.m2/settings.xml (as they should have)

system范围这样的小问题,当人们尝试将您的项目作为可传递依赖项时,会带来无休止的痛苦世界……因为猜测${basedir}在解决您的项目时会评估什么从本地存储库而不是从反应堆获取?尝试~/.m2/repository/your-groupId/your-artifactId/your-version,它肯定不是 ,您将其放置在第3方jar文件中.

Hacks like system scope cause a never ending world of pain when people try to work with your project as a transitive dependencies... because guess what ${basedir} evaluates to when resolving your project from the local repository and not from the reactor? try ~/.m2/repository/your-groupId/your-artifactId/your-version which is definately not where you put that 3rd party jar file.

system作用域hack仅在构建最终工件时才起作用,即使那样,它也可能具有意想不到的副作用(例如将类路径烘焙到JAR清单中...它将是您机器的-磁盘路径...而不是用户部署到的路径)

The system scope hack only works when you are building the final artifact, and even then it can have unintended side-effects (like the classpath that gets baked into the JAR manifest... it will be your machine's on-disk path... not the path that the user deploys to)

只有三种解决方案:

  1. 将其部署到远程存储库(首选转到中央存储库)
  2. 将其安装在本地存储库中(最终用户会很痛苦)
  3. Fake模块解决方案(在其中伪造了一个JAR模块,并用您想要分入的jar替换了内置"的jar,以便该模块现在是无需构建的内置工件...最终是选项1或2,但比项目存储库"中的解决方案邪恶得多)

这篇关于如果我的开源项目受到maven的管理,并且依赖于不在maven存储库中的库,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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