How to check the sources of an artifact, given its coordinates in Maven?

I am going to write a tool with which our developers can check the sources of an artifact, given its maven coordinates. The tool should be able to selectively check sources recursively for all SNAPSHOT dependencies.

My first question is: do I need to write this tool at all? You can imagine that this is not a very unique user scenario, but so far I have not been able to find something suitable to achieve this. I looked at scm: checkout and scm: bootstrap, both require knowledge of the connection url, since I only have artifactID. Is there any other way, but write my own tool to do this?

If not, my home brew tool will do something in the following lines:

  • Parse.m2 / settings.xml to determine which repo to use. Download pom for artifact.
  • Create a temporary bootstrap-pom with the scm tag from the loaded pom.
  • Use scm: bootstrap and bootstrap-pom to check.
  • [Optional] Search for sources for SNAPSHOT dependency pumps and repeat the process.

My second question is: will this sound like a good way to handle this? Any spring reservations to mind?

+3
source share
2 answers

For each project that you want to check in this way, you can add a profile containing the plugin configuration for the bootstrap purpose of the scm plugin. The plugin configuration will be in the same POM as the scm URL, so descriptors # 2 and 3; you do not need a separate bootstrap-pom.

POM dependency:get :

mvn dependency:get -Dartifact=some.group:my.artifact:version:pom -Ddestination=someDirectory

POM :

mvn -Pbootstrap-profile-id scm:bootstrap

.

, . , dependency:copy-dependencies POM, . , .

+1

user944849 , ,

mvn dependency:get -Dartifact=ar.com.hjg:pngj:2.1.0:pom  -Ddest=pom.xml
mvn scm:bootstrap -Dgoals=validate
mv target/checkout ~/projects/pngj
0

All Articles