You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Nick Bonatsakis <nb...@gmail.com> on 2010/05/10 19:42:56 UTC

resolving multiple maven artifact dependencies of same type

Hello All,

I have a maven pom that builds a project and publishes 3 properties files
alongside the project jar file using pom code like:

<execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>

 <file>src/war/WEB-INF/foo.properties</file>
                                    <type>properties</type>
                                    <classifier>foo</classifier>

                                </artifact>
                                <artifact>

 <file>src/war/WEB-INF/bar.properties</file>
                                    <type>properties</type>
                                    <classifier>bar</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>

When I look in the m2 local repo, I see the jar file and these two files
with the project name and version prepended. I now want to be able to pull
these files into a different project using ivy. It seems that if I use the
classifier attribute of <artifact>, I can only resolve one file of a given
type. My ivy snippet:

<dependency org="com.mycompany.myproj" name="myproj"
rev="latest.integration" conf="test">
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="foo"/>
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="bar"/>
    </dependency>

This fails because when it runs, it wants to name both files
"myproj.properties" so when it gets to the second, it fails, because the
first is already there. Is there any way I can dictate how the resolved
files are named? Or some other sollution to this problem?

Thank you all.

-- 
Nicholas Bonatsakis
Software Engineer

RE: resolving multiple maven artifact dependencies of same type

Posted by James Davis <ja...@atsid.com>.
If I understand correctly, this can be specified in the resolver by specifying the artifact pattern.

See the documentation here: http://ant.apache.org/ivy/history/latest-milestone/settings.html

James Davis • QA Engineer II/Software Engineer
Applied Technical Systems, Inc. • Systems Division
web: www.atsid.com • e-mail: james.davis@atsid.com
(p) 360.698.7100 x241 • (f) 360.698.7200

________________________________________
From: Nick Bonatsakis [nbonatsakis@gmail.com]
Sent: Monday, May 10, 2010 10:42 AM
To: ivy-user@ant.apache.org
Subject: resolving multiple maven artifact dependencies of same type

Hello All,

I have a maven pom that builds a project and publishes 3 properties files
alongside the project jar file using pom code like:

<execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>

 <file>src/war/WEB-INF/foo.properties</file>
                                    <type>properties</type>
                                    <classifier>foo</classifier>

                                </artifact>
                                <artifact>

 <file>src/war/WEB-INF/bar.properties</file>
                                    <type>properties</type>
                                    <classifier>bar</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>

When I look in the m2 local repo, I see the jar file and these two files
with the project name and version prepended. I now want to be able to pull
these files into a different project using ivy. It seems that if I use the
classifier attribute of <artifact>, I can only resolve one file of a given
type. My ivy snippet:

<dependency org="com.mycompany.myproj" name="myproj"
rev="latest.integration" conf="test">
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="foo"/>
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="bar"/>
    </dependency>

This fails because when it runs, it wants to name both files
"myproj.properties" so when it gets to the second, it fails, because the
first is already there. Is there any way I can dictate how the resolved
files are named? Or some other sollution to this problem?

Thank you all.

--
Nicholas Bonatsakis
Software Engineer

RE: resolving multiple maven artifact dependencies of same type

Posted by Nathan Franzen <Na...@mmodal.com>.
Can you explain further?   What [classifier] token?   I don't see this mentioned in the documentation, so I'm curious.   When you construct a pattern, what determines a valid token element? 

For reference, the example in the documentation is the simple
       <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]"/>

Nathan

 

> -----Original Message-----
> From: Maarten Coene [mailto:maarten_coene@yahoo.com]
> Sent: Tuesday, May 11, 2010 4:19 PM
> To: ivy-user@ant.apache.org
> Subject: Re: resolving multiple maven artifact dependencies of same type
> 
> I guess are you are using the ivy:retrieve task?
> You'll have to add [classifier] to your retrieve pattern to solve this
> problem.
> 
> Maarten
> 
> 
> 
> 
> ----- Original Message ----
> From: Nick Bonatsakis <nb...@gmail.com>
> To: ivy-user@ant.apache.org
> Sent: Mon, May 10, 2010 7:42:56 PM
> Subject: resolving multiple maven artifact dependencies of same type
> 
> Hello All,
> 
> I have a maven pom that builds a project and publishes 3 properties files
> alongside the project jar file using pom code like:
> 
> <execution>
>                         <id>attach-artifacts</id>
>                         <phase>package</phase>
>                         <goals>
>                             <goal>attach-artifact</goal>
>                         </goals>
>                         <configuration>
>                             <artifacts>
>                                 <artifact>
> 
> <file>src/war/WEB-INF/foo.properties</file>
>                                     <type>properties</type>
>                                     <classifier>foo</classifier>
> 
>                                 </artifact>
>                                 <artifact>
> 
> <file>src/war/WEB-INF/bar.properties</file>
>                                     <type>properties</type>
>                                     <classifier>bar</classifier>
>                                 </artifact>
>                             </artifacts>
>                         </configuration>
>                     </execution>
> 
> When I look in the m2 local repo, I see the jar file and these two files
> with the project name and version prepended. I now want to be able to pull
> these files into a different project using ivy. It seems that if I use the
> classifier attribute of <artifact>, I can only resolve one file of a given
> type. My ivy snippet:
> 
> <dependency org="com.mycompany.myproj" name="myproj"
> rev="latest.integration" conf="test">
>         <artifact name="myproj" type="properties" ext="properties"
> m:classifier="foo"/>
>         <artifact name="myproj" type="properties" ext="properties"
> m:classifier="bar"/>
>     </dependency>
> 
> This fails because when it runs, it wants to name both files
> "myproj.properties" so when it gets to the second, it fails, because the
> first is already there. Is there any way I can dictate how the resolved
> files are named? Or some other sollution to this problem?
> 
> Thank you all.
> 
> --
> Nicholas Bonatsakis
> Software Engineer
> 
> 
> 
> 

Re: resolving multiple maven artifact dependencies of same type

Posted by Maarten Coene <ma...@yahoo.com>.
I guess are you are using the ivy:retrieve task?
You'll have to add [classifier] to your retrieve pattern to solve this problem.

Maarten




----- Original Message ----
From: Nick Bonatsakis <nb...@gmail.com>
To: ivy-user@ant.apache.org
Sent: Mon, May 10, 2010 7:42:56 PM
Subject: resolving multiple maven artifact dependencies of same type

Hello All,

I have a maven pom that builds a project and publishes 3 properties files
alongside the project jar file using pom code like:

<execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>

<file>src/war/WEB-INF/foo.properties</file>
                                    <type>properties</type>
                                    <classifier>foo</classifier>

                                </artifact>
                                <artifact>

<file>src/war/WEB-INF/bar.properties</file>
                                    <type>properties</type>
                                    <classifier>bar</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>

When I look in the m2 local repo, I see the jar file and these two files
with the project name and version prepended. I now want to be able to pull
these files into a different project using ivy. It seems that if I use the
classifier attribute of <artifact>, I can only resolve one file of a given
type. My ivy snippet:

<dependency org="com.mycompany.myproj" name="myproj"
rev="latest.integration" conf="test">
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="foo"/>
        <artifact name="myproj" type="properties" ext="properties"
m:classifier="bar"/>
    </dependency>

This fails because when it runs, it wants to name both files
"myproj.properties" so when it gets to the second, it fails, because the
first is already there. Is there any way I can dictate how the resolved
files are named? Or some other sollution to this problem?

Thank you all.

-- 
Nicholas Bonatsakis
Software Engineer