On Mon, Jun 15, 2009 at 6:54 PM, tony k<[email protected]> wrote:
> the general use case is that you are working with a series of third-party
> dependencies
> (and their respective poms) that specify conflicting versions of a
> particular
> library commons-logging for example, and you want to force a specific
> version
> that you know you will be running with. let's say you want to verify
> behavior
> of those third party dependencies with this specific version using the test
> goal.

Perhaps I am misunderstanding your question, but I think the
dependecyManagement section in fact does exactly what you want:
enforce versions of dependencies.  Specify the following section in a
common parent for your artifacts, mvn install, and you should be done
(I used version 1.1 for the sake of example):

<dependencyManagement>
  <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1</version>
  </dependency>
...
</dependencyManagement>

You can visually test the result using 'mvn help:effective-pom' or
'mvn dependency:tree'.

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

"Dependency management - this allows project authors to directly
specify the versions of artifacts to be used when they are encountered
in transitive dependencies or in dependencies where no version has
been specified. ... A can include D as a dependency in its
dependencyManagement section and directly control which version of D
is used when, or if, it is ever referenced."

Controlling versions through dependencyManagement is a good idea
(combined with parent POMs, dare I say a "best practice").  Handling
this stuff is one of maven's key strengths; it was designed for this
general use case.  No surprise that this is "one of the first things"
you asked yourself :)

You would only *need* to use exclusions if you didn't want the
dependency at all.  If that were true, then yes, I think you would
have to do it for each artifact that specified it as a direct
dependency.

Zac

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to