Search code examples
javamaveneclipse-plugintycho

Set Maven property based on dependency version


I am assembling an Eclipse plugin using Maven and Tycho, where one of my maven projects aggregates the non-OSGi dependencies of the project and bundles them as an Eclipse plugin (so that Tycho, and therefore my main plugin, will be able to use them)

I am hitting an issue where one of my dependencies should always be the latest version of the jar, eg:

<properties>
    <binary-version>LATEST</binary-version>
<properties>
<dependencies>
    <dependency>
        <groupId>com.imaginary.group</groupId>
        <artifactId>needed-binaries</artifactId>
        <version>${binary-version}</version>
    <dependency>
</dependencies>

(FYI, the actual dependency is something we deploy internally, otherwise I would give the actual groupId/artifactId)

All the dependencies for this aggregator project are copied to a directory called maven-libs so that they can be bundled.

When I attempt to include this jar in my aggregator project, I need to specify it in the build.properties file, like so:

bin.includes = META-INF/,\
               .,\
               maven-libs/necessary-binaries-1.2.3.jar

This fails any time the necessary-binaries version number changes, as the name of the file changes as well

I can add maven properties to the build.properties, but:

bin.includes = META-INF/,\
               .,\
               maven-libs/necessary-binaries-${binary-version}.jar

just resolves to literally necessary-binaries-LATEST.jar, instead of substituting in the latest version

So my question is: when I resolve the LATEST version for needed-binaries, can I set that version to a property? I could then use that propery in the build.properties file


Solution

  • Using LATEST is a deprecated feature. It is better to use the real version number and update it with the versions plugin.