Browse Source

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
master
Peter Donald 23 years ago
parent
commit
420e7ff2b3
2 changed files with 25 additions and 25 deletions
  1. +24
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java
  2. +1
    -25
      src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java

+ 24
- 0
src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java View File

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

+ 1
- 25
src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java View File

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

Loading…
Cancel
Save