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 ); - } - } }