The following patch enables one to define properties specific to a
given OS. For example:

  <property name="my_jar" value="e:\foo\jar\a.jar" os="WinNT"/>
  <property name="my_jar" value="/opt/jar/a.jar"   os="SunOS"/>

If the OS mismatches the property is ignored.

Frank Varnavas

=====================================

diff -c -r1.1.1.1 Property.java
*** Property.java       2001/06/21 20:50:04     1.1.1.1
--- Property.java       2001/06/27 20:39:58
***************
*** 76,81 ****
--- 76,82 ----
      protected String resource;
      protected Path classpath;
      protected String env;
+     protected String os;
      protected Reference ref = null;
  
      protected boolean userProperty=false; // set read-only properties
***************
*** 88,93 ****
--- 89,102 ----
          return name;
      }
  
+     public void setOS(String os) {
+         this.os = os;
+     }
+ 
+     public String getOS() {
+         return os;
+     }
+ 
      public void setLocation(File location) {
          setValue(location.getAbsolutePath());
      }
***************
*** 161,166 ****
--- 170,180 ----
  
      public void execute() throws BuildException {
          try {
+         // dont load if os mismatch
+         if( os != null && !os.equals(System.getProperty("os.name"))){
+           log("Property skipped due to OS mismatch. Specified:" + 
+               os + " actual:" + System.getProperty("os.name"), Project.MSG_VERBOSE);
+         } else {
              if ((name != null) && (value != null)) {
                  addProperty(name, value);
              }
***************
*** 177,182 ****
--- 191,197 ----
                      addProperty(name, obj.toString());
                  }
              }
+         }
  
          } catch (Exception e) {
              throw new BuildException(e, location);

Reply via email to