You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by boraldo <bo...@mail.ru> on 2011/07/28 13:39:30 UTC

How to use the latest version from dependencies (not from all repository)

Suppose I have the following artifacts. I will omit groups for simplicity.

A:1.0
A:2.0
A:3.0
B:1.0 depends on A:1.0
C:1.0 depends on A:2.0
D:1.0 depends on B:1.0, C:1.0

I want D to use the latest version of A that is inherited from it's
dependencies (not from repository). In this case it is 2.0.

How can I make this with Maven 2 or Maven 3?

--
View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4642240.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: How to use the latest version from dependencies (not from all repository)

Posted by boraldo <bo...@mail.ru>.
I don't like to use version ranges and I agree that it is evil.
This is just example that it is possible.

I just want to use the latest version from full dependency tree. This is
absolutely reproducable. Do you agree with that?
Now I set version of A in D each time some middle artifact is changed.
I have a great library tree and when some middle library starts to depend on
new version of A I set also this version in D.
Absolutely always in D I set the latest version from full dependency tree. 
Do you have the experience where this wasn't the case for your library
trees?

So, I want this to be done automatically..
If I need to know version of A that will be used, I can always do it by
dependency:list or dependency:tree.
What is the problem with that workflow?

--
View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4673465.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: How to use the latest version from dependencies (not from all repository)

Posted by Baptiste MATHUS <ml...@batmat.net>.
2011/8/6 Ron Wheeler <rw...@artifact-software.com>

> On 06/08/2011 11:47 AM, boraldo wrote:
>
>> I am absolutely agree with your opinion that unreproducability of build is
>> a
>> bad feature, but ...
>>
>> 1. Maven has a built-in mechanism of dependency version range
>> (http://docs.codehaus.org/**display/MAVEN/Dependency+**
>> Mediation+and+Conflict+**Resolution#**DependencyMediationandConflict**
>> Resolution-**DependencyVersionRanges<http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges>
>> ).
>> Using this you can set that the build will always include the last version
>> of some artifact. That makes it absolutely unreproducable. So
>> unreproducability doesn't contradict with the concepts of Maven and what I
>> ask could be possible in it too.
>>
> Just because Maven can do something does not make it a good idea.
> Maven will give you enough rope to hang yourself and there enough really
> brilliant people here who can show you how to make the killer knot, so that
> it is easy to get hurt.
> Just read some of the threads on version range or worse yet - profiles if
> you want to see people getting into serious trouble.


+1. Version ranges is evil.
Maven is designed to help you ensure build reproducibility.

Using undefined versions is exactly the opposite.

Bump your versions regularly, script it if you like, but don't use version
ranges.

Cheers.

-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !
nbsp;!

Re: How to use the latest version from dependencies (not from all repository)

Posted by Baptiste MATHUS <ml...@batmat.net>.
2011/8/6 Ron Wheeler <rw...@artifact-software.com>

> On 06/08/2011 12:53 PM, Eric Kolotyluk wrote:
>
>> I love it :-)
>>
>> I keep seeing some of the most clever insightful statements from the
>> people of this list.
>>
>>  Less the voice of insight and more of bitter experience.
> We all got the same amount of rope at the start. It just takes a while to
> appreciate the dangers involved.
>

I feel "bitter experience" is a just a longer word for "experience".
Experience is, in my opinion, mainly built doing mistakes.

Cheers

-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !
nbsp;!

Re: How to use the latest version from dependencies (not from all repository)

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 06/08/2011 12:53 PM, Eric Kolotyluk wrote:
> I love it :-)
>
> I keep seeing some of the most clever insightful statements from the 
> people of this list.
>
Less the voice of insight and more of bitter experience.
We all got the same amount of rope at the start. It just takes a while 
to appreciate the dangers involved.
>
> I made a killer knot that took months before it manifest, and took me 
> over a week to finally figure out - but was not related to version stuff.
>
> Cheers, Eric
>
> On 2011-08-06 9:29 AM, Ron Wheeler wrote:
>> Maven will give you enough rope to hang yourself and there enough 
>> really brilliant people here who can show you how to make the killer 
>> knot, so that it is easy to get hurt. 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


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


Re: How to use the latest version from dependencies (not from all repository)

Posted by Eric Kolotyluk <er...@gmail.com>.
I love it :-)

I keep seeing some of the most clever insightful statements from the 
people of this list.

I made a killer knot that took months before it manifest, and took me 
over a week to finally figure out - but was not related to version stuff.

Cheers, Eric

On 2011-08-06 9:29 AM, Ron Wheeler wrote:
> Maven will give you enough rope to hang yourself and there enough 
> really brilliant people here who can show you how to make the killer 
> knot, so that it is easy to get hurt. 

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


Re: How to use the latest version from dependencies (not from all repository)

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 06/08/2011 11:47 AM, boraldo wrote:
> I am absolutely agree with your opinion that unreproducability of build is a
> bad feature, but ...
>
> 1. Maven has a built-in mechanism of dependency version range
> (http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges).
> Using this you can set that the build will always include the last version
> of some artifact. That makes it absolutely unreproducable. So
> unreproducability doesn't contradict with the concepts of Maven and what I
> ask could be possible in it too.
Just because Maven can do something does not make it a good idea.
Maven will give you enough rope to hang yourself and there enough really 
brilliant people here who can show you how to make the killer knot, so 
that it is easy to get hurt.
Just read some of the threads on version range or worse yet - profiles 
if you want to see people getting into serious trouble.

