0

I've a resource file, that is filtered by maven:

version=${project.version}
buildDate=${timestampFormatted}
buildBy=${user.name}   
fileEncoding=${file.encoding}
XX_LIB_VERSION = ${project.dependency.someName.version}

I would like to have one or more dependency and version used by the pom Is there any thing like ${project.dependency.someName.version}?

Thank you!

JavaSheriff
  • 7,074
  • 20
  • 89
  • 159

1 Answers1

2

First extract desired dependencies' versions into a property (which is always a good idea):

<properties>
    <org.springframework.version>3.1.0.RC2</org.springframework.version>
</properties>

And use it later in pom.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${org.springframework.version}</version>
</dependency>

Once this is done you can reference the property in filtered resource:

XX_LIB_VERSION=${org.springframework.version}
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • So for X dependencies i will have to declare X properties? – JavaSheriff Jan 11 '12 at 20:21
  • Yes, unfortunately. Although I am not claiming this is the best approach. Spring is a good example here because you typically import several dependencies with the same version (only one property needed). – Tomasz Nurkiewicz Jan 11 '12 at 20:50