Re: dependency version at pom level
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 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): > > > > commons-logging > commons-logging > 1.1 > > ... > > > 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
Re: dependency version at pom level
On Mon, Jun 15, 2009 at 6:54 PM, tony k 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): commons-logging commons-logging 1.1 ... 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
dependency version at pom level
i'm new to maven, but have decades of experience with builds and java. after a basic survey of maven, one of the first things i asked my self is how i could force a version of a dependency at the parent pom. 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. i did some research and found some mailing list archives which basically said this wasn't supported and that the technique to address this would involved the use of exclusions, but you may end up having to exclude the same transitive dependency across multiple direct dependencies. this seems to violate the "don't repeat yourself" (DRY) principle, and i was wondering why there wasn't some thing like an "override" flag for dependencies in the "dependencyManagement" section to provide the option to ratchet down the version of a potentially repetitively occurring transitive dependency in one fell swoop. i came up with a round about way of accomplishing that by declaring a pom-type dependency, and specifying the exclusion there, but it seems on the awkward side. so basically, i just wanted to verify this behavior and ask if anyone was aware of any outstanding jira entries requesting this type of feature, or if this is an old topic that has been dismissed as a improper or something. thanks,tony. -- View this message in context: http://www.nabble.com/dependency-version-at-pom-level-tp24046046p24046046.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