0

I have a maven plugin which is using hsqldb 1.8.0.10. In my pom.xml from the plugin, it is declared like this:

<dependency>
    <groupId>hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>1.8.0.10</version>
</dependency>

But if I run that plugin from another maven project, and that project has a newer version of hsqldb (for instance 1.9.0), how can I configure my plugin that he will use the newest version of hsqldb, without changing it's pom.xml?

And is it possible to do this the other way around as well? If my other maven project uses hsqldb 1.7.0 (for instance), that he will use the 1.8.0.10 version which is specified in the maven plugin itself?

I hope someone can answer my question.

Kind regards,

Walle

Walle
  • 540
  • 1
  • 9
  • 32
  • Did i understand correct that you are creating a plugin or using a plugin which has a dependency like http://mojo.codehaus.org/sql-maven-plugin/usage.html ? – khmarbaise May 17 '11 at 16:32

2 Answers2

1

use properties place holder for the version, say ${hsqldb.version} then declare in different project pom the version you want to put in it

1

Your main question is possible, but it might not work properly if the plugin doesn't work with the newer code for any reason.

A plugin can have it's own personal dependencies section, and will use standard Maven dependency resolution, choosing the highest version requested. So, you can do

<plugin>
    <groupId>some.group.id</groupId>
    <artifactId>some.artifact.id</artifactId>
    <version>someversion</version>
    <dependencies>
        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.9.0</version>
        </dependency>
    </dependencies>
</plugin>

I don't think going the other way around is possible, though.

DuckPuppy
  • 1,336
  • 1
  • 12
  • 21
  • Going the other way around is not possible indeed. Classloaders of project and plugins are meant to be isolated (especially in Maven 3). If you need another version of the same library for the plugin, use this answer. If you want another version for your project dependencies, you will have to change it in your pom. Would Maven resolve project dependencies by including also plugins ones, it would be Hell on Earth :) – Tome Nov 08 '13 at 21:27