ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Coene <maarten_co...@yahoo.com>
Subject Re: Conditions on dependencies
Date Sun, 07 Nov 2010 13:09:51 GMT
Hi Markus,

thanks for the patch!
Could you create a JIRA issue for this and attach your patch to it with the 
"Grant license to ASF ..."-option checked?

thanks,
Maarten


----- Original Message ----
From: "Markus.Barchfeld.ext@deka.de" <Markus.Barchfeld.ext@deka.de>
To: ivy-user@ant.apache.org
Sent: Mon, November 1, 2010 10:08:41 AM
Subject: Conditions on dependencies

Hi,

I would sugggest to extend conditions on dependencies to check for
system properties, too.

Let me explain the use case. We want to use the ivy dependencies also
for deploying packages. Therefore we have separated code from
configuration files and put them into different modules. The
configuration modules contain configuration files for various
environments (development, integration, pre-production, production and
so on) and provide ivy configurations for the environments. I found that
conditional dependencies would be a great way to express the
dependencies from the code modules to the configuration modules - if
only I could use system properties there, too.

E.g.

<ivy-module version="2.0">
    <info organisation="org" module="module_config"
status="integration"/>
    <configurations>
        <conf name="prod" />
        <conf name="dev" />
    </configurations>
</ivy-module>

<ivy-module version="2.0">
    <info organisation="org" module="module" status="integration"/>
    <dependencies>
        <dependency name="module_config"
rev="latest.integration" conf="dist->[env=prod]prod,[env=dev]dev"/>
    </dependencies>
</ivy-module>

In order to fetch all packages needed for deploying into prod
environment I would only have to set the system property 'env' before
resolving/retrieving the dependencies of module, e.g.

> export ANT_OPTS=-Denv=prod 
> ant deploy

A patch for extending conditions in that way would be fairly simple and
can be found below. The question is if this is really the ivy-way of
doing things or if there is a better way to implement my use case.

Thanks 
Markus



Index:
src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.ja
va
===================================================================
---
src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.ja
va    (revision 1029576)
+++
src/java/org/apache/ivy/plugins/parser/AbstractModuleDescriptorParser.ja
va    (working copy)
@@ -24,7 +24,9 @@
import java.util.Date;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;

import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.Configuration;
@@ -229,6 +231,11 @@
                 }

                 String attrValue = dd.getAttribute(leftOp);
+                
+                if (attrValue == null) {
+                    attrValue = System.getProperty(leftOp);
+                }
+                
                 if (!rightOp.equals(attrValue)) {
                     return null;
                 }
@@ -242,6 +249,9 @@
                 }

                 String attrValue = dd.getAttribute(leftOp);
+                if (attrValue == null) {
+                    attrValue = System.getProperty(leftOp);
+                }
                 if (rightOp.equals(attrValue)) {
                     return null;
                 }


      

Mime
View raw message