Quantcast

Does the "versions" plugin deal with transitive references to two different versions of an artifact?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Does the "versions" plugin deal with transitive references to two different versions of an artifact?

David M. Karr
If I have a build with a lot of modules, and I end up with two transitive dependency references to "commons-lang", one for version 2.2, and one for version 2.4, does the "versions" plugin let me define rules that will let me choose either the older or newer version to actually use?

From the documentation, I would think that "versions:use-latest-versions" comes close, but the documentation is vague.  It just says "Replaces any version with the latest version."

Does the "versions" plugin work with maven 3.x?

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does the "versions" plugin deal with transitive references to two different versions of an artifact?

Ansgar Konermann
Am 28.10.2011 20:07 schrieb "KARR, DAVID" <[hidden email]>:
>
> If I have a build with a lot of modules, and I end up with two transitive
dependency references to "commons-lang", one for version 2.2, and one for
version 2.4, does the "versions" plugin let me define rules that will let me
choose either the older or newer version to actually use?

The versions plugin deals with direct dependencies, not transitive ones.

>
> From the documentation, I would think that "versions:use-latest-versions"
comes close, but the documentation is vague.  It just says "Replaces any
version with the latest version."

Yes, but only those which are defined in the pom of your project, not inside
the poms of dependencies referenced by your project.

It just updates the text of the pom file, which cannot be done easily with
released poms from some maven repository. After all, that's why we have
releases first hand: to count on the released artifacts as unmodifiable.

To manage transitive dependencies, enable dependency convergence using
maven-enforcer-plugin. You will be notified about version clashes between
different versions of the same transitive dependency. To remove these
clashes, define <exclusions> for those transitive dependencies you don't
want in your classpath.

Best regards,

Ansgar

>
> Does the "versions" plugin work with maven 3.x?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Does the "versions" plugin deal with transitive references to two different versions of an artifact?

David M. Karr
> -----Original Message-----
> From: Ansgar Konermann [mailto:[hidden email]]
> Sent: Friday, October 28, 2011 12:15 PM
> To: Maven Users List
> Subject: Re: Does the "versions" plugin deal with transitive references
> to two different versions of an artifact?
>
> Am 28.10.2011 20:07 schrieb "KARR, DAVID" <[hidden email]>:
> >
> > If I have a build with a lot of modules, and I end up with two
> transitive
> dependency references to "commons-lang", one for version 2.2, and one
> for
> version 2.4, does the "versions" plugin let me define rules that will
> let me
> choose either the older or newer version to actually use?
>
> The versions plugin deals with direct dependencies, not transitive
> ones.
>
> >
> > From the documentation, I would think that "versions:use-latest-
> versions"
> comes close, but the documentation is vague.  It just says "Replaces
> any
> version with the latest version."
>
> Yes, but only those which are defined in the pom of your project, not
> inside
> the poms of dependencies referenced by your project.
>
> It just updates the text of the pom file, which cannot be done easily
> with
> released poms from some maven repository. After all, that's why we have
> releases first hand: to count on the released artifacts as
> unmodifiable.
>
> To manage transitive dependencies, enable dependency convergence using
> maven-enforcer-plugin. You will be notified about version clashes
> between
> different versions of the same transitive dependency. To remove these
> clashes, define <exclusions> for those transitive dependencies you
> don't
> want in your classpath.

Can you elaborate on this, please?  As I've seen in many cases, the plugin documentation is very rudimentary.

It looks to me like we would need to specify "enforcer:enforce", but how do I know what this is going to do?

> >
> > Does the "versions" plugin work with maven 3.x?
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does the "versions" plugin deal with transitive references to two different versions of an artifact?

Ron Wheeler

Doesn't your IDE let you know when there is a conflict in the transitive
dependencies?
I believe that Eclipse STS does that for us.
Much simpler than using a plug-in, finds it earlier in the process and
avoids adding more stuff to your POM.

When Eclipse finds one, we fix conflicts for 3rd party things like
commons-lang by excluding it from every direct dependency that tries to
drag a version in and providing a library with the one that we want.
http://blog.artifact-software.com/tech/?p=121

Lots of other advantages but avoids the mystery of which commons-lang
actually gets loaded at run-time.

Ron

On 28/10/2011 5:04 PM, KARR, DAVID wrote:

>> -----Original Message-----
>> From: Ansgar Konermann [mailto:[hidden email]]
>> Sent: Friday, October 28, 2011 12:15 PM
>> To: Maven Users List
>> Subject: Re: Does the "versions" plugin deal with transitive references
>> to two different versions of an artifact?
>>
>> Am 28.10.2011 20:07 schrieb "KARR, DAVID"<[hidden email]>:
>>> If I have a build with a lot of modules, and I end up with two
>> transitive
>> dependency references to "commons-lang", one for version 2.2, and one
>> for
>> version 2.4, does the "versions" plugin let me define rules that will
>> let me
>> choose either the older or newer version to actually use?
>>
>> The versions plugin deals with direct dependencies, not transitive
>> ones.
>>
>>>  From the documentation, I would think that "versions:use-latest-
>> versions"
>> comes close, but the documentation is vague.  It just says "Replaces
>> any
>> version with the latest version."
>>
>> Yes, but only those which are defined in the pom of your project, not
>> inside
>> the poms of dependencies referenced by your project.
>>
>> It just updates the text of the pom file, which cannot be done easily
>> with
>> released poms from some maven repository. After all, that's why we have
>> releases first hand: to count on the released artifacts as
>> unmodifiable.
>>
>> To manage transitive dependencies, enable dependency convergence using
>> maven-enforcer-plugin. You will be notified about version clashes
>> between
>> different versions of the same transitive dependency. To remove these
>> clashes, define<exclusions>  for those transitive dependencies you
>> don't
>> want in your classpath.
> Can you elaborate on this, please?  As I've seen in many cases, the plugin documentation is very rudimentary.
>
> It looks to me like we would need to specify "enforcer:enforce", but how do I know what this is going to do?

