You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Nigel Magnay <ni...@gmail.com> on 2005/11/14 10:23:31 UTC

[m2] dependency ordering

Hi -

I'm doing some processing with a custom mojo that relies on the
dependency information to build an artifact, but the order of
processing is important. Because MavenProject.getArtifacts() returns a
set, this is unordered with respect to the pom.xml; I was wondering if
it's possible to add extra information in the pom, something like

...>
<dependency>
      <groupId>blah</groupId>
      <artifactId>thing</artifactId>
      <version>3.8.1</version>
<order>1</order>  <------------------
    </dependency>
<dependency>
      <groupId>woo</groupId>
      <artifactId>yay</artifactId>
      <version>3</version>
       <order>2</order>  <------------------
    </dependency>
<...

Is there a good way of tackling this?

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


Re: [m2] dependency ordering

Posted by Mark Hobson <ma...@gmail.com>.
On 14/11/05, Brett Porter <br...@gmail.com> wrote:
> But how does that help in the situation where you declare dependencies
> A and B, but both declare a dependency C at the same level? Is C
> first, second or third when ordered?
>
> I haven't looked at this issue, but an application should avoid
> classpath ordering at all costs.

I agree classpath ordering is not ideal, but I think an order should
be enforced so that mvn is deterministic.  The real-life scenario I
was encountering was a same-named resource being loaded from one
dependency jar rather than the intended dependency jar.

Mark

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


Re: [m2] dependency ordering

Posted by Brett Porter <br...@gmail.com>.
But how does that help in the situation where you declare dependencies
A and B, but both declare a dependency C at the same level? Is C
first, second or third when ordered?

I haven't looked at this issue, but an application should avoid
classpath ordering at all costs.

- Brett

On 11/14/05, Mark Hobson <ma...@gmail.com> wrote:
> This discussion kinda overlaps with an issue I raised with the eclipse plugin:
>
> http://jira.codehaus.org/browse/MNG-1412
>
> I think the order should be nearest first, and then the order
> specified in the pom.
>
> Mark
>
> On 14/11/05, Nigel Magnay <ni...@gmail.com> wrote:
> > The artifact being generated is effectively a merge of several other
> > artifacts of the same type  - a WAR file. It's important to get the
> > ordering right as the overwriting precidence matters.
> >
> > I was just thinking of needing an extra bit of user data, much like
> > the properties you could put on dependencies in M1 that controlled
> > things like whether the file got included in the manifest or not; a
> > 'proper' ordering of all dependencies does sound harder (and maybe too
> > hard to be always right in all circumstances..)
> >
> > On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> > > Can you describe what the relevance of the ordering is? There might be
> > > something already available.
> > >
> > > The suggestion of this tag is tricky, as how does dependencies brought
> > > in transitively get ordered?
> > >
> > > - Brett
> > >
> > > On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > > > Hi -
> > > >
> > > > I'm doing some processing with a custom mojo that relies on the
> > > > dependency information to build an artifact, but the order of
> > > > processing is important. Because MavenProject.getArtifacts() returns a
> > > > set, this is unordered with respect to the pom.xml; I was wondering if
> > > > it's possible to add extra information in the pom, something like
> > > >
> > > > ...>
> > > > <dependency>
> > > >       <groupId>blah</groupId>
> > > >       <artifactId>thing</artifactId>
> > > >       <version>3.8.1</version>
> > > > <order>1</order>  <------------------
> > > >     </dependency>
> > > > <dependency>
> > > >       <groupId>woo</groupId>
> > > >       <artifactId>yay</artifactId>
> > > >       <version>3</version>
> > > >        <order>2</order>  <------------------
> > > >     </dependency>
> > > > <...
> > > >
> > > > Is there a good way of tackling this?
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: [m2] dependency ordering

Posted by Mark Hobson <ma...@gmail.com>.
This discussion kinda overlaps with an issue I raised with the eclipse plugin:

http://jira.codehaus.org/browse/MNG-1412

I think the order should be nearest first, and then the order
specified in the pom.

Mark

