You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "KARR, DAVID" <dk...@att.com> on 2014/01/14 01:24:14 UTC

Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

I have a situation where it would be convenient for my pom to have two dependencies that are almost identical, only being different by the version.  The makeup of the artifact is such that it would be safe (and intended) to use both of them.  The Java package used in each is similar, but different.  The package will vary along with the version number.

Will dependency resolution and the EAR plugin (and any other mechanism that lists dependencies) have any trouble with this?

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


Re: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Stephen Connolly <st...@gmail.com>.
I like to consider a G:A as being substitutable along the V access... if
you change the artifact so that it is not substitutable, then you really
need to change the G:A part.

Now substitutable does not mean no breaking API changes... it does mean
that the package name and at least some of the class names are the same.

So a good case in point here is Jackson the JSON serialization library...

There are many versions of Jackson, but when a major breaking change to the
API was required Tatu changed from org.codehaus.jackson:jackson-core-asl to
com.fasterxml.jackson.core:jackson-core and also changed the package name
of the classes.

This was the correct thing to do, IMHO.

They maintained 82 releases of the API without having to refactor in a
breaking way.

The changes that they needed would break the API, leaving no way for
existing code to inter-op

As a result, by changing package name and G:A the two versions can
co-exist...

Now let us consider some other ways that Tatu & Co could have handled this:

* They could have kept the package name the same and changed the G:A. That
would mean that classes in the package name would not be coming from the
same jar file, and so with a security manager enabled the "same jar origin
policy" would mean that at run time you end up getting class conflicts all
over the place as different classloaders resolve the package name from
different jar files depending on which class they reference first and the
order of the jars in the classpath... sounds a lot like hell... let's scrap
that plan

* They could have changed the package name and kept the G:A. That would
mean that any fool* using version ranges could now find that their code
fails to compile. (*only a fool uses version ranges)... that is self
inflicted hell... also dependencyManagement will overrule versions so if
somebody uses a dependencyManagement to force a version that will force a
single version even though the classpath *should* have two versions... plus
how Maven resolves the dependency tree means that it assumes that for any
G:A varying the V gives you substitutable artifacts (and if they don't work
then either `compile` or `test/verify` will fail the build so that's ok)

So the rule of thumb I use is:

* every time you change the package name, change the G:A

* if you are making breaking API changes that are not substitutable, change
the package name


# aside

Is there a use case for dependencies of the same GA but different V?

I think there may be, at least when dealing with non-java resources... and
Java 9 / OSGi provides a use case also.

For example, you may have a legitimate (if crappy) reason to include two
versions of jQuery in your web application... one set of pages may use the
older one during a transition for example.

So in modelVersion 5.0.0, I do think that we should investigate a means of
flagging that certain types of dependency collection require a single
unique version resolved for each GA dependency, while other types of
dependency collection require the set of versions for each GA dependency




On 14 January 2014 00:24, KARR, DAVID <dk...@att.com> wrote:

> I have a situation where it would be convenient for my pom to have two
> dependencies that are almost identical, only being different by the
> version.  The makeup of the artifact is such that it would be safe (and
> intended) to use both of them.  The Java package used in each is similar,
> but different.  The package will vary along with the version number.
>
> Will dependency resolution and the EAR plugin (and any other mechanism
> that lists dependencies) have any trouble with this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Wayne Fay <wa...@gmail.com>.
> I haven't heard anyone confirm conclusively that this will not work, so up
> to now it appears to just be an opinion that there's something wrong with
> this approach.

Let me make it perfectly clear for you then:
This will not work. Maven will resolve both dependencies with the same
GA and different Vs into a single GAV.

Wayne

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


RE: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com]
> Sent: Tuesday, January 14, 2014 3:10 PM
> To: Maven Users List
> Subject: Re: Is it possible to deliberately have two dependencies with the
> same groupid, artifactid, and packaging, but different version?
> 
> On 14 January 2014 22:49, KARR, DAVID <dk...@att.com> wrote:
> 
> > > -----Original Message-----
> > > From: Barrie Treloar [mailto:baerrach@gmail.com]
> > > Sent: Tuesday, January 14, 2014 2:23 PM
> > > To: Maven Users List
> > > Subject: Re: Is it possible to deliberately have two dependencies with
> > the
> > > same groupid, artifactid, and packaging, but different version?
> > >
> > > On 15 January 2014 01:40, KARR, DAVID <dk...@att.com> wrote:
> > > > Again, I didn't want to debate whether this is "convenient", I just
> > wanted
> > > to know if Maven dependency resolution and things like the EAR plugin
> > will
> > > have any trouble incorporating multiple dependencies with the same G:A,
> > but
> > > different version.
> > >
> > > David, you've been on the list long enough to see the term "If you
> > > fight Maven you will lose".
> > > That way pain lies.
> >
> > I haven't heard anyone confirm conclusively that this will not work, so up
> > to now it appears to just be an opinion that there's something wrong with
> > this approach.
> >
> 
> Perhaps I just wasn't clear enough...
> 
> Maven will resolve any list of dependencies so that there is a single
> unique version of any GA.
> 
> Where you have a maven does not bomb out when you double list a dependency,
> you will get a single version.
> 
> The correct parsing behaviour that Maven *should* follow is:
> 
> * If the double dependency is in a project *being built* then fail the build
> 
> * If the double dependency is in a dependency of the project being built,
> then resolve to single version.
> 
> AFAIK the only unknown I am aware of is whether the first case applies, but
> in all cases that I am aware of you will only see one version of any GA

