You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by "Jing Xue (JIRA)" <ji...@apache.org> on 2007/09/23 00:53:50 UTC

[jira] Created: (IVY-608) Add support for importing environment variables

Add support for importing environment variables
-----------------------------------------------

                 Key: IVY-608
                 URL: https://issues.apache.org/jira/browse/IVY-608
             Project: Ivy
          Issue Type: New Feature
          Components: Core
    Affects Versions: 2.0.0-alpha-2
            Reporter: Jing Xue
            Priority: Minor
         Attachments: import-env.patch

Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-608) Add support for importing environment variables

Posted by "Jing Xue (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Xue updated IVY-608:
-------------------------

    Attachment: import-env-v2.patch

(Evidently my watch on this issue never sent me any emails...)

I'm uploading a new patch that:
1. reimplements the environment importing feature using the EnvironmentLoader approach Jan suggested, with Java 5 and Ant support.
2. adds the property description to the documentation.

Please consider the last patch obsolete.


> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch, import-env-v2.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Jan Matèrne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529849 ] 

Jan Matèrne commented on IVY-608:
---------------------------------

Regarding the maintenance of Ant code ... some thoughts ...

interface EnvironmentLoader {
    Map getEnvironment();
}
abstract class EnvLoaderFactory {
    EnvironmentLoader getEnvLoader() {
        // 1. check for Java5, then return the Java5EnvLoader
        // 2. check if Ants <property> is on classpath; then use AntEnvLoader
        // 3. other implementations?
        // NoEnvLoader
    }
}
interface EnvironmentLoader {
    Map getEnvironment();
}
public class NoEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // error statements
        // maybe an exception?
    }
}
public class AntEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        oata.taskdefs.Properties propTask = new ...
        // some more configuration needed?
        propTask.setEnvironment("env");
        propTask.execute();
        // read the env key-value pairs
        return ...
    }
}
public class Java5EnvLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // based on Jings implementation
    }
}

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (IVY-608) Add support for importing environment variables

Posted by "Jan Matèrne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529849 ] 

jhm edited comment on IVY-608 at 9/24/07 6:05 AM:
----------------------------------------------------------

Regarding the maintenance of Ant code ... some thoughts ...

{code:title=EnvironmentLoading}
interface EnvironmentLoader {
    Map getEnvironment();
}
abstract class EnvironmentLoader {
    EnvironmentLoader getEnvLoader() {
        // 1. check for Java5, then return the Java5EnvLoader
        // 2. check if Ants <property> is on classpath; then use AntEnvLoader
        // 3. other implementations?
        // NoEnvLoader
    }
}
public class NoEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // error statements
        // maybe an exception?
    }
}
public class AntEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        oata.taskdefs.Properties propTask = new ...
        // some more configuration needed?
        propTask.setEnvironment("env");
        propTask.execute();
        // read the env key-value pairs
        return ...
    }
}
public class Java5EnvLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // based on Jings implementation
    }
}
{code}

      was (Author: jhm):
    Regarding the maintenance of Ant code ... some thoughts ...

interface EnvironmentLoader {
    Map getEnvironment();
}
abstract class EnvLoaderFactory {
    EnvironmentLoader getEnvLoader() {
        // 1. check for Java5, then return the Java5EnvLoader
        // 2. check if Ants <property> is on classpath; then use AntEnvLoader
        // 3. other implementations?
        // NoEnvLoader
    }
}
interface EnvironmentLoader {
    Map getEnvironment();
}
public class NoEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // error statements
        // maybe an exception?
    }
}
public class AntEnvironmentLoader implements EnvironmentLoader {
    Map getEnvironment() {
        oata.taskdefs.Properties propTask = new ...
        // some more configuration needed?
        propTask.setEnvironment("env");
        propTask.execute();
        // read the env key-value pairs
        return ...
    }
}
public class Java5EnvLoader implements EnvironmentLoader {
    Map getEnvironment() {
        // based on Jings implementation
    }
}
  
> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-608) Add support for importing environment variables

