From 420e7ff2b3e9b9abd9752ebd6dbcccf17558e512 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Tue, 30 Apr 2002 07:54:19 +0000 Subject: [PATCH] Moved getManifest method to ExtensionUtil to make method usable from other locaitons git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272611 13f79535-47bb-0310-9956-ffa450edef68 --- .../optional/extension/ExtensionUtil.java | 24 +++++++++++++++++ .../optional/extension/LibraryDisplayer.java | 26 +------------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java index 6acab9433..22d1576bc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java @@ -54,9 +54,11 @@ package org.apache.tools.ant.taskdefs.optional.extension; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.jar.JarFile; +import java.util.jar.Manifest; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; @@ -235,4 +237,26 @@ public class ExtensionUtil extensionList.add( extension ); } + + /** + * retrieve manifest for specified file. + * + * @param file the file + * @return the manifest + * @throws BuildException if errror occurs (file not exist, + * file not a jar, manifest not exist in file) + */ + static Manifest getManifest( final File file ) + throws BuildException + { + try + { + final JarFile jarFile = new JarFile( file ); + return jarFile.getManifest(); + } + catch( final IOException ioe ) + { + throw new BuildException( ioe.getMessage(), ioe ); + } + } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java index 141bcdeb1..6077658b1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java @@ -54,9 +54,7 @@ package org.apache.tools.ant.taskdefs.optional.extension; import java.io.File; -import java.io.IOException; import java.text.ParseException; -import java.util.jar.JarFile; import java.util.jar.Manifest; import org.apache.tools.ant.BuildException; @@ -80,7 +78,7 @@ class LibraryDisplayer void displayLibrary( final File file ) throws BuildException { - final Manifest manifest = getManifest( file ); + final Manifest manifest = ExtensionUtil.getManifest( file ); displayLibrary( file, manifest ); } @@ -209,26 +207,4 @@ class LibraryDisplayer } System.out.println( specification.toString() ); } - - /** - * retrieve manifest for specified file. - * - * @param file the file - * @return the manifest - * @throws BuildException if errror occurs (file not exist, - * file not a jar, manifest not exist in file) - */ - private Manifest getManifest( final File file ) - throws BuildException - { - try - { - final JarFile jarFile = new JarFile( file ); - return jarFile.getManifest(); - } - catch( final IOException ioe ) - { - throw new BuildException( ioe.getMessage(), ioe ); - } - } }