5

In a Maven project, one of my direct dependency has an indirect dependency com.foo:bar. What I need, is a Maven property (e.g. ${bar-version}) with the version number of this artifact. I need this mechanism for the version numbers of several indirect dependencies.

I learned from that question that I can access the local path of the artifact's jar with ${maven.dependency.com.foo.bar.jar.path} within the antrun plugin. The workaround I am using now, is to parse its value (e.g. /path/to/repository/com/foo/bar/2.1.1/bar-2.1.1.jar) within an antrun execution and define a property there (configuration exportAntProperties is my friend). However, since there is no good string regex manipulation in ant per default, this is quite cumbersome.

Are there other properties like ${maven.dependency.com.foo.bar.jar.path} available? I tried ${maven.dependency.com.foo.bar.jar.version}, but it did not work. I would also like to understand the mechanism behind this property. Is it backed by Java Classes? Like project.organization.name is getProject().getOrganizarion().getName() in the corresponding Maven Classes...

Any help welcome!

Thanks, Johannes

Community
  • 1
  • 1
Johannes S.
  • 321
  • 1
  • 3
  • 3
  • Use dependencyManagement to influence the transitive dependencies. Or you can explicit add those indirect deps to your own pom so they will fixed. – khmarbaise May 27 '14 at 13:59
  • I do not want to influence/override the dependencies. I want to have exactly the version of com.foo:bar that my direct dependency is using. – Johannes S. May 28 '14 at 10:59
  • Than just write it into your pom file. – khmarbaise May 28 '14 at 11:04
  • That is prone to typos - I could use a wrong version by accident. In addition, I want to have it updated automatically when I use a newer version of my direct dependency. It is not only one dependency, there are 5 indirect dependency version numbers I want to extract. – Johannes S. May 28 '14 at 13:11
  • https://stackoverflow.com/questions/14861242/maven-2-define-dependency-version-from-transitive-dependency-version – Rinke Mar 16 '18 at 13:36

0 Answers0