如何在不使用本地安装的工件的情况下进行构建
有没有办法强制 Maven 使用远程工件而不是安装在您的计算机上的工件? 因为我担心运行时错误而不是编译错误,构建服务器不是有效的选项。
PS 我知道我可以删除或重命名 .m2 文件夹,但我敢打赌有一些更聪明的方法可以做到这一点。 也许是一些插件或特殊的命令参数?
Is there any way to force Maven to use remote artifacts and not those installed on your machine? since I worry about runtime errors and not compilation errors build server is not valid option.
P.S. I know I could delete or rename the .m2 folder, but I bet there is some more clever way of doing this. Maybe some plugin or special command param?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为没有真正的方法可以满足您的要求。 您可以根据 SNAPSHOT 版本进行研究(但这意味着将上游项目的版本字符串更改为 SNAPSHOT 版本)。
顺便说一句,最近的 Java Posse 剧集 (#268)。 我认为他们最终没有找到解决方案,但你可能会得到一些好主意。
我也喜欢一些Rich Seller 的想法,我会亲自研究一下。
I don't think there's really a way to do what you are asking for. You could look into depending on SNAPSHOT releases (but that means changing your version string of the upstream projects to be SNAPSHOT versions).
Incidentally, this was discussed at length in a recent Java Posse episode (#268). I don't think they ended up with a solution, but you may get some good ideas there.
I also like some of Rich Seller's ideas, which I'll be looking into myself.
没有本地存储库意味着您的类路径几乎完全由远程服务器上的 URL 组成。 我不明白为什么会支持这个,因为执行会很糟糕,并且任何断开的连接都会导致类加载器问题。 拥有本地存储库可确保 jar 在编译/执行开始之前可用。
还要考虑 WAR 和 EAR 项目(以及许多使用依赖插件的项目)依赖于下载 jar 来完成其打包。 如果每次构建时都必须从远程存储库检索这些内容,则会产生巨大的开销。 我很确定中央的管理者不会热衷于处理这种负载。
您可以考虑一些替代方案:
有关 LATEST 的更多详细信息和发布,请参阅 Maven 书的第 9.3.1.3 节。
如果您使用内部存储库管理器(必需 Nexus 和 Artifactory 引用),清除本地存储库的开销大大减少 - 您将只是增加本地网络流量负载。
Having no local repository would mean your classpath consisting almost entirely of URLs on remote servers. I can't see why this would be supported as execution would be awful, and any dropped connection would result in classloader issues. Having a local repository ensures the jars are available before compilation/execution begins.
Also consider that WAR and EAR projects (and many using the dependency plugin) rely on downloading the jars to complete their packaging. There would be a huge overhead if these had to be retrieved from a remote repository on every build. I'm pretty sure the managers of central would not be keen on dealing with that load.
Some alternatives for you to consider:
For more details on LATEST and RELEASE, see section 9.3.1.3 of the Maven book.
If you use an internal repository manager (obligatory Nexus and Artifactory references here), the overhead of purging the local repository is greatly reduced - you'll just have an increased local network traffic load.