Maven: access version of transitive dependency via property

大憨熊 提交于 2019-12-19 03:38:04

问题


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

来源:https://stackoverflow.com/questions/23891067/maven-access-version-of-transitive-dependency-via-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!