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/testcases/org/apache/tools/ant/taskdefs ManifestTest.java
Date Thu, 11 Nov 2004 17:48:36 GMT
stevel      2004/11/11 09:48:36

  Modified:    docs/manual/CoreTasks manifest.html
               src/etc/testcases/taskdefs manifest.xml
               src/main/org/apache/tools/ant/taskdefs Manifest.java
                        ManifestTask.java
               src/testcases/org/apache/tools/ant/taskdefs
                        ManifestTest.java
  Log:
  Manifest task logs warnings: PR32190
  
  Revision  Changes    Path
  1.10      +11 -1     ant/docs/manual/CoreTasks/manifest.html
  
  Index: manifest.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/manifest.html,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- manifest.html	9 Feb 2004 21:50:05 -0000	1.9
  +++ manifest.html	11 Nov 2004 17:48:36 -0000	1.10
  @@ -14,13 +14,23 @@
   <p>This task can be used to write a Manifest file, optionally
   replacing or updating an existing file.</p>
   
  +<p>
  +The Ant team regularly gets complaints that this task in generating invalid
  +manifests. By and large, this is not the case: we believe that we are following
  +the specification to the letter. The usual problem is that some third party
  +manifest reader is not following the same specification as well as they think
  +they should; we cannot generate invalid manifest files just because one
  +single application is broken.
  +</p>  
  +
   <p>Manifests are processed according to the 
  -<a href="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">Jar
  +<a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html">Jar
   file specification.</a>. Specifically, a manifest element consists of
   a set of attributes and sections. These sections in turn may contain
   attributes. Note in particular that this may result in manifest lines
   greater than 72 bytes being wrapped and continued on the next
   line.</p>
  +
   
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
  
  
  
  1.8       +11 -0     ant/src/etc/testcases/taskdefs/manifest.xml
  
  Index: manifest.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/manifest.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- manifest.xml	4 Oct 2002 12:43:46 -0000	1.7
  +++ manifest.xml	11 Nov 2004 17:48:36 -0000	1.8
  @@ -202,6 +202,17 @@
       </manifest>
     </target>
   
  +
  +  <target name="testFrom">
  +    <manifest file="mftestfrom.mf" >
  +      <section name="Test">
  +        <attribute name="before" value="before" />
  +        <attribute name="From" value="illegal"/>
  +        <attribute name="after" value="after" />
  +      </section>
  +    </manifest>
  +  </target>
  +
     <target name="clean">
       <delete>
         <fileset dir="." includes="mftest*"/>
  
  
  
  1.54      +3 -2      ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  
  Index: Manifest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- Manifest.java	9 Mar 2004 16:48:06 -0000	1.53
  +++ Manifest.java	11 Nov 2004 17:48:36 -0000	1.54
  @@ -79,6 +79,8 @@
   
       /** The End-Of-Line marker in manifests */
       public static final String EOL = "\r\n";
  +    public static final String ERROR_FROM_FORBIDDEN = "Manifest attributes should not start
"
  +                        + "with \"" + ATTRIBUTE_FROM + "\" in \"";
   
       /**
        * An attribute for the manifest.
  @@ -566,8 +568,7 @@
               }
   
               if (attribute.getKey().startsWith(ATTRIBUTE_FROM.toLowerCase())) {
  -                warnings.addElement("Manifest attributes should not start "
  -                    + "with \"" + ATTRIBUTE_FROM + "\" in \""
  +                warnings.addElement(ERROR_FROM_FORBIDDEN
                       + attribute.getName() + ": " + attribute.getValue() + "\"");
               } else {
                   // classpath attributes go into a vector
  
  
  
  1.17      +10 -7     ant/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
  
  Index: ManifestTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ManifestTask.java	9 Mar 2004 16:48:06 -0000	1.16
  +++ ManifestTask.java	11 Nov 2004 17:48:36 -0000	1.17
  @@ -24,9 +24,12 @@
   import java.io.OutputStreamWriter;
   import java.io.IOException;
   import java.io.PrintWriter;
  +import java.util.Enumeration;
  +
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.ant.types.EnumeratedAttribute;
   
   /**
  @@ -163,16 +166,16 @@
                   error = new BuildException("Failed to read " + manifestFile,
                                              e, getLocation());
               } finally {
  -                if (isr != null) {
  -                    try {
  -                        isr.close();
  -                    } catch (IOException e) {
  -                        // ignore
  -                    }
  -                }
  +                FileUtils.close(isr);
               }
           }
   
  +        //look for and print warnings
  +        for (Enumeration e = nestedManifest.getWarnings();
  +                e.hasMoreElements();) {
  +            log("Manifest warning: " + (String) e.nextElement(),
  +                    Project.MSG_WARN);
  +        }
           try {
               if (mode.getValue().equals("update") && manifestFile.exists()) {
                   if (current != null) {
  
  
  
  1.14      +5 -1      ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java
  
  Index: ManifestTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ManifestTest.java	9 Mar 2004 16:48:57 -0000	1.13
  +++ ManifestTest.java	11 Nov 2004 17:48:36 -0000	1.14
  @@ -116,7 +116,7 @@
       public void test7() {
           executeTarget("test7");
   
  -        boolean hasWarning = getLog().indexOf("Manifest attributes should not start with
\"From\"") != -1;
  +        boolean hasWarning = getLog().indexOf(Manifest.ERROR_FROM_FORBIDDEN) != -1;
           assertEquals("Expected warning about From: attribute", true, hasWarning);
       }
   
  @@ -286,6 +286,10 @@
           assertTrue(mfAsString.indexOf("Foo: Baz") > -1);
       }
   
  +    public void testFrom() {
  +        expectLogContaining("testFrom", Manifest.ERROR_FROM_FORBIDDEN);
  +    }
  +    
       /**
        * Reads mftest.mf.
        */
  
  
  

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


Mime
View raw message