Maven:获取CSM /连接的依赖关系

时间:2018-09-15 10:42:31

标签: maven github

我们有许多内部使用的Maven工件,我们需要整理所有这些依赖项并将它们映射到csm /这些依赖项的连接中提到的github存储库。

  <scm>
        <connection>github_URL</connection>
        ...
  </scm>

那么有没有一种优雅的方法来获取pom文件的每个依赖项的csm /连接?

1 个答案:

答案 0 :(得分:1)

好吧,我设法使用bash scriptperlmvn-dependency-plugin

在您的主要maven项目中,运行以下命令:

  mvn clean dependency:unpack-dependencies -Dmdep.unpack.includes=**/pom.xml

这将解压缩pom.xml目录中所有依赖项的所有target/dependency文件。

然后运行以下bash脚本:

for pom in $(find target/dependency/META-INF/maven -name 'pom.xml'); 
    do cat $pom | perl -n -e '/<connection>(.*)<\/connection>/ && print "$1\n"';
done

这将迭代所有pom.xml文件,并打印所有模块中的所有scm连接字符串。