ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Lalevée <nicolas.lale...@hibnet.org>
Subject Re: Ivy Settings Conditionally Use an Environment Variable?
Date Thu, 02 Aug 2012 12:03:14 GMT
Le 2 août 2012 à 10:45, Eyad Ebrahim a écrit :

> I'm not sure if it's necessary to include this feature in Ivy. Ivy is
> supposed to compliment ant, and used along with it.
> Doing this, is to invite un-welcomed practices into Ivy usage. The code
> with be lost between ivy and ant.

If a part of the ivy configuration is to be defined/computed in an ant script, how it is supposed
to work within in the IDE ? Ant is very nice for headless build, but is too slow for an development
in an IDE. So I see only two options: either make the ivysettings independent, or generate
the ide metadata via ant. I have always worked with developers who prefer managing their IDE
themselves since each one has its preferred setup or tool. So I tend to prefer the former
solution.

Also note that even if Ivy is really well integrated with Ant, there are many use outside
of it. Within IDE like IvyDE or IvyBeans for instance. And some new build tool are using it
for their dependency management (see gradle, sbt, easyant).

IMHO of course too :)

Nicolas

> IMHO of course.
> 
> On Thu, Aug 2, 2012 at 10:19 AM, Nicolas Lalevée <nicolas.lalevee@hibnet.org
>> wrote:
> 
>> I think https://issues.apache.org/jira/browse/IVY-1367 is the answer :)
>> 
>> Nicolas
>> 
>> Le 2 août 2012 à 10:13, Eyad Ebrahim a écrit :
>> 
>>> I agree with Mitch. Such logic is better to be done in IVY.
>>> But if you are using IvyDE as well, things will get rough, since you
>> won't
>>> be passing through the ant files.
>>> 
>>> Yesterday someone had something similar, and I had also some ideas in
>> this
>>> regard:
>>> 
>> http://mail-archives.apache.org/mod_mbox/ant-ivy-user/201208.mbox/browser
>>> 
>>> 
>>> On Thu, Aug 2, 2012 at 6:00 AM, Mitch Gitman <mgitman@gmail.com> wrote:
>>> 
>>>> For this life of me, I can't find this in the Ivy documentation,
>>>> but--assuming you're using Ant and the ivy:settings Ant task--Ivy will
>>>> consume all the containing Ant Project's properties as Ivy variables, as
>>>> needed.
>>>> 
>>>> So what you could do is define just the following in your
>> ivysettings.xml:
>>>> <property name="ivy.repos.server" value="http://ivy:8081"
>> override="false"
>>>> />
>>>> 
>>>> Then you place your condition in the Ant script:
>>>> <condition property="ivy.repos.server" value="${env.IVY_SERVER}">
>>>>   <isset property="env.IVY_SERVER"/>
>>>> </condition>
>>>> 
>>>> Better yet, put everything in the Ant script.
>>>> 
>>>> Beyond that, you could take advantage of the immutability of Ant
>> properties
>>>> and just define the following in Ant:
>>>> <property name="env.IVY_SERVER" value="http://ivy:8081" />
>>>> 
>>>> This line will be your fallback if the environment variable IVY_SERVER
>> is
>>>> not defined. Then consume env.IVY_SERVER in your ivysettings.xml.
>> There's
>>>> something funky though about consuming an environment variable directly
>>>> like this. There are more elegant mechanisms than environment variables
>> for
>>>> non-bootstrappy user-varying content.
>>>> 
>>>> Another, not necessarily elegant technique I've seen is to use special
>>>> marker variables to import different nested Ivy settings into your main
>> Ivy
>>>> setting using the include element. So you might do:
>>>> <include file="ivysettings-${environment}.xml"
>>>> 
>>>> Then you can define different Ivy resolvers/repositories with the same
>> name
>>>> but which potentially use vastly different configurations.
>>>> 
>>>> On Tue, Jul 31, 2012 at 1:04 PM, J.C. Hamlin <
>> JHamlin@successfactors.com
>>>>> wrote:
>>>> 
>>>>> I am looking for help with using Ivy and environment variables. Is
>>>>> there any way to conditionally use an environment variable in
>>>>> ivysettings.xml, and if it is not set, then fall back on a default?
>>>>> Basically, what we want is something like that if the IVY_SERVER
>>>>> environment variable is set, use it, otherwise default to
>>>> http://ivy:8081/.
>>>>> Kind of like how shell would do it with a definition like
>> ${IVY_SERVER:-
>>>>> http://ivy:8081}. I can’t find a way to achieve this same behavior
in
>>>>> Ivy. ****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> We tried this in ivysettings.xml:****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> <properties environment="env"/>****
>>>>> 
>>>>> <property name="ivy.repos.server" value="${env.IVY_SERVER}"
>>>>> override="false"/>****
>>>>> 
>>>>> <property name="ivy.repos.server" value="http://ivy:8081"
>>>>> override="false"/>****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> And it doesn't work. ivy.repos.server either ends up with the value of
>>>> the
>>>>> environment variable IVY_SERVER (which is desirable) or the value
>>>>> ${env.IVY_SERVER} if no environment variable is defined (which is
>>>>> undesirable). So, in our attempt, the second property setting never
>>>> happens.
>>>>> ****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> Now I understand this is the way it works in ant, so this make Ivy
>>>>> consistent with how ant works. However, ant has “condition”, which
can
>>>>> achieve the actual effect that we want like this:****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> <condition property="ivy.repos.server" value="${env.IVY_SERVER}">****
>>>>> 
>>>>>   <isset property="env.IVY_SERVER"/>****
>>>>> 
>>>>> </condition>****
>>>>> 
>>>>> <property name="ivy.repos.server" value="http://ivy:8081"/>****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> Is there a way to do this with Ivy? If not, that makes it pretty
>>>>> impossible to allow users to use environment variables to override the
>>>>> default behavior of the system.****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> Any help would be appreciated. Thanks in advance.****
>>>>> 
>>>>> ** **
>>>>> 
>>>>> -J.C.****
>>>>> 
>>>>> <http://www.successfactors.com>
>>>>> 
>>>>> 
>>>> 
>> 
>> 


Mime
View raw message