doh!

you're absolutely correct zac.

i misinterpeted something i read in "maven: the definitive guide".

on the bottom of page 106 in a section describing dependencyManagement it
reads:

Once these are moved up, we need to remove the versions for these
dependencies from each of the POMs; otherwise, they will override the
dependencyManagement defined in the parent project.

so i was thinking using dependencyManagement for my use case wouldn't work
unless the version wasn't specified in the dependent poms, but i guess the
above statement only applies to pom inheritance relationships, versus pom
dependency relationships. 

so i'm all set on this, thanks again!

 

Zac Thompson wrote:
> 
> On Mon, Jun 15, 2009 at 6:54 PM, tony k<tony_k...@sbcglobal.net> 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: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/dependency-version-at-pom-level-tp24046046p24066287.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to