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 XmlProperty.java
Date Thu, 09 Jan 2003 08:23:17 GMT
bodewig     2003/01/09 00:23:17

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs XmlProperty.java
  Log:
  Don't fail if the file doesn't exist in <xmlproperty>
  
  PR: 15674
  Submitted by:	Nicola Ken Barozzi <nicolaken at apache dot org>
  
  Revision  Changes    Path
  1.336     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.335
  retrieving revision 1.336
  diff -u -r1.335 -r1.336
  --- WHATSNEW	6 Jan 2003 14:12:36 -0000	1.335
  +++ WHATSNEW	9 Jan 2003 08:23:17 -0000	1.336
  @@ -161,6 +161,8 @@
     works for the code generated by the Sun java compiler. It may not work for
     all compilers.
   
  +* <xmlproperty> will no longer fail if the file to be loaded doesn't exist.
  +
   Changes from Ant 1.5.1Beta1 to 1.5.1
   ====================================
   
  
  
  
  1.10      +33 -24    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
  
  Index: XmlProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XmlProperty.java	6 Nov 2002 08:43:45 -0000	1.9
  +++ XmlProperty.java	9 Jan 2003 08:23:17 -0000	1.10
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -266,32 +266,41 @@
           BufferedInputStream configurationStream = null;
   
           try {
  -            configurationStream =
  -                    new BufferedInputStream(new FileInputStream(src));
  -
  -            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  -
  -            factory.setValidating(validate);
  -            factory.setNamespaceAware(false);
  -
  -            Element topElement = factory.newDocumentBuilder().parse(configurationStream).getDocumentElement();
  -
  -            // Keep a hashtable of attributes added by this task.
  -            // This task is allow to override its own properties
  -            // but not other properties.  So we need to keep track
  -            // of which properties we've added.
  -            addedAttributes = new Hashtable();
  +            log("Loading " + src.getAbsolutePath(), Project.MSG_VERBOSE);
  +           
  +            if (src.exists()) {
  +
  +              configurationStream =
  +                      new BufferedInputStream(new FileInputStream(src));
  +
  +              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  +
  +              factory.setValidating(validate);
  +              factory.setNamespaceAware(false);
  +
  +              Element topElement = factory.newDocumentBuilder().parse(configurationStream).getDocumentElement();
  +
  +              // Keep a hashtable of attributes added by this task.
  +              // This task is allow to override its own properties
  +              // but not other properties.  So we need to keep track
  +              // of which properties we've added.
  +              addedAttributes = new Hashtable();
  +
  +              if (keepRoot) {
  +                  addNodeRecursively(topElement, prefix, null);
  +              } else {
  +                  NodeList topChildren = topElement.getChildNodes();
  +                  int numChildren = topChildren.getLength();
  +                  for (int i = 0; i < numChildren; i++) {
  +                    addNodeRecursively(topChildren.item(i), prefix, null);
  +                  }
  +              }
   
  -            if (keepRoot) {
  -                addNodeRecursively(topElement, prefix, null);
               } else {
  -                NodeList topChildren = topElement.getChildNodes();
  -                int numChildren = topChildren.getLength();
  -                for (int i = 0; i < numChildren; i++) {
  -                    addNodeRecursively(topChildren.item(i), prefix, null);
  -                }
  +                log("Unable to find property file: " + src.getAbsolutePath(),
  +                    Project.MSG_VERBOSE);
               }
  -
  +            
           } catch (SAXException sxe) {
               // Error generated during parsing
               Exception x = sxe;
  
  
  

--
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