我们有许多内部使用的Maven工件,我们需要整理所有这些依赖项并将它们映射到csm /这些依赖项的连接中提到的github存储库。
<scm>
<connection>github_URL</connection>
...
</scm>
那么有没有一种优雅的方法来获取pom文件的每个依赖项的csm /连接?
答案 0 :(得分:1)
好吧,我设法使用bash script
,perl
和mvn-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连接字符串。