1

For an artifact in Nexus, I want to find out the classpath, i.e. against which version of which artifact the artifact was built. Of course, parsing the pom gives some hints, but as we have parent POMs, dependency management etc., this is a difficult task.

I guess that Maven does not store this information in the jars or side artifacts automatically (at least I cannot find such a thing, a hint would be very welcome), but is there an easy way to adjust the build process so that Maven puts this information into the Nexus repository?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • The [build-classpath](http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html) mojo of the dependency plugin seems helpful – SpaceTrucker Aug 25 '16 at 09:45
  • 1
    You could also consult the maven dependency tree (if you need the information more structured than just in a list) `mvn dependency:tree` – Ralph Aug 25 '16 at 09:48

1 Answers1

1

Nexus doesn't provide such functionality. You can use the Maven dependency tree instead by invoking:

mvn dependency:tree

If you use a CI (Continuous Integration) server (such as Hudson/Jenkins, Bamboo, TeamCity, etc), you can usually see which particular revisions of the snapshots were used for this build.

carlspring
  • 31,231
  • 29
  • 115
  • 197
  • So if I want to see the concrete dependencies in Nexus, I should write the dependency tree to a file and add it the artifact? – J Fabian Meier Aug 25 '16 at 10:02
  • Well, if you really must have it in a file -- I would assume -- "yes". Otherwise, you can always invoke the command locally and have a look at the tree. – carlspring Aug 25 '16 at 11:27
  • If using `dependency:tree` use the correct [`scope`](http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html#scope). Also not that there is currently a problem with it: https://issues.apache.org/jira/browse/MNG-3089 – SpaceTrucker Aug 25 '16 at 11:27
  • My actual aim is that I have programmatically accessible information in Nexus about the classpath/dependency-tree. – J Fabian Meier Aug 25 '16 at 11:32
  • If you'd like an easily parsable flat list, then you might prefer using `mvn dependency:list`. Check here for more details: http://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html . – carlspring Aug 25 '16 at 11:36