如何从 Maven 版本中排除未修改(scm)模块

发布于 2024-10-10 01:37:50 字数 368 浏览 0 评论 0 原文

我有一个包含大约 200 个 jar 的巨大项目,当我准备发布 maven 时,会为所有 jar 做准备,但可以肯定的是,有些 jar 自上次构建以来尚未修改,所以有什么方法可以检查自上次从 scm 构建以来 jar 是否已被修改?并排除他们?

我不想单独释放 jars(超过 200 个)。

例如:我想为父级发布 relase,但我不想发布尚未修改的 jar4

-Parent

---------Module1

----------------jar1*

----------------jar2*

---------Module2

----------------jar3*

----------------jar4   

i have huge project that contains around 200 jars, when i prepare release maven prepare for all jars but for sure there are jars that has not been modified since last build so is there any way to check if jar has been modified since last build from scm? and exclude them?

i dont want to relase jars (more than 200) individually.

for example: i want to make relase for parent but i dont want to relase jar4 that has not been modified

-Parent

---------Module1

----------------jar1*

----------------jar2*

---------Module2

----------------jar3*

----------------jar4   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

书间行客 2024-10-17 01:37:50

例如:我想为父级进行relase,但我不想relase尚未修改的jar4

其语法是

mvn -pl Module1,Module2/jar3 <your maven goals here>

(在这种情况下,您想要构建所有 Module1 和 Module2 的 jar3)

现在棘手的部分是如何将参数组装到-pl。我非常确定没有 Maven 方法可以做到这一点,因此您可能必须编写一个 shell 脚本(或 Ruby、Groovy、PERL python 等脚本)来为您执行此操作。

基本上,您的脚本必须执行以下操作:

  • 在给定目录中查找所有 maven 项目目录(包含 pom.xml 的目录),对它们进行反向排序(首先是最深的路径)
  • 在整个层次结构中查找所有已更改的文件(使用 svn、cvs或任何调用)
  • 将每个更改的文件映射到项目之一(通过比较路径),收集列表中的所有匹配项目
  • 现在通过执行一些父/子优化来优化列表(如果给定父项的所有子项都存在,则删除子级并添加父级)。重复执行此操作,直到到达根层次结构。
  • 从剩余的列表中,提取相对路径,用逗号将它们连接起来,然后使用 -pl 参数的值启动 Maven 进程。

for example: i want to make relase for parent but i dont want to relase jar4 that has not been modified

The syntax for this is

mvn -pl Module1,Module2/jar3 <your maven goals here>

(in this case you want to build all of Module1 and just jar3 of Module2)

Now the tricky part is how to assemble the parameter to -pl. I am pretty sure there is no maven way to do that, so you will probably have to write a shell script (or Ruby, Groovy, PERL python etc. script) that does that for you.

Basically, what your script must do:

  • look for all maven project directories (directories that contain a pom.xml) in the given directory, sort them in reverse (deepest paths first)
  • find all changed files in the entire hierarchy (using svn, cvs or whatever calls)
  • map each changed file to one of the projects (by comparing paths), collect all matched projects in a list
  • Now optimize the list by doing some parent/child optimization (if all children of a given parent are present, remove the children and add the parent). Do this repeatedly until you reach the root hierarchy.
  • From the remaining list, extract the relative paths, join them with a comma and start your maven process using that value for the -pl parameter.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文