On 14/11/05, Nigel Magnay <ni...@gmail.com> wrote:
> The artifact being generated is effectively a merge of several other
> artifacts of the same type  - a WAR file. It's important to get the
> ordering right as the overwriting precidence matters.
>
> I was just thinking of needing an extra bit of user data, much like
> the properties you could put on dependencies in M1 that controlled
> things like whether the file got included in the manifest or not; a
> 'proper' ordering of all dependencies does sound harder (and maybe too
> hard to be always right in all circumstances..)
>
> On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> > Can you describe what the relevance of the ordering is? There might be
> > something already available.
> >
> > The suggestion of this tag is tricky, as how does dependencies brought
> > in transitively get ordered?
> >
> > - Brett
> >
> > On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > > Hi -
> > >
> > > I'm doing some processing with a custom mojo that relies on the
> > > dependency information to build an artifact, but the order of
> > > processing is important. Because MavenProject.getArtifacts() returns a
> > > set, this is unordered with respect to the pom.xml; I was wondering if
> > > it's possible to add extra information in the pom, something like
> > >
> > > ...>
> > > <dependency>
> > >       <groupId>blah</groupId>
> > >       <artifactId>thing</artifactId>
> > >       <version>3.8.1</version>
> > > <order>1</order>  <------------------
> > >     </dependency>
> > > <dependency>
> > >       <groupId>woo</groupId>
> > >       <artifactId>yay</artifactId>
> > >       <version>3</version>
> > >        <order>2</order>  <------------------
> > >     </dependency>
> > > <...
> > >
> > > Is there a good way of tackling this?
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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: [m2] dependency ordering

Posted by Carsten Ziegeler <cz...@apache.org>.
I think I general use case for ordered dependencies is when you need two
different versions of one dependency for compilation. For example I have
some utility project that provides functionality for framework A. My
utility project can be used with version 1.x of A and 2.x - as A changed
 incompatible from 1.x to 2.x and as I don't want to split my project
into different versions, I need some classes of 1.x and some of 2.x for
compilation. In this case the ordering is important.

