You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2001/11/02 08:56:53 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/util SourceFileScanner.java

bodewig     01/11/01 23:56:53

  Modified:    src/main/org/apache/tools/ant/taskdefs Chmod.java
                        DependSet.java Execute.java Javadoc.java
               src/main/org/apache/tools/ant/taskdefs/condition Os.java
               src/main/org/apache/tools/ant/taskdefs/optional Cab.java
               src/main/org/apache/tools/ant/types CommandlineJava.java
               src/main/org/apache/tools/ant/util SourceFileScanner.java
  Log:
  Take care of NetWare when searching for "java" and "javadoc", add
  NetWare case for <property environment=... />.
  
  Simplify OS based decisions.
  
  Revision  Changes    Path
  1.17      +2 -5      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Chmod.java
  
  Index: Chmod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Chmod.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Chmod.java	2001/10/28 21:26:29	1.16
  +++ Chmod.java	2001/11/02 07:56:52	1.17
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant.taskdefs;
   
   import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.taskdefs.condition.Os;
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.PatternSet;
   
  @@ -202,10 +203,6 @@
       }
   
       protected boolean isValidOs() {
  -        // XXX if OS=unix
  -        return System.getProperty("path.separator").equals(":") 
  -            && (!System.getProperty("os.name").startsWith("Mac") 
  -                 || System.getProperty("os.name").endsWith("X"))
  -            && super.isValidOs();
  +        return Os.isFamily("unix") && super.isValidOs();
       }
   }
  
  
  
  1.5       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  
  Index: DependSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DependSet.java	2001/10/31 11:04:59	1.4
  +++ DependSet.java	2001/11/02 07:56:52	1.5
  @@ -108,7 +108,7 @@
    * </li></ulist>
    * 
    * @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
  - * @version $Revision: 1.4 $ $Date: 2001/10/31 11:04:59 $
  + * @version $Revision: 1.5 $ $Date: 2001/11/02 07:56:52 $
    */
   public class DependSet extends MatchingTask {
   
  @@ -171,7 +171,7 @@
             be able to check file modification times.
             (Windows has a max resolution of two secs for modification times)
           */
  -        if ((new Os("windows")).eval()) {
  +        if (Os.isFamily("windows")) {
               now += 2000;
           }
   
  
  
  
  1.24      +11 -7     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Execute.java	2001/10/31 11:04:59	1.23
  +++ Execute.java	2001/11/02 07:56:52	1.24
  @@ -111,15 +111,15 @@
               // Ignore and keep try
           }
   
  -        if ( (new Os("mac")).eval() ) {
  +        if ( Os.isFamily("mac") ) {
               // Mac
               shellLauncher = new MacCommandLauncher(new CommandLauncher());
           }
  -        else if ( (new Os("os/2")).eval() ) {
  +        else if ( Os.isFamily("os/2") ) {
               // OS/2 - use same mechanism as Windows 2000
               shellLauncher = new WinNTCommandLauncher(new CommandLauncher());
           }
  -        else if ( (new Os("windows")).eval() ) {
  +        else if ( Os.isFamily("windows") ) {
               // Windows.  Need to determine which JDK we're running in
   
               CommandLauncher baseLauncher;
  @@ -203,13 +203,13 @@
       }
   
       private static String[] getProcEnvCommand() {
  -        if ( (new Os("os/2")).eval() ) {
  +        if ( Os.isFamily("os/2") ) {
               // OS/2 - use same mechanism as Windows 2000
               // Not sure
               String[] cmd = {"cmd", "/c", "set" };
               return cmd;
           }
  -        else if ( (new Os("windows")).eval() ) {
  +        else if ( Os.isFamily("windows") ) {
               String osname = 
                   System.getProperty("os.name").toLowerCase(Locale.US);
               // Determine if we're running under 2000/NT or 98/95
  @@ -224,14 +224,18 @@
                   return cmd;
               }
           }
  -        else if ( (new Os("unix")).eval() ) {
  +        else if ( Os.isFamily("unix") ) {
               // Generic UNIX
               // Alternatively one could use: /bin/sh -c env
               String[] cmd = {"/usr/bin/env"};
               return cmd;
  +        } 
  +        else if ( Os.isFamily("netware") ) {
  +            String[] cmd = {"env"};
  +            return cmd;
           }
           else {
  -            // MAC OS 9 and previous, Netware
  +            // MAC OS 9 and previous
               // TODO: I have no idea how to get it, someone must fix it
               String[] cmd = null;
               return cmd;
  
  
  
  1.64      +6 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- Javadoc.java	2001/10/31 11:04:59	1.63
  +++ Javadoc.java	2001/11/02 07:56:52	1.64
  @@ -1159,7 +1159,7 @@
       {
           // This is the most common extension case - exe for windows and OS/2, 
           // nothing for *nix.
  -	String extension =  (new Os("dos")).eval() ? ".exe" : "";
  +	String extension =  Os.isFamily("dos") ? ".exe" : "";
   
           // Look for javadoc in the java.home/../bin directory.  Unfortunately
           // on Windows java.home doesn't always refer to the correct location,
  @@ -1168,14 +1168,16 @@
           File jdocExecutable = new File( System.getProperty("java.home") +
                                           "/../bin/javadoc" + extension );
   
  -        if (jdocExecutable.exists())
  +        if (jdocExecutable.exists() && !Os.isFamily("netware"))
           {
               return jdocExecutable.getAbsolutePath();
           }
           else
           {
  -            log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
  -                 ". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
  +            if (!Os.isFamily("netware")) {
  +                log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
  +                     ". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
  +            }
               return "javadoc";
           }
       }
  
  
  
  1.5       +17 -5     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  
  Index: Os.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/Os.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Os.java	2001/10/31 11:02:23	1.4
  +++ Os.java	2001/11/02 07:56:53	1.5
  @@ -62,9 +62,13 @@
    * Condition that tests the OS type.
    *
    * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class Os implements Condition {
  +    private static final String osName =
  +        System.getProperty("os.name").toLowerCase(Locale.US);
  +    private static final String pathSep = System.getProperty("path.separator");
  +
       private String family;
   
       public Os() {}
  @@ -93,8 +97,16 @@
        * @see Os#setFamily(String)
        */
       public boolean eval() throws BuildException {
  -        String osName = System.getProperty("os.name").toLowerCase(Locale.US);
  -        String pathSep = System.getProperty("path.separator");
  +        return isFamily(family);
  +    }
  +
  +    /**
  +     * Determines if the OS on which Ant is executing matches the
  +     * given OS family.
  +     *
  +     * @since 1.5
  +     */
  +    public static boolean isFamily(String family) {
           if (family != null) {
               if (family.equals("windows")) {
                   return osName.indexOf("windows") > -1;
  @@ -103,12 +115,12 @@
               } else if (family.equals("netware")) {
                   return osName.indexOf("netware") > -1;
               } else if (family.equals("dos")) {
  -                return pathSep.equals(";");
  +                return pathSep.equals(";") && !isFamily("netware");
               } else if (family.equals("mac")) {
                   return osName.indexOf("mac") > -1;
               } else if (family.equals("unix")) {
                   return pathSep.equals(":")
  -                    && (!osName.startsWith("mac") || osName.endsWith("x"));
  +                    && (!isFamily("mac") || osName.endsWith("x"));
               }
               throw new BuildException("Don\'t know how to detect os family \""
                                        + family + "\"");
  
  
  
  1.10      +1 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  
  Index: Cab.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Cab.java	2001/10/31 11:04:59	1.9
  +++ Cab.java	2001/11/02 07:56:53	1.10
  @@ -92,7 +92,6 @@
       protected String archiveType = "cab";
   
       private static String myos;
  -    private static boolean isWindows = (new Os("windows")).eval();
   
       /**
        * This is the name/location of where to 
  @@ -310,7 +309,7 @@
           log("Building "+ archiveType +": "+ cabFile.getAbsolutePath());
   
           // we must be on Windows to continue
  -        if (!isWindows) {
  +        if (Os.isFamily("windows")) {
               log("Using listcab/libcabinet", Project.MSG_VERBOSE);
               
               StringBuffer sb = new StringBuffer();
  
  
  
  1.20      +5 -2      jakarta-ant/src/main/org/apache/tools/ant/types/CommandlineJava.java
  
  Index: CommandlineJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- CommandlineJava.java	2001/10/31 11:05:00	1.19
  +++ CommandlineJava.java	2001/11/02 07:56:53	1.20
  @@ -347,7 +347,7 @@
       private String getJavaExecutableName() {
   	// This is the most common extension case - exe for windows and OS/2, 
           // nothing for *nix.
  -	String extension =  (new Os("dos")).eval() ? ".exe" : "";
  +	String extension =  Os.isFamily("dos") ? ".exe" : "";
   
   	// Look for java in the java.home/../bin directory.  Unfortunately
   	// on Windows java.home doesn't always refer to the correct location, 
  @@ -357,7 +357,10 @@
               new java.io.File(System.getProperty("java.home") +
                                "/../bin/java" + extension );
   
  -	if (jExecutable.exists()) {
  +	if (jExecutable.exists() && !Os.isFamily("netware")) {
  +            // NetWare may have a "java" in that directory, but 99% of
  +            // the time, you don't want to execute it -- Jeff Tulley
  +            // <JT...@novell.com>
   	    return jExecutable.getAbsolutePath();
   	} else {
   	    return "java";
  
  
  
  1.10      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java
  
  Index: SourceFileScanner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SourceFileScanner.java	2001/10/31 11:05:00	1.9
  +++ SourceFileScanner.java	2001/11/02 07:56:53	1.10
  @@ -107,7 +107,7 @@
             be able to check file modification times.
             (Windows has a max resolution of two secs for modification times)
           */
  -        if ((new Os("windows")).eval()) {
  +        if (Os.isFamily("windows")) {
               now += 2000;
           }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>