How to change the version of a dependency during test execution to test binary compatibility with maven?

238 Views Asked by At

I'm currently working on a dbunit extension library. Thus this library depends on dbunit.

I extracted the version as a maven property.

<properties>
    <dbunit.version>2.4.8</dbunit.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>${dbunit.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

This allows me to run the maven build with another dbunit version

mvn test -Ddbunit.version=2.7.3

But it also change the dbunit version that the compiler uses. Thus I test source code compatibility to another dbunit version.

The question I want to answer with my maven build is:

Does my library work normal, as specified by the tests, if I use the library that was build against dbunit 2.4.8 with dbunit 2.7.3 at runtime?

I would like to introduce version ranges so that clients of the library can choose which version they want to use, but to do that I want to test which versions work.

The maven-surefire-plugin allows me to add additional classpath entries. But only if I know the path of a lib. I would like to use the GAV (group artifact version) format.

How can I solve this? Do you know another plugin that can handle such cases.

0

There are 0 best solutions below