是否“使用本地依赖项构建"?在没有多模块的Maven中存在吗? [英] Does "build with local dependencies" exist in Maven without multi-module?

查看:80
本文介绍了是否“使用本地依赖项构建"?在没有多模块的Maven中存在吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一套应用程序,都使用Maven和本地存储库.应用程序在它们的 pom.xml 中使用 形成一个依赖树.所有这些项目的版本中都有 -SNAPSHOT.

I have a set of applications, all use Maven and the local repository. The applications form a dependency tree using <dependency> in their pom.xml. All of these projects have -SNAPSHOT in their version.

Maven(或某些兼容的依赖项管理器)是否可以将应用程序与其所有源已更改的本地依赖项一起构建?

我不想创建一个多模块项目,因为:

I do not want to create a multi-module project, because:

  • 项目完全是库,而不是模块;
  • 我不希望仅仅拥有一种已经精确定义的构建形式而增加额外的复杂性;
  • 我希望这个过程是动态的:如果一个库足够成熟,可以放入远程存储库,它就不会再用主项目重新构建,这没关系.

目前,有很多重构,将代码从一个库移动到另一个库等等,而且依赖树的重要部分经常需要重建.因此,我需要在多个项目中手动编写 mvn install 以确保没有过时的代码.

For now, there is a lot of refactoring, moving code from one library to another etc. and it happens often that substantial parts of the dependency tree need to be rebuilt. I thus need to manually write mvn install in several projects in order to assure that there is no stale code.

推荐答案

不,它不起作用.即使是一个多模块项目,maven 也不会检测到哪些模块在其中更改了源,哪些没有.

No, it doesn't work. Even with a multi-module project, maven does not detect which modules have changed sources in it and which do not.

在 Maven 2 中有一个(片状)实现,但在 3.x 中没有继续,参见 如何让 maven 3.0 只构建具有本地 scm 更改的模块

There was a (flaky) implementation in Maven 2, but it was not continued in 3.x, see How to get maven 3.0 to only build modules with local scm changes

我希望他们能在 maven 4 中再次包含它,但我还没有看到它:https://maarten.mulders.it/2020/11/whats-new-in-maven-4/

I hoped they would include it again in maven 4, but I didn't see it yet: https://maarten.mulders.it/2020/11/whats-new-in-maven-4/

我曾经做过类似的设置,但不得不使用带有一些 git 魔法的 shell 脚本来让它工作.

I once did a similar setup, but had to use shell scripts with some git magic to get it working.

您也可以决定从一开始就将您的库放在单独的 repo 中,并使用谷歌用于 android 开发的 repo 工具:https://github.com/GerritCodeReview/git-repo/blob/main/README.md

You can also decide to put your libraries in separate repo's from the start, and use the repo tool that google uses for android development: https://github.com/GerritCodeReview/git-repo/blob/main/README.md

这篇关于是否“使用本地依赖项构建"?在没有多模块的Maven中存在吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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