Posted by "Jing Xue (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Xue updated IVY-608:
-------------------------

    Attachment: import-env-1.patch

attaching the patch.

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Xavier Hanin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529847 ] 

Xavier Hanin commented on IVY-608:
----------------------------------

Reusing the code from Ant property task will bring quite a lot of code (which actually executes an OS specific command), which we will have to maintain later. So I'm in favor of using Jing solution, with a good documentation explaining that the feature is available for java5+ only.

About documentation, Jing could you provide a patch for the documentation too?

About the implementation, I think we should extract the code dealing with environment loading in a separate class, and maybe even put it in a separate source directory, so that we could still compile the core with jdk 1.4, and compile this class only with jdk 1.5+. Otherwise we may easily introduce code relying on jdk5+ without noticing it.

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-608) Add support for importing environment variables

Posted by "Jing Xue (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Xue updated IVY-608:
-------------------------

    Attachment: import-env.patch

Attaching the patch.

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537581 ] 

Maarten Coene commented on IVY-608:
-----------------------------------

Another possibility would maybe be to change the getVariable(String) method on IvyVariableContainer to use the System.getenv(String) method if the variable hasn't been specified manually, for instance to something like this:

{code:java}
    public String getVariable(String name) {
        String val = (String) variables.get(name);
        if (val == null) {
            val = System.getenv(name);
        }
        return val == null ? val : substitute(val);
    }
{code}

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch, import-env-v2.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-608) Add support for importing environment variables

Posted by "Jing Xue (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Xue updated IVY-608:
-------------------------

    Attachment:     (was: import-env.patch)

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Maarten Coene (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529844 ] 

Maarten Coene commented on IVY-608:
-----------------------------------

Maybe we can "reuse" the code from the Ant Property task which loads the environment variables?
This way, it will also work for JDK <1.5

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Jan Matèrne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529883 ] 

Jan Matèrne commented on IVY-608:
---------------------------------

Just for IvyDE - Eclipse has a bundled Ant (1.7.0 at the moment). A plugin dependency would be enough.

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IVY-608) Add support for importing environment variables

Posted by "Jing Xue (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jing Xue updated IVY-608:
-------------------------

    Comment: was deleted

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Xavier Hanin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529873 ] 

Xavier Hanin commented on IVY-608:
----------------------------------

Sounds like a nice way to have it working in many cases. And with the classloading mechanism we have in Ivy, someone with jre 1.4 could still use environment properties in IvyDE simply by adding ant.jar in the Ivy classpath. 

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IVY-608) Add support for importing environment variables

Posted by "Jan Matèrne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IVY-608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529882 ] 

Jan Matèrne commented on IVY-608:
---------------------------------

And with splitting into several classes you could use conditional compilation like in Ant.

{code:xml}
<project ...>

  <selector id="needs.jdk1.5+">
    <or>
      <filename name="**/Java5EnvLoader*"/>
      <!-- maybe more -->
    </or>
  </selector>
  <available property="jdk1.5+" classname="java.net.Proxy"/>

  <target name="build" ...>
      ...
      <javac ...>
          <selector id="conditional-patterns">
              <not>
                  <selector refid="needs.jdk1.5+" unless="jdk1.5+"/>
              </not>
          </selector>
      </javac>
  </target>

</project>
{code}

> Add support for importing environment variables
> -----------------------------------------------
>
>                 Key: IVY-608
>                 URL: https://issues.apache.org/jira/browse/IVY-608
>             Project: Ivy
>          Issue Type: New Feature
>          Components: Core
>    Affects Versions: 2.0.0-alpha-2
>            Reporter: Jing Xue
>            Priority: Minor
>         Attachments: import-env-1.patch
>
>
> Ant supports importing environment variables into properties via the <properties environment="env" /> task.  If an ivysettings.xml relies on an environment variable, the lack of support for this feature in Ivy makes it difficult to reuse the same ivysettings.xml in a non-Ant environment, such as in IvyDE.  I'm submitting a patch to add the support for JDK 1.5+. This implementation will throw an exception when running in lesser JVMs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.