Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 80584 invoked from network); 10 Feb 2002 00:27:19 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 10 Feb 2002 00:27:19 -0000 Received: (qmail 369 invoked by uid 97); 10 Feb 2002 00:27:19 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 348 invoked by uid 97); 10 Feb 2002 00:27:18 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 337 invoked by uid 97); 10 Feb 2002 00:27:18 -0000 Date: 10 Feb 2002 00:27:10 -0000 Message-ID: <20020210002710.62090.qmail@icarus.apache.org> From: donaldp@apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive Jar.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N donaldp 02/02/09 16:27:10 Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest Section.java ManifestTask.java Manifest.java proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive Jar.java Added: proposal/myrmidon/src/java/org/apache/aut/manifest ManifestUtil.java Removed: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest ManifestUtil.java Log: Move manifestUtil into aut package Revision Changes Path 1.4 +2 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/Section.java Index: Section.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/Section.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Section.java 9 Feb 2002 05:51:20 -0000 1.3 +++ Section.java 10 Feb 2002 00:27:10 -0000 1.4 @@ -16,6 +16,7 @@ import java.util.Iterator; import org.apache.aut.manifest.Attribute; import org.apache.aut.manifest.ManifestException; +import org.apache.aut.manifest.ManifestUtil; /** * Class to represent an individual section in the Manifest. A section @@ -25,7 +26,7 @@ * @author Conor MacNeill * @author Stefan Bodewig * @author Peter Donald - * @version $Revision: 1.3 $ $Date: 2002/02/09 05:51:20 $ + * @version $Revision: 1.4 $ $Date: 2002/02/10 00:27:10 $ */ public class Section { 1.3 +2 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/ManifestTask.java Index: ManifestTask.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/ManifestTask.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ManifestTask.java 9 Feb 2002 05:51:20 -0000 1.2 +++ ManifestTask.java 10 Feb 2002 00:27:10 -0000 1.3 @@ -19,6 +19,7 @@ import org.apache.myrmidon.api.TaskException; import org.apache.aut.manifest.Attribute; import org.apache.aut.manifest.ManifestException; +import org.apache.aut.manifest.ManifestUtil; /** * Class to manage Manifest information @@ -26,7 +27,7 @@ * @author Peter Donald * @author Conor MacNeill * @author Stefan Bodewig - * @version $Revision: 1.2 $ $Date: 2002/02/09 05:51:20 $ + * @version $Revision: 1.3 $ $Date: 2002/02/10 00:27:10 $ */ public class ManifestTask extends AbstractTask 1.5 +2 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/Manifest.java Index: Manifest.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/manifest/Manifest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Manifest.java 9 Feb 2002 05:51:20 -0000 1.4 +++ Manifest.java 10 Feb 2002 00:27:10 -0000 1.5 @@ -15,6 +15,7 @@ import org.apache.myrmidon.api.TaskException; import org.apache.aut.manifest.Attribute; import org.apache.aut.manifest.ManifestException; +import org.apache.aut.manifest.ManifestUtil; /** * Class to manage Manifest information @@ -22,7 +23,7 @@ * @author Peter Donald * @author Conor MacNeill * @author Stefan Bodewig - * @version $Revision: 1.4 $ $Date: 2002/02/09 05:51:20 $ + * @version $Revision: 1.5 $ $Date: 2002/02/10 00:27:10 $ */ public class Manifest { 1.1 jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/manifest/ManifestUtil.java Index: ManifestUtil.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.aut.manifest; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.io.BufferedReader; import java.util.jar.Attributes; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.taskdefs.manifest.Manifest; import org.apache.tools.ant.taskdefs.manifest.Section; /** * Utility methods for manifest stuff. * * @author Conor MacNeill * @author Stefan Bodewig * @author Peter Donald * @version $Revision: 1.1 $ $Date: 2002/02/10 00:27:10 $ */ public final class ManifestUtil { /** * The Name Attribute is the first in a named section */ public final static String ATTRIBUTE_NAME = "Name"; /** * The From Header is disallowed in a Manifest */ public final static String ATTRIBUTE_FROM = "From"; /** * The Class-Path Header is special - it can be duplicated */ public final static String ATTRIBUTE_CLASSPATH = Attributes.Name.CLASS_PATH.toString(); /** * Default Manifest version if one is not specified */ public final static String DEFAULT_MANIFEST_VERSION = "1.0"; /** * The max length of a line in a Manifest */ public final static int MAX_LINE_LENGTH = 70; public static Attribute buildAttribute( final String line ) throws ManifestException { final Attribute attribute = new Attribute(); parse( attribute, line ); return attribute; } public static Manifest buildManifest( final Reader reader ) throws ManifestException, IOException { final Manifest manifest = new Manifest(); BufferedReader bufferedReader = new BufferedReader( reader ); // This should be the manifest version final Section mainSection = manifest.getMainSection(); String nextSectionName = mainSection.read( bufferedReader ); final String readManifestVersion = mainSection.getAttributeValue( Attributes.Name.MANIFEST_VERSION.toString() ); if( readManifestVersion != null ) { manifest.setManifestVersion( readManifestVersion ); mainSection.removeAttribute( Attributes.Name.MANIFEST_VERSION.toString() ); } String line = null; while( ( line = bufferedReader.readLine() ) != null ) { if( line.length() == 0 ) { continue; } Section section = new Section(); if( nextSectionName == null ) { Attribute sectionName = ManifestUtil.buildAttribute( line ); if( !sectionName.getName().equalsIgnoreCase( ManifestUtil.ATTRIBUTE_NAME ) ) { throw new ManifestException( "Manifest sections should start with a \"" + ManifestUtil.ATTRIBUTE_NAME + "\" attribute and not \"" + sectionName.getName() + "\"" ); } nextSectionName = sectionName.getValue(); } else { // we have already started reading this section // this line is the first attribute. set it and then let the normal // read handle the rest Attribute firstAttribute = ManifestUtil.buildAttribute( line ); section.addAttributeAndCheck( firstAttribute ); } section.setName( nextSectionName ); nextSectionName = section.read( bufferedReader ); manifest.addSection( section ); } return manifest; } /** * Construct a manifest from Ant's default manifest file. */ public static Manifest getDefaultManifest() throws ManifestException { try { final InputStream input = getInputStream(); final InputStreamReader reader = getReader( input ); return buildManifest( reader ); } catch( final IOException ioe ) { throw new ManifestException( "Unable to read default manifest", ioe ); } } private static InputStream getInputStream() throws ManifestException { final String location = "default.mf"; final InputStream input = ManifestUtil.class.getResourceAsStream( location ); if( null == input ) { throw new ManifestException( "Could not find default manifest: " + location ); } return input; } private static InputStreamReader getReader( final InputStream input ) { try { return new InputStreamReader( input, "ASCII" ); } catch( final UnsupportedEncodingException uee ) { return new InputStreamReader( input ); } } /** * Parse a line into name and value pairs * * @param line the line to be parsed * @throws ManifestException if the line does not contain a colon * separating the name and value */ public static void parse( final Attribute attribute, final String line ) throws ManifestException { final int index = line.indexOf( ": " ); if( index == -1 ) { throw new ManifestException( "Manifest line \"" + line + "\" is not valid as it does not " + "contain a name and a value separated by ': ' " ); } final String name = line.substring( 0, index ); final String value = line.substring( index + 2 ); attribute.setName( name ); attribute.setValue( value ); } public static void write( final Attribute attribute, final PrintWriter writer ) throws IOException { final String name = attribute.getName(); final String value = attribute.getValue(); String line = name + ": " + value; while( line.getBytes().length > MAX_LINE_LENGTH ) { // try to find a MAX_LINE_LENGTH byte section int breakIndex = MAX_LINE_LENGTH; String section = line.substring( 0, breakIndex ); while( section.getBytes().length > MAX_LINE_LENGTH && breakIndex > 0 ) { breakIndex--; section = line.substring( 0, breakIndex ); } if( breakIndex == 0 ) { throw new IOException( "Unable to write manifest line " + name + ": " + value ); } writer.println( section ); line = " " + line.substring( breakIndex ); } writer.println( line ); } /** * Write the manifest out to a print writer. * * @param writer the Writer to which the manifest is written * @throws IOException if the manifest cannot be written */ public static void write( Manifest manifest, PrintWriter writer ) throws IOException { final String sigVersionKey = Attributes.Name.SIGNATURE_VERSION.toString(); writer.println( Attributes.Name.MANIFEST_VERSION + ": " + manifest.getManifestVersion() ); final String signatureVersion = manifest.getMainSection().getAttributeValue( sigVersionKey ); if( signatureVersion != null ) { writer.println( Attributes.Name.SIGNATURE_VERSION + ": " + signatureVersion ); manifest.getMainSection().removeAttribute( sigVersionKey ); } manifest.getMainSection().write( writer ); if( signatureVersion != null ) { try { manifest.getMainSection().addAttribute( new Attribute( sigVersionKey, signatureVersion ) ); } catch( ManifestException e ) { // shouldn't happen - ignore } } final Section[] sections = manifest.getSections(); for( int i = 0; i < sections.length; i++ ) { sections[ i ].write( writer ); } } } 1.6 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Jar.java Index: Jar.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Jar.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Jar.java 9 Feb 2002 05:51:20 -0000 1.5 +++ Jar.java 10 Feb 2002 00:27:10 -0000 1.6 @@ -23,7 +23,7 @@ import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.taskdefs.manifest.Manifest; import org.apache.aut.manifest.ManifestException; -import org.apache.tools.ant.taskdefs.manifest.ManifestUtil; +import org.apache.aut.manifest.ManifestUtil; import org.apache.tools.ant.types.FileScanner; /** -- To unsubscribe, e-mail: For additional commands, e-mail: