ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Chmod.java
Date Tue, 19 Apr 2005 22:23:39 GMT
stevel      2005/04/19 15:23:39

  Modified:    docs/manual/CoreTasks conditions.html
               src/main/org/apache/tools/ant/taskdefs/condition Os.java
               src/main/org/apache/tools/ant/taskdefs Chmod.java
  Log:
  Os gets
   -specific test for nt based systems
   -refactored (less recursive) OS analysis
   -constant strings for every family
  Patched into chmod.
  
  Revision  Changes    Path
  1.35      +3 -1      ant/docs/manual/CoreTasks/conditions.html
  
  Index: conditions.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/conditions.html,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- conditions.html	7 Apr 2005 22:22:25 -0000	1.34
  +++ conditions.html	19 Apr 2005 22:23:39 -0000	1.35
  @@ -113,7 +113,9 @@
     <li>netware (for Novell NetWare)</li>
     <li>os/2 (for OS/2)</li>
     <li>tandem (for HP's NonStop Kernel - formerly Tandem)</li>
  -  <li>win9x for Microsoft Windows 95 and 98</li>
  +  <li>win9x for Microsoft Windows 95 and 98, ME and CE</li>
  +  <li>nt for Microsoft Windows NT-based systems, including Windows 2000, XP and
  +      successors</li>
     <li>z/os for z/OS and OS/390</li>
     <li>os/400 for OS/400</li>
     <li>openvms for OpenVMS</li>
  
  
  
  1.37      +97 -25    ant/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  
  Index: Os.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/condition/Os.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Os.java	10 Mar 2005 12:50:58 -0000	1.36
  +++ Os.java	19 Apr 2005 22:23:39 -0000	1.37
  @@ -36,10 +36,68 @@
       private static final String PATH_SEP =
           System.getProperty("path.separator");
   
  +    /**
  +     * OS family to look for
  +     */
       private String family;
  +    /**
  +     * Name of OS
  +     */
       private String name;
  +    /**
  +     * version of OS
  +     */
       private String version;
  +    /**
  +     * OS architecture
  +     */
       private String arch;
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_WINDOWS = "windows";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_9X = "win9x";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_NT = "nt";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_OS2 = "os/2";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_NETWARE = "netware";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_DOS = "dos";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_MAC = "mac";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_TANDEM = "tandem";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_UNIX = "unix";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_VMS = "openvms";
  +    /**
  +     * OS family that can be tested for. {@value}
  +     */
  +    public static final String FAMILY_ZOS = "z/os";
  +    /** OS family that can be tested for. {@value} */
  +    public static final String FAMILY_OS400 = "os/400";
   
       /**
        * Default constructor
  @@ -186,35 +244,49 @@
               boolean isVersion = true;
   
               if (family != null) {
  -                if (family.equals("windows")) {
  -                    isFamily = OS_NAME.indexOf("windows") > -1;
  -                } else if (family.equals("os/2")) {
  -                    isFamily = OS_NAME.indexOf("os/2") > -1;
  -                } else if (family.equals("netware")) {
  -                    isFamily = OS_NAME.indexOf("netware") > -1;
  -                } else if (family.equals("dos")) {
  -                    isFamily = PATH_SEP.equals(";") && !isFamily("netware");
  -                } else if (family.equals("mac")) {
  -                    isFamily = OS_NAME.indexOf("mac") > -1;
  -                } else if (family.equals("tandem")) {
  -                    isFamily = OS_NAME.indexOf("nonstop_kernel") > -1;
  -                } else if (family.equals("unix")) {
  -                    isFamily = PATH_SEP.equals(":")
  -                        && !isFamily("openvms")
  -                        && (!isFamily("mac") || OS_NAME.endsWith("x"));
  -                } else if (family.equals("win9x")) {
  -                    isFamily = isFamily("windows")
  -                        && (OS_NAME.indexOf("95") >= 0
  +
  +                //windows probing logic relies on the word 'windows' in
  +                //the OS
  +                boolean isWindows = OS_NAME.indexOf(FAMILY_WINDOWS) > -1;
  +                boolean is9x = false;
  +                boolean isNT = false;
  +                if(isWindows) {
  +                    //there are only four 9x platforms that we look for
  +                    is9x = (OS_NAME.indexOf("95") >= 0
                               || OS_NAME.indexOf("98") >= 0
                               || OS_NAME.indexOf("me") >= 0
  +                            //wince isn't really 9x, but crippled enough to
  +                            //be a muchness. Ant doesnt run on CE, anyway.
                               || OS_NAME.indexOf("ce") >= 0);
  -                } else if (family.equals("z/os")) {
  -                    isFamily = OS_NAME.indexOf("z/os") > -1
  +                    isNT = !is9x;
  +                }
  +                if (family.equals(FAMILY_WINDOWS)) {
  +                    isFamily = isWindows;
  +                } else if (family.equals(FAMILY_9X)) {
  +                    isFamily = isWindows && is9x;
  +                } else if (family.equals(FAMILY_NT)) {
  +                    isFamily = isWindows && isNT;
  +                } else if (family.equals(FAMILY_OS2)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_OS2) > -1;
  +                } else if (family.equals(FAMILY_NETWARE)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_NETWARE) > -1;
  +                } else if (family.equals(FAMILY_DOS)) {
  +                    isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE);
  +                } else if (family.equals(FAMILY_MAC)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_MAC) > -1;
  +                } else if (family.equals(FAMILY_TANDEM)) {
  +                    isFamily = OS_NAME.indexOf("nonstop_kernel") > -1;
  +                } else if (family.equals(FAMILY_UNIX)) {
  +                    isFamily = PATH_SEP.equals(":")
  +                        && !isFamily(FAMILY_VMS)
  +                        && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x"));
  +                } else if (family.equals(FAMILY_ZOS)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_ZOS) > -1
                           || OS_NAME.indexOf("os/390") > -1;
  -                } else if (family.equals("os/400")) {
  -                    isFamily = OS_NAME.indexOf("os/400") > -1;
  -                } else if (family.equals("openvms")) {
  -                    isFamily = OS_NAME.indexOf("openvms") > -1;
  +                } else if (family.equals(FAMILY_OS400)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_OS400) > -1;
  +                } else if (family.equals(FAMILY_VMS)) {
  +                    isFamily = OS_NAME.indexOf(FAMILY_VMS) > -1;
                   } else {
                       throw new BuildException(
                           "Don\'t know how to detect os family \""
  
  
  
  1.45      +1 -1      ant/src/main/org/apache/tools/ant/taskdefs/Chmod.java
  
  Index: Chmod.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Chmod.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Chmod.java	25 Jan 2005 16:09:47 -0000	1.44
  +++ Chmod.java	19 Apr 2005 22:23:39 -0000	1.45
  @@ -250,6 +250,6 @@
        * @return true if the os is valid.
        */
       protected boolean isValidOs() {
  -        return Os.isFamily("unix") && super.isValidOs();
  +        return Os.isFamily(Os.FAMILY_UNIX) && super.isValidOs();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message