Maven: get csm/connection for dependencies

Viewed 117

We have a lot of maven artifact for internal use, and we need away to organize all these dependencies and map them to the github repository that's mentioned in csm/connection of these dependencies.

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

So is there an elegant way to get csm/connection of a each dependency of a pom file?

1 Answers

Well I managed to get this using a bash script, perl and mvn-dependency-plugin

In your main maven project run the following command:

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

This will unpack all pom.xml files of all dependencies in target/dependency directory.

Then run the following bash script:

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

This will iterate for all pom.xml files and print all the scm connection strings in all modules.

Related