ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Manifest.java ManifestException.java Mkdir.java Parallel.java Patch.java PathConvert.java
Date Fri, 12 Apr 2002 08:12:55 GMT
bodewig     02/04/12 01:12:55

  Modified:    src/main/org/apache/tools/ant/taskdefs Manifest.java
                        ManifestException.java Mkdir.java Parallel.java
                        Patch.java PathConvert.java
  Log:
  Fix API backwards incompatibilty in PathConvert I had introduced.
  
  Make sure <pathconvert> resets its state (7552).
  
  Cosmetics.
  
  Revision  Changes    Path
  1.30      +9 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  
  Index: Manifest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Manifest.java	4 Apr 2002 13:30:00 -0000	1.29
  +++ Manifest.java	12 Apr 2002 08:12:54 -0000	1.30
  @@ -70,6 +70,7 @@
   import java.io.UnsupportedEncodingException;
   
   import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.EnumeratedAttribute;
   import org.apache.tools.ant.util.CollectionUtils;
  @@ -81,6 +82,8 @@
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:j_a_fernandez@yahoo.com">Jose Alberto Fernandez</a>
    *
  + * @since Ant 1.4
  + *
    * @ant.task category="java"
    */
   public class Manifest extends Task {
  @@ -553,7 +556,7 @@
               String check = addAttributeAndCheck(attribute);
               if (check != null) {
                   throw new BuildException("Specify the section name using " 
  -                    + "the \"name\" attribute of the <section> element rather " 
  +                    + "the \"name\" attribute of the <section> element rather "
                       + "than using a \"Name\" manifest attribute");
               }
           }
  @@ -691,7 +694,6 @@
       /**
        * Construct a manifest from Ant's default manifest file.
        *
  -     *
        * @return the default manifest.
        * @exception BuildException if there is a problem loading the 
        *            default manifest
  @@ -1031,7 +1033,7 @@
       /**
        * Create or update the Manifest when used as a task.
        *
  -     * @throws BuildException if the manifst cannot be written.
  +     * @throws BuildException if the manifest cannot be written.
        */
       public void execute() throws BuildException {
           if (manifestFile == null) {
  @@ -1049,10 +1051,10 @@
                   current = new Manifest(f);
               } catch (ManifestException m) {
                   error = new BuildException("Existing manifest " + manifestFile
  -                                         + " is invalid", m, location);
  +                                           + " is invalid", m, location);
               } catch (IOException e) {
                   error = new BuildException("Failed to read " + manifestFile,
  -                                         e, location);
  +                                           e, location);
               } finally {
                   if (f != null) {
                       try {
  @@ -1078,7 +1080,8 @@
           }
   
           if (toWrite.equals(current)) {
  -            log("Manifest has not changed, do not recreate", project.MSG_VERBOSE);
  +            log("Manifest has not changed, do not recreate", 
  +                Project.MSG_VERBOSE);
               return;
           }
   
  
  
  
  1.5       +1 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ManifestException.java
  
  Index: ManifestException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ManifestException.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ManifestException.java	19 Mar 2002 07:02:11 -0000	1.4
  +++ ManifestException.java	12 Apr 2002 08:12:54 -0000	1.5
  @@ -53,13 +53,11 @@
    */
   package org.apache.tools.ant.taskdefs;
   
  -
  -
  -
   /**
    * Exception thrown indicating problems in a JAR Manifest
    *
    * @author Conor MacNeill
  + * @since Ant 1.4
    */
   public class ManifestException extends Exception {
   
  
  
  
  1.18      +6 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Mkdir.java
  
  Index: Mkdir.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Mkdir.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Mkdir.java	3 Mar 2002 01:46:20 -0000	1.17
  +++ Mkdir.java	12 Apr 2002 08:12:54 -0000	1.18
  @@ -62,6 +62,7 @@
    * Creates a given directory.
    *
    * @author duncan@x180.com
  + * @since Ant 1.1
    *
    * @ant.task category="filesystem"
    */
  @@ -76,14 +77,16 @@
           }
   
           if (dir.isFile()) {
  -            throw new BuildException("Unable to create directory as a file already exists
with that name: " + dir.getAbsolutePath());
  +            throw new BuildException("Unable to create directory as a file "
  +                                     + "already exists with that name: " 
  +                                     + dir.getAbsolutePath());
           }
   
           if (!dir.exists()) {
               boolean result = dir.mkdirs();
               if (!result) {
  -                String msg = "Directory " + dir.getAbsolutePath() + " creation was not
" +
  -                    "successful for an unknown reason";
  +                String msg = "Directory " + dir.getAbsolutePath() 
  +                    + " creation was not successful for an unknown reason";
                   throw new BuildException(msg, location);
               }
               log("Created dir: " + dir.getAbsolutePath());
  
  
  
  1.8       +7 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Parallel.java
  
  Index: Parallel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Parallel.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Parallel.java	18 Mar 2002 02:44:29 -0000	1.7
  +++ Parallel.java	12 Apr 2002 08:12:54 -0000	1.8
  @@ -57,6 +57,7 @@
   import org.apache.tools.ant.TaskContainer;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Location;
  +import org.apache.tools.ant.util.StringUtils;
   
   import java.util.Vector;
   import java.util.Enumeration;
  @@ -68,6 +69,7 @@
    * <p>
    * @author Thomas Christen <a href="mailto:chr@active.ch">chr@active.ch</a>
    * @author Conor MacNeill
  + * @since Ant 1.4
    *
    * @ant.task category="control"
    */
  @@ -95,7 +97,8 @@
       public void execute() throws BuildException {
           TaskThread[] threads = new TaskThread[nestedTasks.size()];
           int threadNumber = 0;
  -        for (Enumeration e = nestedTasks.elements(); e.hasMoreElements(); threadNumber++)
{
  +        for (Enumeration e = nestedTasks.elements(); e.hasMoreElements(); 
  +             threadNumber++) {
               Task nestedTask = (Task)e.nextElement();
               threads[threadNumber] = new TaskThread(threadNumber, nestedTask);
           }
  @@ -117,7 +120,6 @@
           
           // now did any of the threads throw an exception
           StringBuffer exceptionMessage = new StringBuffer();
  -        String lSep = System.getProperty("line.separator");
           int numExceptions = 0;
           Throwable firstException = null;
           Location firstLocation = Location.UNKNOWN_LOCATION;;
  @@ -132,7 +134,7 @@
                           firstLocation == Location.UNKNOWN_LOCATION) {
                       firstLocation = ((BuildException)t).getLocation();
                   }
  -                exceptionMessage.append(lSep);
  +                exceptionMessage.append(StringUtils.LINE_SEP);
                   exceptionMessage.append(t.getMessage());
               }
           }
  @@ -146,7 +148,8 @@
               }
           }
           else if (numExceptions > 1) {
  -            throw new BuildException(exceptionMessage.toString(), firstLocation);
  +            throw new BuildException(exceptionMessage.toString(), 
  +                                     firstLocation);
           }
       }
   
  
  
  
  1.13      +2 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Patch.java
  
  Index: Patch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Patch.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Patch.java	3 Mar 2002 01:46:20 -0000	1.12
  +++ Patch.java	12 Apr 2002 08:12:54 -0000	1.13
  @@ -66,6 +66,8 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="utility"
    */
   public class Patch extends Task {
  
  
  
  1.15      +129 -97   jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  
  Index: PathConvert.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/PathConvert.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PathConvert.java	2 Apr 2002 15:48:53 -0000	1.14
  +++ PathConvert.java	12 Apr 2002 08:12:54 -0000	1.15
  @@ -70,35 +70,39 @@
   import java.io.File;
   
   /**
  - * This task converts path and classpath information to a specific target OS format.
  - * The resulting formatted path is placed into a specified property.
  - * <p>
  - * LIMITATION: Currently this implementation groups all machines into one of two
  - * types: Unix or Windows.  Unix is defined as NOT windows.
  + * This task converts path and classpath information to a specific
  + * target OS format.  The resulting formatted path is placed into a
  + * specified property.
    *
    * @author Larry Streepy <a href="mailto:streepy@healthlanguage.com">streepy@healthlanguage.com</a>
    *
  + * @since Ant 1.4
  + *
    * @ant.task category="utility"
    */
   public class PathConvert extends Task {
   
  +    public PathConvert() {
  +        onWindows = Os.isFamily("dos");
  +    }
  +
       /**
  -     * Helper class, holds the nested <map> values.  Elements will look like this:
  -     * &lt;map from="d:" to="/foo"/&gt;
  +     * Helper class, holds the nested <map> values.  Elements will
  +     * look like this: &lt;map from=&quot;d:&quot; to=&quot;/foo&quot;/&gt;
        * <p>
        * When running on windows, the prefix comparison will be case insensitive.
        */
       public class MapEntry {
   
           /**
  -         * Set the "from" attribute of the map entry
  +         * Set the &quot;from&quot; attribute of the map entry
            */
           public void setFrom( String from ) {
               this.from = from;
           }
   
           /**
  -         * Set the "to" attribute of the map entry
  +         * Set the &quot;to&quot; attribute of the map entry
            */
           public void setTo( String to ) {
               this.to = to;
  @@ -111,15 +115,16 @@
            */
           public String apply( String elem ) {
               if( from == null || to == null ) {
  -                throw new BuildException( "Both 'from' and 'to' must be set in a map entry"
);
  +                throw new BuildException( "Both 'from' and 'to' must be set "
  +                                          + "in a map entry" );
               }
   
               // If we're on windows, then do the comparison ignoring case
               String cmpElem = onWindows ? elem.toLowerCase() : elem;
               String cmpFrom = onWindows ? from.toLowerCase() : from;
   
  -            // If the element starts with the configured prefix, then convert the prefix
  -            // to the configured 'to' value.
  +            // If the element starts with the configured prefix, then
  +            // convert the prefix to the configured 'to' value.
   
               if( cmpElem.startsWith( cmpFrom ) ) {
                   int len = from.length();
  @@ -170,8 +175,21 @@
           return entry;
       }
   
  +
  +    /**
  +     * Set the value of the targetos attribute
  +     * @deprecated use the method taking a TargetOs argument instead
  +     * @see #setTargetos(TargetOs)
  +     */
  +    public void setTargetos( String target ) {
  +        TargetOs to = new TargetOs();
  +        to.setValue(target);
  +        setTargetos(to);
  +    }
  +
       /**
        * Set the value of the targetos attribute
  +     * @since Ant 1.5
        */
       public void setTargetos( TargetOs target ) {
   
  @@ -180,7 +198,7 @@
           // Currently, we deal with only two path formats: Unix and Windows
           // And Unix is everything that is not Windows
   
  -        // for NetWare and os/2, piggy-back on Windows, since in the
  +        // for NetWare and OS/2, piggy-back on Windows, since in the
           // validateSetup code, the same assumptions can be made as
           // with windows - that ; is the path separator
   
  @@ -232,84 +250,94 @@
        * Do the execution.
        */
       public void execute() throws BuildException {
  -
  -        // If we are a reference, create a Path from the reference
  -        if( isReference() ) {
  -            path = new Path(getProject()).createPath();
  -
  -            Object obj = refid.getReferencedObject(getProject());
  -
  -            if( obj instanceof Path ) {
  -                path.setRefid(refid);
  -            } else if( obj instanceof FileSet ) {
  -                FileSet fs = (FileSet)obj;
  -                path.addFileset( fs );
  -            } else if( obj instanceof DirSet ) {
  -                DirSet ds = (DirSet)obj;
  -                path.addDirset( ds );
  -            } else if( obj instanceof FileList ) {
  -                FileList fl = (FileList)obj;
  -                path.addFilelist( fl );
  +        Path savedPath = path;
  +        String savedPathSep = pathSep; // may be altered in validateSetup
  +        String savedDirSep = dirSep; // may be altered in validateSetup
  +
  +        try {
  +            // If we are a reference, create a Path from the reference
  +            if( isReference() ) {
  +                path = new Path(getProject()).createPath();
                   
  -            } else {
  -                throw new BuildException( "'refid' does not refer to a path, fileset, dirset,
or filelist." );
  -            }
  -        }
  -
  -        validateSetup();                    // validate our setup
  -
  -        // Currently, we deal with only two path formats: Unix and Windows
  -        // And Unix is everything that is not Windows
  -        // (with the exception for NetWare below)
  -
  -        // for NetWare and OS/2, piggy-back on Windows, since here and
  -        // in the apply code, the same assumptions can be made as with
  -        // windows - that \\ is an OK separator, and do comparisons
  -        // case-insensitive.
  -        onWindows = Os.isFamily("dos");
  -
  -        String fromDirSep = onWindows ? "\\" : "/";
  -
  -        StringBuffer rslt = new StringBuffer( 100 );
  -
  -        // Get the list of path components in canonical form
  -        String[] elems = path.list();
  -
  -        for( int i=0; i < elems.length; i++ ) {
  -            String elem = elems[i];
  -
  -            elem = mapElement( elem );      // Apply the path prefix map
  -
  -
  -            // Now convert the path and file separator characters from the
  -            // current os to the target os.
  -
  -            if( i != 0 ) {
  -                rslt.append( pathSep );
  +                Object obj = refid.getReferencedObject(getProject());
  +                
  +                if( obj instanceof Path ) {
  +                    path.setRefid(refid);
  +                } else if( obj instanceof FileSet ) {
  +                    FileSet fs = (FileSet)obj;
  +                    path.addFileset( fs );
  +                } else if( obj instanceof DirSet ) {
  +                    DirSet ds = (DirSet)obj;
  +                    path.addDirset( ds );
  +                } else if( obj instanceof FileList ) {
  +                    FileList fl = (FileList)obj;
  +                    path.addFilelist( fl );
  +                    
  +                } else {
  +                    throw new BuildException( "'refid' does not refer to a "
  +                                              + "path, fileset, dirset, or "
  +                                              + "filelist." );
  +                }
               }
  -
  -            StringTokenizer stDirectory = 
  -                new StringTokenizer(elem, fromDirSep, true);
  -            String token = null;
  -
  -            while ( stDirectory.hasMoreTokens() ) {
  -                token = stDirectory.nextToken();
  -
  -                if (fromDirSep.equals(token)) {
  -                    rslt.append( dirSep ); 
  +            
  +            validateSetup();                    // validate our setup
  +            
  +            // Currently, we deal with only two path formats: Unix and Windows
  +            // And Unix is everything that is not Windows
  +            // (with the exception for NetWare and OS/2 below)
  +            
  +            // for NetWare and OS/2, piggy-back on Windows, since here and
  +            // in the apply code, the same assumptions can be made as with
  +            // windows - that \\ is an OK separator, and do comparisons
  +            // case-insensitive.
  +            String fromDirSep = onWindows ? "\\" : "/";
  +            
  +            StringBuffer rslt = new StringBuffer( 100 );
  +            
  +            // Get the list of path components in canonical form
  +            String[] elems = path.list();
  +            
  +            for( int i=0; i < elems.length; i++ ) {
  +                String elem = elems[i];
  +                
  +                elem = mapElement( elem );      // Apply the path prefix map
  +                
  +                
  +                // Now convert the path and file separator characters from the
  +                // current os to the target os.
  +                
  +                if( i != 0 ) {
  +                    rslt.append( pathSep );
                   }
  -                else {
  -                    rslt.append( token );
  +                
  +                StringTokenizer stDirectory = 
  +                    new StringTokenizer(elem, fromDirSep, true);
  +                String token = null;
  +                
  +                while ( stDirectory.hasMoreTokens() ) {
  +                    token = stDirectory.nextToken();
  +                    
  +                    if (fromDirSep.equals(token)) {
  +                        rslt.append( dirSep ); 
  +                    }
  +                    else {
  +                        rslt.append( token );
  +                    }
                   }
               }
  -        }
  -
  -        // Place the result into the specified property
  -        String value = rslt.toString();
  -
  -        log( "Set property " + property + " = " + value, Project.MSG_VERBOSE );
   
  -        getProject().setNewProperty( property, value );
  +            // Place the result into the specified property
  +            String value = rslt.toString();
  +            
  +            log( "Set property " + property + " = " + value, 
  +                 Project.MSG_VERBOSE );
  +            
  +            getProject().setNewProperty( property, value );
  +        } finally {
  +            path = savedPath;
  +            dirSep = savedDirSep;
  +            pathSep = savedPathSep;
  +        }
       }
   
       /**
  @@ -363,7 +391,8 @@
           // Must either have a target OS or both a dirSep and pathSep
   
           if( targetOS == null && pathSep == null && dirSep == null ) {
  -            throw new BuildException( "You must specify at least one of targetOS, dirSep,
or pathSep" );
  +            throw new BuildException( "You must specify at least one of "
  +                                      + "targetOS, dirSep, or pathSep" );
           }
   
           // Determine the separator strings.  The dirsep and pathsep attributes
  @@ -393,19 +422,22 @@
        * not have child elements if the refid attribute is set.  
        */
       private BuildException noChildrenAllowed() {
  -        return new BuildException("You must not specify nested <path> elements when
using the refid attribute.");
  +        return new BuildException("You must not specify nested <path> "
  +                                  + "elements when using the refid attribute.");
       }
   
  -
       // Members
  -    private Path path = null;               // Path to be converted
  -    private Reference refid = null;         // Reference to path/fileset to convert
  -    private String targetOS = null;         // The target OS type
  -    private boolean targetWindows = false;  // Set when targetOS is set
  -    private boolean onWindows = false;      // Set if we're running on windows
  -    private String property = null;         // The property to receive the results
  -    private Vector prefixMap = new Vector();  // Path prefix map
  -    private String pathSep = null;          // User override on path sep char
  -    private String dirSep = null;           // User override on directory sep char
  +    private Path path = null;                // Path to be converted
  +    private Reference refid = null;          // Reference to path/fileset to 
  +                                             // convert
  +    private String targetOS = null;          // The target OS type
  +    private boolean targetWindows = false;   // Set when targetOS is set
  +    private boolean onWindows = false;       // Set if we're running on windows
  +    private String property = null;          // The property to receive the 
  +                                             //results
  +    private Vector prefixMap = new Vector(); // Path prefix map
  +    private String pathSep = null;           // User override on path sep char
  +    private String dirSep = null;            // User override on directory sep
  +                                             // char
   
   }
  
  
  

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


Mime
View raw message