ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antd <anthony.dilor...@gmail.com>
Subject RE: How to specify which resolver to use at resolve time?
Date Tue, 24 Aug 2010 13:15:18 GMT

Hi again,

After trying to implement a workaround, I've realized that specifying
"resolver" in resolve task isn't quite what I wanted. Specifying "resolver"
would imply only using that resolver in order to resolve dependencies. If
that were the case many errors would pop up as part of the resolution would
be unsuccessful since the rest of the dependencies are in other resolvers!

So what I really wanted was the "meta-data" of which resolver had the
artifact, and to use that in order to create a lib directory structure to
split them by resolver. One way that might be accomplished would be to have
another Ivy pattern called [resolver]. Then anyone can use the [resolver] as
part of the way they organize their directory structure during a retrieve
for example.

Having said all that, I came up with a workaround I'd like to share, but
it's a bit messy (which is why the above would make things so much simpler).

There are two main things you need to do:
1) Alter your ivysettings.xml to specify a different cache location for each
resolver you have. For example:

	<property name="ivysettings.first-party.cache.dir"
value="${user.home}/.ivy2/first-party-cache" override="false"/>
	<property name="ivysettings.third-party.cache.dir"
value="${user.home}/.ivy2/third-party-cache" override="false"/>

...

	<caches resolutionCacheDir="${user.home}/.ivy2/cache"  >
		<cache name="first-party-cache"
basedir="${ivysettings.first-party.cache.dir}" />
		<cache name="third-party-cache"
basedir="${ivysettings.third-party.cache.dir}" />
	</caches>

...

	<resolvers>
		<chain name="chained" returnFirst="true">
			<url name="first-party-releases" cache="first-party-cache">
...
			</url>
			<url name="third-party-releases" cache="third-party-cache">
...
			</url>
		</chain>
	</resolvers>


2) Then in your Ant build script, you use a pattern match to identify which
artifacts came from which cache based on the path:

		<ivy:cachepath pathid="lib.path.id" />
		<echo message="lib.path.id = ${toString:lib.path.id}" />

		<!-- 
			Identify first-party artifacts from the Ivy cachepath and copy
			them to the lib.build.dir directory.
		-->
		<copy todir="${lib.build.dir}">
			<path refid="lib.path.id" />
			<regexpmapper from="^.*/first-party-cache/.*/(.*)" to="\1"
handledirsep="true"/>
		</copy>



I hope that helps someone in a similar situation. If you think it's worth
having the [resolver] pattern/meta-data when doing a resolve, I can add a
defect/enhancement request.

Cheers.


antd wrote:
> 
> Hi,
> 
> I know this is an old thread, but I also tend to think it would be a nice
> feature to have to avoid complexity of multiple settings files. The
> alternative of using a property in the ivysettings file won't work easily
> for me because in the same common build script I use for all my projects,
> I want to use the default resolver and switch between the two I have as
> well.
> 
> Here is my use-case:
> - I use Hudson to build my Ivy-enabled ant scripts
> - I have several projects that dependent on other projects and also
> third-party libraries
> - I use Hudson fingerprinting (which basically records a unique identifier
> for build artifacts you specify) so that Hudson (and thus the user) knows
> what jar versions of Project B, C and D were used to build Project A
> - Hudson fingerprints are specified via a multiple directories (including
> wild cards)
> - All of my dependent jars (both first and third-party) resolve and
> retrieve to a folder called /lib
> 
> Thus is my dilemma. I cannot easily do a "fingerprint lib/*.jar" as it
> will end up fingerprinting all of the third-party libraries as well, which
> I don't want and is typically not done.
> 
> So long story short, if I could...
> - Ivy retrieve first-party dependencies to /lib/first-party
> - and Ivy retrieve third-party-dependencies to /lib/third-party
> ...it would be simple to specify lib/first-party/*.jar 
> 
> When you have many different first-party dependencies to specify, all with
> unique names, it gets error-prone in the Hudson fingerprint text box to
> type "lib/FirstDep.jar lib/SecondDep.jar lib/ThirdDep.jar etc." for every
> project you create.
> 
> In the meantime I'll try the workarounds suggested, but I think it would
> be very convenient to specify the resolver for all Ant/Ivy (post-)resolve
> tasks.
> 

-- 
View this message in context: http://old.nabble.com/How-to-specify-which-resolver-to-use-at-resolve-time--tp16338083p29521820.html
Sent from the ivy-user mailing list archive at Nabble.com.


Mime
View raw message