I have a maven dependency in my pom.xml as such:
<dependency>
<groupId>com.foo</groupId>
<artifactId>Bar</artifactId>
<version>1.2.3</version>
</dependency>
And I would like to use the system path to the binary as a property (so I can pass it to an external process that is kicked off by maven). I can do this in an awkward way:
<properties>
<my.lib>${settings.localRepository}/com/foo/Bar/1.2.3/Bar.jar</my.lib>
</properties>
But I would really like to use a more standard mechanism, such as:
<properties>
<my.lib>${com.foo:Bar:1.2.3}</my.lib>
</properties>
I something like that possible?
Assuming that the
com.foo:Bar:jar:1.2.3artifact is declared as dependency in your POM, the following property returns the path to the jar in the local repository:Update: Here is a simple POM demonstrating this:
Running
mvn process-resourcesproduces the following output:$ mvn process-resources [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building q2359872 [INFO] task-segment: [process-resources] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources {execution: default-resources}] [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/pascal/Projects/stackoverflow/q2359872/src/main/resources [INFO] [antrun:run {execution: default}] [INFO] Executing tasks [echo] /home/pascal/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar [INFO] Executed tasks [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7 seconds [INFO] Finished at: Tue Mar 02 14:41:32 CET 2010 [INFO] Final Memory: 7M/68M [INFO] ------------------------------------------------------------------------