>
> 2. What I want is absolutely reproducable. Maybe you didn't understand me.
> I want an artifact D to include last version of artifact A, but not among
> all versions of A but among versions that are present in D's full dependency
> tree. As dependency tree is not changed in time we get a reproducable build.
> At each moment of time (if artifacts from dependency tree are not changed)
> final D's build will include the same version of A.
> Moreover, what I want, I suppose, is much more reproducable and logical
> behaviour because using standard behaviour you depend very strongly on the
> order in which dependencies are declared.
My preference is to control the versions of anything that gets built 
into my projects.
Classloaders will only load the first version of a library requested and 
if you include 2 versions of a library in a set of jars that you make 
available at run-time, you can have some unpleasant and random surprises 
- MethodNotFound being the most likely cause of a stack dump.

It is worthwhile to do the planning up front and make sure that you know 
what version your builds include and which artifact is going to provide 
each of the third party libraries that you need.
An hour at the start of each development cycle is not a high price to 
pay for peace of mind.
It takes a bit of thinking to get your POMs set up correctly initially 
but it pays off.
Your builds also take less time and your artifacts are smaller since you 
will have many modules with a lot of their libraries getting scoped as 
"provided" rather than included in the artifact.

>
> --
> View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4672834.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


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


Re: How to use the latest version from dependencies (not from all repository)

Posted by boraldo <bo...@mail.ru>.
I am absolutely agree with your opinion that unreproducability of build is a
bad feature, but ...

1. Maven has a built-in mechanism of dependency version range
(http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges).
Using this you can set that the build will always include the last version
of some artifact. That makes it absolutely unreproducable. So
unreproducability doesn't contradict with the concepts of Maven and what I
ask could be possible in it too. 

2. What I want is absolutely reproducable. Maybe you didn't understand me.
I want an artifact D to include last version of artifact A, but not among
all versions of A but among versions that are present in D's full dependency
tree. As dependency tree is not changed in time we get a reproducable build.
At each moment of time (if artifacts from dependency tree are not changed)
final D's build will include the same version of A.
Moreover, what I want, I suppose, is much more reproducable and logical
behaviour because using standard behaviour you depend very strongly on the
order in which dependencies are declared.

--
View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4672834.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: How to use the latest version from dependencies (not from all repository)

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 30/07/2011 7:16 AM, boraldo wrote:
> I don't need to make maven use A version that is inherited from C exactly.
> I want Maven to define the latest version automatically, without explicit
> definition.
Not a good idea. You want a repeatable build with a specific version of 
A so you know what you are running.
> And I don't want to release new version of B only to fix it's A version.
> A:1.0 is suitable for B, so there's no need to change it.
> In real life I have a lot of artifacts. Some of them are stable and I don't
> want to update all them once new version of some middle artifact is changed.
It is worth the effort to decide what version of things you are using.
Having maven pick the latest version when you have not tested your 
software with that version is a recipe for long and painful debugging 
session that are surprises to everyone involved.
We use 70+ third party libraries to build our application comprised of 
over 80 maven projects and every dependency is specified.

We do not upgrade to a new version of anything unless everyone is aware 
of the change and someone reads the release notes to verify upward 
compatibility and tests the new version with our software.

This makes individual developers confident that what they tested 
yesterday was only broken by what they did today not some random fix 
applied by a stranger to some library that they did not know was a 
dependency of a dependency.

It takes an hour or so to plan a new release and every now and again a 
developer asks for a version upgrade in the middle of a development 
cycle which creates a min-project to verify that the new version does 
not break anything that we have done.
That is a lot less than the time lost by a surprise update of a 
dependency by an Apache project or some other third party that breaks 
your code.

There is a good reason why dependencies have versions.

You may think that we are just too lazy to live on the edge but we have 
learned that it is better to plan than debug.


Ron

>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4649537.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


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


Re: How to use the latest version from dependencies (not from all repository)

Posted by boraldo <bo...@mail.ru>.
I don't need to make maven use A version that is inherited from C exactly.
I want Maven to define the latest version automatically, without explicit
definition.

And I don't want to release new version of B only to fix it's A version.
A:1.0 is suitable for B, so there's no need to change it.
In real life I have a lot of artifacts. Some of them are stable and I don't
want to update all them once new version of some middle artifact is changed.



--
View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4649537.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: How to use the latest version from dependencies (not from all repository)

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 28/07/2011 7:39 AM, boraldo wrote:
> Suppose I have the following artifacts. I will omit groups for simplicity.
>
> A:1.0
> A:2.0
> A:3.0
> B:1.0 depends on A:1.0
> C:1.0 depends on A:2.0
> D:1.0 depends on B:1.0, C:1.0
>
> I want D to use the latest version of A that is inherited from it's
> dependencies (not from repository). In this case it is 2.0.
>
> How can I make this with Maven 2 or Maven 3?
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/How-to-use-the-latest-version-from-dependencies-not-from-all-repository-tp4642240p4642240.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Either do nothing and let Maven figure it out or in D's dependency on B 
exclude A since you are going to get it from C anyway.

If you can fix B to depend on A:2.0 that would be best since you are 
going to force it to use A:2.0 anyway, you might as well update it, if 
you can.

Ron

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