Now, unfortunately, this scenario is not going to work with m2 directly
as m2 only allows one version of a dependency in the classpath :(

Carsten

Nigel Magnay wrote:
> The artifact being generated is effectively a merge of several other
> artifacts of the same type  - a WAR file. It's important to get the
> ordering right as the overwriting precidence matters.
> 
> I was just thinking of needing an extra bit of user data, much like
> the properties you could put on dependencies in M1 that controlled
> things like whether the file got included in the manifest or not; a
> 'proper' ordering of all dependencies does sound harder (and maybe too
> hard to be always right in all circumstances..)
> 
> On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> 
>>Can you describe what the relevance of the ordering is? There might be
>>something already available.
>>
>>The suggestion of this tag is tricky, as how does dependencies brought
>>in transitively get ordered?
>>


-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

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


Re: [m2] dependency ordering

Posted by Nigel Magnay <ni...@gmail.com>.
I was just looking at that and thinking that was probably the way I
should do it.. just seemed a shame that I couldn't attach some
arbitary property inside the dependency tag, but it's no biggie.

Nigel

On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> Right - transitivity defeats the ability to do this.
>
> What you need to do is specify the order in configuration to your
> plugin (and still declare the dependencies normally).
>
> <wars>
>   <war>groupId:artifactId1</war>
>   <war>groupId:artifactId2</war>
> </wars>
>
> From this you can construct an artifact filter pretty easily and
> filter the ${project.artifacts}. This is how the assembly plugin
> works.
>
> - Brett
>
> On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > The artifact being generated is effectively a merge of several other
> > artifacts of the same type  - a WAR file. It's important to get the
> > ordering right as the overwriting precidence matters.
> >
> > I was just thinking of needing an extra bit of user data, much like
> > the properties you could put on dependencies in M1 that controlled
> > things like whether the file got included in the manifest or not; a
> > 'proper' ordering of all dependencies does sound harder (and maybe too
> > hard to be always right in all circumstances..)
> >
> > On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> > > Can you describe what the relevance of the ordering is? There might be
> > > something already available.
> > >
> > > The suggestion of this tag is tricky, as how does dependencies brought
> > > in transitively get ordered?
> > >
> > > - Brett
> > >
> > > On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > > > Hi -
> > > >
> > > > I'm doing some processing with a custom mojo that relies on the
> > > > dependency information to build an artifact, but the order of
> > > > processing is important. Because MavenProject.getArtifacts() returns a
> > > > set, this is unordered with respect to the pom.xml; I was wondering if
> > > > it's possible to add extra information in the pom, something like
> > > >
> > > > ...>
> > > > <dependency>
> > > >       <groupId>blah</groupId>
> > > >       <artifactId>thing</artifactId>
> > > >       <version>3.8.1</version>
> > > > <order>1</order>  <------------------
> > > >     </dependency>
> > > > <dependency>
> > > >       <groupId>woo</groupId>
> > > >       <artifactId>yay</artifactId>
> > > >       <version>3</version>
> > > >        <order>2</order>  <------------------
> > > >     </dependency>
> > > > <...
> > > >
> > > > Is there a good way of tackling this?
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: [m2] dependency ordering

Posted by Brett Porter <br...@gmail.com>.
Right - transitivity defeats the ability to do this.

What you need to do is specify the order in configuration to your
plugin (and still declare the dependencies normally).

<wars>
  <war>groupId:artifactId1</war>
  <war>groupId:artifactId2</war>
</wars>

>From this you can construct an artifact filter pretty easily and
filter the ${project.artifacts}. This is how the assembly plugin
works.

- Brett

On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> The artifact being generated is effectively a merge of several other
> artifacts of the same type  - a WAR file. It's important to get the
> ordering right as the overwriting precidence matters.
>
> I was just thinking of needing an extra bit of user data, much like
> the properties you could put on dependencies in M1 that controlled
> things like whether the file got included in the manifest or not; a
> 'proper' ordering of all dependencies does sound harder (and maybe too
> hard to be always right in all circumstances..)
>
> On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> > Can you describe what the relevance of the ordering is? There might be
> > something already available.
> >
> > The suggestion of this tag is tricky, as how does dependencies brought
> > in transitively get ordered?
> >
> > - Brett
> >
> > On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > > Hi -
> > >
> > > I'm doing some processing with a custom mojo that relies on the
> > > dependency information to build an artifact, but the order of
> > > processing is important. Because MavenProject.getArtifacts() returns a
> > > set, this is unordered with respect to the pom.xml; I was wondering if
> > > it's possible to add extra information in the pom, something like
> > >
> > > ...>
> > > <dependency>
> > >       <groupId>blah</groupId>
> > >       <artifactId>thing</artifactId>
> > >       <version>3.8.1</version>
> > > <order>1</order>  <------------------
> > >     </dependency>
> > > <dependency>
> > >       <groupId>woo</groupId>
> > >       <artifactId>yay</artifactId>
> > >       <version>3</version>
> > >        <order>2</order>  <------------------
> > >     </dependency>
> > > <...
> > >
> > > Is there a good way of tackling this?
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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: [m2] dependency ordering

Posted by Nigel Magnay <ni...@gmail.com>.
The artifact being generated is effectively a merge of several other
artifacts of the same type  - a WAR file. It's important to get the
ordering right as the overwriting precidence matters.

I was just thinking of needing an extra bit of user data, much like
the properties you could put on dependencies in M1 that controlled
things like whether the file got included in the manifest or not; a
'proper' ordering of all dependencies does sound harder (and maybe too
hard to be always right in all circumstances..)

On 11/14/05, Brett Porter <br...@gmail.com> wrote:
> Can you describe what the relevance of the ordering is? There might be
> something already available.
>
> The suggestion of this tag is tricky, as how does dependencies brought
> in transitively get ordered?
>
> - Brett
>
> On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> > Hi -
> >
> > I'm doing some processing with a custom mojo that relies on the
> > dependency information to build an artifact, but the order of
> > processing is important. Because MavenProject.getArtifacts() returns a
> > set, this is unordered with respect to the pom.xml; I was wondering if
> > it's possible to add extra information in the pom, something like
> >
> > ...>
> > <dependency>
> >       <groupId>blah</groupId>
> >       <artifactId>thing</artifactId>
> >       <version>3.8.1</version>
> > <order>1</order>  <------------------
> >     </dependency>
> > <dependency>
> >       <groupId>woo</groupId>
> >       <artifactId>yay</artifactId>
> >       <version>3</version>
> >        <order>2</order>  <------------------
> >     </dependency>
> > <...
> >
> > Is there a good way of tackling this?
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: [m2] dependency ordering

Posted by Brett Porter <br...@gmail.com>.
Can you describe what the relevance of the ordering is? There might be
something already available.

The suggestion of this tag is tricky, as how does dependencies brought
in transitively get ordered?

- Brett

On 11/14/05, Nigel Magnay <ni...@gmail.com> wrote:
> Hi -
>
> I'm doing some processing with a custom mojo that relies on the
> dependency information to build an artifact, but the order of
> processing is important. Because MavenProject.getArtifacts() returns a
> set, this is unordered with respect to the pom.xml; I was wondering if
> it's possible to add extra information in the pom, something like
>
> ...>
> <dependency>
>       <groupId>blah</groupId>
>       <artifactId>thing</artifactId>
>       <version>3.8.1</version>
> <order>1</order>  <------------------
>     </dependency>
> <dependency>
>       <groupId>woo</groupId>
>       <artifactId>yay</artifactId>
>       <version>3</version>
>        <order>2</order>  <------------------
>     </dependency>
> <...
>
> Is there a good way of tackling this?
>
> ---------------------------------------------------------------------
> 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