You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by Michal Maczka <mm...@interia.pl> on 2004/06/20 14:20:32 UTC

Re: cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact AbstractMavenArtifact.java

On Sun, 2004-06-20 at 04:05, Trygve Laugstøl wrote:
> On Sun, Jun 20, 2004 at 11:45:52AM +1000, Dion Gillard wrote:
> > On Sat, 19 Jun 2004 21:40:09 -0400, Trygve Laugstøl <tr...@apache.org> wrote:
> > > 
> > > The id of a artifact/dependency is
> > > 
> > >  <groupId>:<artifactId>:<type>
> > > 
> > > so I guess the version should be removed from the hashCode() then?
> > 
> > I think version should be part of the uniqeness of an artifact. If I
> > have two artifacts, e.g.
> > 
> > apache:struts:jar:1.0 and apache:struts:jar:2.0, they're definitely
> > not 'equal', right?
> 
it's not so clear as it seems. 

For example when Artifact collector is working it needs to use
<groupId>:<artifactId>:<type> as id for finding conflicts,

When I have two artifacts of the same id but different version - I know
that conflict has been found. 

As I see it now for some other functions we will 
need to use "short" version of  id: <groupId>:<artifactId>:<type>

and for some others "long" version:
<groupId>:<artifactId>:<type>:<version>.

The thing is that at the moment much more often 
we need to use "short id" and "long id" can be easly generated from
"short id" but reverse is not so easy to achieve in a clean way.

Maybe in fact we can have two methods in Dependency:

getShortId()  and getLongId()


So dIon - yes you are right that apache:struts:jar:1.0 and
apache:struts:jar:2.0 are two different artifacts but it seems to me
that for our internal needs we more often have to put them into the same
bucket.




> You are right, the version will be added to Dependency.getId() in the
> model.

This can have many side effects of existing code. I am almost sure it
will break ArtifactCollector.
> 
> I'll let the hashCode() be as it is for now and we'll add version to the
> id ASAP


Michal



Re: cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact AbstractMavenArtifact.java

Posted by Gilles Dodinet <rh...@free.fr>.
Michal Maczka wrote:

>For example when Artifact collector is working it needs to use
><groupId>:<artifactId>:<type> as id for finding conflicts,
>
>When I have two artifacts of the same id but different version - I know
>that conflict has been found. 
>
>As I see it now for some other functions we will 
>need to use "short" version of  id: <groupId>:<artifactId>:<type>
>
>and for some others "long" version:
><groupId>:<artifactId>:<type>:<version>.
>
>The thing is that at the moment much more often 
>we need to use "short id" and "long id" can be easly generated from
>"short id" but reverse is not so easy to achieve in a clean way.
>
>Maybe in fact we can have two methods in Dependency:
>
>getShortId()  and getLongId()
>
>
>So dIon - yes you are right that apache:struts:jar:1.0 and
>apache:struts:jar:2.0 are two different artifacts but it seems to me
>that for our internal needs we more often have to put them into the same
>bucket.
>  
>
Glad to see this appears in m2. Indeed such comparison methods are 
really needed for integration, and in mevenide we use
util classes to support the exact scheme michal described. equals, 
relaxEquals and strictEquals method names make sense to me where
equals could delegate to relaxEquals or strictEquals. In addition it 
would be very nice if there were a #conflict(AbstractMavenArtifact) method.

Related i have a question about jar override. to specify override we now 
use maven.jar.<artifactId>, however what if same artifactId is shared by 
two
different artifacts, that have either the same groupId (only the type 
differs) or a completly different groupId (maybe same type) ?

-- gd