Ok, thanks for clarifying.

I guess I'll plan on putting the version number into the artifact id string so the G:A will vary.
 
> > I've also been writing software long enough to know that reality often
> > makes theory irrelevant.
> >
> > > You will have much more joy solving the problem in a way that Maven helps
> > > you.
> > >
> > > Does any of Stephen's response help out?
> >
> > I believe that's a different situation.
> >
> > There will be a new version of this artifact every single month such that
> > multiple versions of the same artifact can and will be used at the same
> > time (very soon we will be using 6 at the same time).  It doesn't make
> > sense to me to define a new group id or artifact id every month,
> > considering the only difference between two names (and their contents) will
> > simply be a number, representing its version number.  If the only
> > difference is the version, then it should be reflected in the version
> > number, as that's the primary difference between them.
> >
> >
> > ---------------------------------------------------------------------
> > 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: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Stephen Connolly <st...@gmail.com>.
On 14 January 2014 22:49, KARR, DAVID <dk...@att.com> wrote:

> > -----Original Message-----
> > From: Barrie Treloar [mailto:baerrach@gmail.com]
> > Sent: Tuesday, January 14, 2014 2:23 PM
> > To: Maven Users List
> > Subject: Re: Is it possible to deliberately have two dependencies with
> the
> > same groupid, artifactid, and packaging, but different version?
> >
> > On 15 January 2014 01:40, KARR, DAVID <dk...@att.com> wrote:
> > > Again, I didn't want to debate whether this is "convenient", I just
> wanted
> > to know if Maven dependency resolution and things like the EAR plugin
> will
> > have any trouble incorporating multiple dependencies with the same G:A,
> but
> > different version.
> >
> > David, you've been on the list long enough to see the term "If you
> > fight Maven you will lose".
> > That way pain lies.
>
> I haven't heard anyone confirm conclusively that this will not work, so up
> to now it appears to just be an opinion that there's something wrong with
> this approach.
>

Perhaps I just wasn't clear enough...

Maven will resolve any list of dependencies so that there is a single
unique version of any GA.

Where you have a maven does not bomb out when you double list a dependency,
you will get a single version.

The correct parsing behaviour that Maven *should* follow is:

* If the double dependency is in a project *being built* then fail the build

* If the double dependency is in a dependency of the project being built,
then resolve to single version.

AFAIK the only unknown I am aware of is whether the first case applies, but
in all cases that I am aware of you will only see one version of any GA


> I've also been writing software long enough to know that reality often
> makes theory irrelevant.
>
> > You will have much more joy solving the problem in a way that Maven helps
> > you.
> >
> > Does any of Stephen's response help out?
>
> I believe that's a different situation.
>
> There will be a new version of this artifact every single month such that
> multiple versions of the same artifact can and will be used at the same
> time (very soon we will be using 6 at the same time).  It doesn't make
> sense to me to define a new group id or artifact id every month,
> considering the only difference between two names (and their contents) will
> simply be a number, representing its version number.  If the only
> difference is the version, then it should be reflected in the version
> number, as that's the primary difference between them.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Barrie Treloar [mailto:baerrach@gmail.com]
> Sent: Tuesday, January 14, 2014 2:23 PM
> To: Maven Users List
> Subject: Re: Is it possible to deliberately have two dependencies with the
> same groupid, artifactid, and packaging, but different version?
> 
> On 15 January 2014 01:40, KARR, DAVID <dk...@att.com> wrote:
> > Again, I didn't want to debate whether this is "convenient", I just wanted
> to know if Maven dependency resolution and things like the EAR plugin will
> have any trouble incorporating multiple dependencies with the same G:A, but
> different version.
> 
> David, you've been on the list long enough to see the term "If you
> fight Maven you will lose".
> That way pain lies.

I haven't heard anyone confirm conclusively that this will not work, so up to now it appears to just be an opinion that there's something wrong with this approach.

I've also been writing software long enough to know that reality often makes theory irrelevant.

> You will have much more joy solving the problem in a way that Maven helps
> you.
> 
> Does any of Stephen's response help out?

I believe that's a different situation.

There will be a new version of this artifact every single month such that multiple versions of the same artifact can and will be used at the same time (very soon we will be using 6 at the same time).  It doesn't make sense to me to define a new group id or artifact id every month, considering the only difference between two names (and their contents) will simply be a number, representing its version number.  If the only difference is the version, then it should be reflected in the version number, as that's the primary difference between them.


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