>
>>> Does the "versions" plugin work with maven 3.x?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Ron Wheeler
President
Artifact Software Inc
email: [hidden email]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does the "versions" plugin deal with transitive references to two different versions of an artifact?

Ansgar Konermann
Hi Ron,

Am 28.10.2011 23:39, schrieb Ron Wheeler:
> Doesn't your IDE let you know when there is a conflict in the
> transitive dependencies?
Depends on your IDE. E. g. IntelliJ IDEA by default does not.
> I believe that Eclipse STS does that for us.
Never used Eclipse STS, can't judge.
> Much simpler than using a plug-in, finds it earlier in the process and
> avoids adding more stuff to your POM.
While it's certainly nice if version clashes are found early in the
process, but your suggested solution assumes everyone working on the
project uses one particular IDE, which might not always be the case.

When using the enforcer plugin, you can reliably prevent version clashes
on your CI server as part of a normal CI build. During normal
development mode, I tend to fire a remote run on our CI server every 5
to 20 minutes. This is sufficiently "early" in the process for me.

If your POM gets "too long", think about pulling common parts into a
common parent POM and inherit plugin configuration into your actual
projects, so your actual module POMs only contain the configuration bits
which are actually specific to your module. I tend to get along with
only coordinates, SCM and some dependencies in my module POMs. Although
the POMs remain written in XML and you might still find XML verbose,
this step can remove a significant amount of noise from your POMs.

Best regards

Ansgar

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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does the "versions" plugin deal with transitive references to two different versions of an artifact?

Ansgar Konermann
In reply to this post by David M. Karr
Am 28.10.2011 23:04, schrieb KARR, DAVID:

>> -----Original Message-----
>> From: Ansgar Konermann [mailto:[hidden email]]
>> Sent: Friday, October 28, 2011 12:15 PM
>> To: Maven Users List
>> Subject: Re: Does the "versions" plugin deal with transitive references
>> to two different versions of an artifact?
>>
>> Am 28.10.2011 20:07 schrieb "KARR, DAVID" <[hidden email]>:
>>> If I have a build with a lot of modules, and I end up with two
>> transitive
>> dependency references to "commons-lang", one for version 2.2, and one
>> for
>> version 2.4, does the "versions" plugin let me define rules that will
>> let me
>> choose either the older or newer version to actually use?
>>
>> The versions plugin deals with direct dependencies, not transitive
>> ones.
>>
>>> From the documentation, I would think that "versions:use-latest-
>> versions"
>> comes close, but the documentation is vague.  It just says "Replaces
>> any
>> version with the latest version."
>>
>> Yes, but only those which are defined in the pom of your project, not
>> inside
>> the poms of dependencies referenced by your project.
>>
>> It just updates the text of the pom file, which cannot be done easily
>> with
>> released poms from some maven repository. After all, that's why we have
>> releases first hand: to count on the released artifacts as
>> unmodifiable.
>>
>> To manage transitive dependencies, enable dependency convergence using
>> maven-enforcer-plugin. You will be notified about version clashes
>> between
>> different versions of the same transitive dependency. To remove these
>> clashes, define <exclusions> for those transitive dependencies you
>> don't
>> want in your classpath.

Hi David,

> Can you elaborate on this, please?

Sure, you're welcome.

>   As I've seen in many cases, the plugin documentation is very rudimentary.

Sorry, but I really can't buy that. To me, the plugin documentation is a
perfect 10: http://maven.apache.org/plugins/maven-enforcer-plugin/

Of course, as maven is basically more a plugin execution engine than a
build tool, you will need some basic maven knowledge, specifically what
a plugin is, and how to configure it. This information is *not*
reproduced in the documentation of each and every plugin, so you should
familiarize yourself with the basic mechanisms before diving into the
(terse) plugin documentation. Some resources:

Online book. "Maven: The Complete Reference". If you have some time to
kill, it's advisable to read it at least up to and including chapter 9
"Properties and resource filtering":
http://www.sonatype.com/books/mvnref-book/reference/

Considering your problem at hand, I'd suggest to pay special attention
to section 1.4 ...
http://www.sonatype.com/books/mvnref-book/reference/installation-sect-universal-reuse.html

and to chapter 7: "How to configure maven plugins:"
http://www.sonatype.com/books/mvnref-book/reference/_configuring_maven_plugins.html

> It looks to me like we would need to specify "enforcer:enforce", but how do I know what this is going to do?

Read the introduction (what is this plugin all about):
http://maven.apache.org/plugins/maven-enforcer-plugin/index.html

Have a look at the sample configuration and put a version tailored to
your needs into your project's pom:
http://maven.apache.org/plugins/maven-enforcer-plugin/usage.html

If you'd like to know more about the available rules which the enforcer
plugin can enforce, this list might help:
http://maven.apache.org/enforcer/enforcer-rules/index.html

As a side note: these pages are what you get when you click link one,
three and five in the main, top-left navigation of the plugin's homepage
(below "Overview"). The homepage can easily be found by googling "maven
enforcer plugin" (it's the first link actually). I'd like to know where
exactly in the process you were unable to find this information or make
sense of the information you might have found, so that the plugin
maintainers can improve presence of this information in search engines
or the documentation itself.

The actual rule you need to configure is documented here:
http://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html

Best regards

Ansgar



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

Loading...