Re: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Barrie Treloar <ba...@gmail.com>.
On 15 January 2014 01:40, KARR, DAVID <dk...@att.com> wrote:
> Again, I didn't want to debate whether this is "convenient", I just wanted to know if Maven dependency resolution and things like the EAR plugin will have any trouble incorporating multiple dependencies with the same G:A, but different version.

David, you've been on the list long enough to see the term "If you
fight Maven you will lose".
That way pain lies.

You will have much more joy solving the problem in a way that Maven helps you.

Does any of Stephen's response help out?

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


Re: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi David,

> Again, I didn't want to debate whether this is "convenient", I just
> wanted to know if Maven dependency resolution and things like the EAR
> plugin will have any trouble incorporating multiple dependencies with
> the same G:A, but different version.

I haven't tried it, but personally I would be shocked if Maven allowed this
at all. Did you try it? Does it work?

IMO, the major reason for versions is so that Maven (and humans) knows to
select one from a set. If you need more than one at the same time, change
the value of A.

Including multiple versions of the same artifact violates Maven's current
assumptions rather severely.

Regards,
Curtis


On Tue, Jan 14, 2014 at 9:10 AM, KARR, DAVID <dk...@att.com> wrote:

> > -----Original Message-----
> > From: Barrie Treloar [mailto:baerrach@gmail.com]
> > Sent: Monday, January 13, 2014 4:48 PM
> > To: Maven Users List
> > Subject: Re: Is it possible to deliberately have two dependencies with
> the
> > same groupid, artifactid, and packaging, but different version?
> >
> > On 14 January 2014 10:54, KARR, DAVID <dk...@att.com> wrote:
> > > I have a situation where it would be convenient for my pom to have two
> > dependencies that are almost identical, only being different by the
> version.
> > The makeup of the artifact is such that it would be safe (and intended)
> to
> > use both of them.  The Java package used in each is similar, but
> different.
> > The package will vary along with the version number.
> > >
> > > Will dependency resolution and the EAR plugin (and any other mechanism
> that
> > lists dependencies) have any trouble with this?
> >
> > Can you describe why you think this would be convenient?
> > Have you looked at classifiers?
> > http://stackoverflow.com/questions/8040964/how-to-use-or-abuse-artifact-
> > classifiers-in-maven
>
> A new version of this artifact is produced perhaps once a month.  Perhaps
> 2-3 versions of this artifact will be referenced in the client code base at
> one time.  More versions than that are supported in the server code base,
> throughout all environments.  The only difference in the reported name of
> this artifact from one version to the next is the version number.
>
> Again, I didn't want to debate whether this is "convenient", I just wanted
> to know if Maven dependency resolution and things like the EAR plugin will
> have any trouble incorporating multiple dependencies with the same G:A, but
> different version.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Barrie Treloar [mailto:baerrach@gmail.com]
> Sent: Monday, January 13, 2014 4:48 PM
> To: Maven Users List
> Subject: Re: Is it possible to deliberately have two dependencies with the
> same groupid, artifactid, and packaging, but different version?
> 
> On 14 January 2014 10:54, KARR, DAVID <dk...@att.com> wrote:
> > I have a situation where it would be convenient for my pom to have two
> dependencies that are almost identical, only being different by the version.
> The makeup of the artifact is such that it would be safe (and intended) to
> use both of them.  The Java package used in each is similar, but different.
> The package will vary along with the version number.
> >
> > Will dependency resolution and the EAR plugin (and any other mechanism that
> lists dependencies) have any trouble with this?
> 
> Can you describe why you think this would be convenient?
> Have you looked at classifiers?
> http://stackoverflow.com/questions/8040964/how-to-use-or-abuse-artifact-
> classifiers-in-maven

A new version of this artifact is produced perhaps once a month.  Perhaps 2-3 versions of this artifact will be referenced in the client code base at one time.  More versions than that are supported in the server code base, throughout all environments.  The only difference in the reported name of this artifact from one version to the next is the version number.

Again, I didn't want to debate whether this is "convenient", I just wanted to know if Maven dependency resolution and things like the EAR plugin will have any trouble incorporating multiple dependencies with the same G:A, but different version.


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


Re: Is it possible to deliberately have two dependencies with the same groupid, artifactid, and packaging, but different version?

Posted by Barrie Treloar <ba...@gmail.com>.
On 14 January 2014 10:54, KARR, DAVID <dk...@att.com> wrote:
> I have a situation where it would be convenient for my pom to have two dependencies that are almost identical, only being different by the version.  The makeup of the artifact is such that it would be safe (and intended) to use both of them.  The Java package used in each is similar, but different.  The package will vary along with the version number.
>
> Will dependency resolution and the EAR plugin (and any other mechanism that lists dependencies) have any trouble with this?

Can you describe why you think this would be convenient?
Have you looked at classifiers?
http://stackoverflow.com/questions/8040964/how-to-use-or-abuse-artifact-classifiers-in-maven

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