maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r552400 [1/2] - in /maven: plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/ pl...
Date Mon, 02 Jul 2007 04:51:00 GMT
Author: brett
Date: Sun Jul  1 21:50:57 2007
New Revision: 552400

URL: http://svn.apache.org/viewvc?view=rev&rev=552400
Log:
an update to the shared JAR component to prepare it for release and simplify/document its design

Added:
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarFileHashAnalyzer.java   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarHashAnalyzer.java   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java   (contents, props changed)
      - copied, changed from r551486, maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/EmptyRepositoryHashSearch.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java   (contents, props changed)
      - copied, changed from r551486, maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/RepositoryHashSearch.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/javadoc/
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/javadoc/overview.html   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java   (contents, props changed)
      - copied, changed from r551486, maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/identification/
      - copied from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalyzerTest.java
      - copied, changed from r552399, maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/JarIdentificationAnalyzerTest.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/identification/exposers/
      - copied from r552399, maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/exposers/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/ant.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/ant.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/codec.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/codec.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/evil-sealed-regex-1.0.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/evil-sealed-regex-1.0.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.1-debug.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.1-debug.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.1.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.1.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.2-debug.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.2-debug.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.2.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.2.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.3-debug.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.3-debug.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.3.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.3.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.4-debug.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.4-debug.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.4.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.4.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.5-debug.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.5-debug.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.5.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/helloworld-1.5.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/helloworld-1.6.jar   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/invalid-class-file.jar   (with props)
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/invalid.jar
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/resources/jars/jxr.jar   (contents, props changed)
      - copied, changed from r551474, maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/jxr.jar
Removed:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/JarDependencyDetails.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/DefaultJarAnalyzerFactory.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzerException.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzerFactory.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/AbstractJarIdentificationExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/EmptyRepositoryHashSearch.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/RepositoryHashSearch.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/util/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/jars/
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarTestCase.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/taxon/
Modified:
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/Dependencies.java
    maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
    maven/sandbox/trunk/shared/maven-shared-jar/pom.xml
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/FilenameExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/JarAnalyzerTest.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/JarClassesAnalyzerTest.java
    maven/sandbox/trunk/shared/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposerTest.java

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/DependenciesReport.java Sun Jul  1 21:50:57 2007
@@ -31,7 +31,7 @@
 import org.apache.maven.shared.dependency.tree.DependencyTree;
 import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
 import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.jar.JarAnalyzerFactory;
+import org.apache.maven.shared.jar.classes.JarClassesAnalysis;
 
 import java.util.Locale;
 
@@ -68,7 +68,7 @@
      * @component
      */
     private WagonManager wagonManager;
-    
+
     /**
      * @component
      */
@@ -77,8 +77,8 @@
     /**
      * @component
      */
-    private JarAnalyzerFactory jarAnalyzerFactory;
-    
+    private JarClassesAnalysis classesAnalyzer;
+
     /**
      * The current user system settings for use in Maven.
      *
@@ -95,6 +95,7 @@
 
     /**
      * Display the repository locations of the dependencies. Requires Maven 2.0.5+.
+     *
      * @parameter expression="${dependency.locations.enabled}" default-value="false"
      */
     private boolean dependencyLocationsEnabled;
@@ -126,7 +127,7 @@
 
         DependencyTree dependencyTree = resolveProject();
 
-        Dependencies dependencies = new Dependencies( project, dependencyTree, jarAnalyzerFactory );
+        Dependencies dependencies = new Dependencies( project, dependencyTree, classesAnalyzer );
 
         DependenciesReportConfiguration config =
             new DependenciesReportConfiguration( dependencyDetailsEnabled, dependencyLocationsEnabled );
@@ -143,14 +144,14 @@
     {
         try
         {
-            return dependencyTreeBuilder.buildDependencyTree( project, localRepository, factory,
-                                                              artifactMetadataSource, collector );
+            return dependencyTreeBuilder.buildDependencyTree( project, localRepository, factory, artifactMetadataSource,
+                                                              collector );
         }
         catch ( DependencyTreeBuilderException e )
         {
             getLog().error( "Unable to build dependency tree.", e );
             return null;
-        } 
+        }
     }
 
     /**

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/Dependencies.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/Dependencies.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/Dependencies.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/Dependencies.java Sun Jul  1 21:50:57 2007
@@ -25,11 +25,10 @@
 import org.apache.maven.shared.dependency.tree.DependencyNode;
 import org.apache.maven.shared.dependency.tree.DependencyTree;
 import org.apache.maven.shared.jar.JarAnalyzer;
-import org.apache.maven.shared.jar.JarAnalyzerException;
-import org.apache.maven.shared.jar.JarAnalyzerFactory;
-import org.apache.maven.shared.jar.classes.JarClasses;
+import org.apache.maven.shared.jar.JarData;
+import org.apache.maven.shared.jar.classes.JarClassesAnalysis;
 
-import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -38,15 +37,17 @@
 
 public class Dependencies
 {
-    private List projectDependencies;
-    private DependencyTree dependencyTree;
-    private JarAnalyzerFactory jarAnalyzerFactory;
+    private final List projectDependencies;
 
-    public Dependencies( MavenProject project, DependencyTree dependencyTree, JarAnalyzerFactory jarAnalyzerFactory )
+    private final DependencyTree dependencyTree;
+
+    private final JarClassesAnalysis classesAnalyzer;
+
+    public Dependencies( MavenProject project, DependencyTree dependencyTree, JarClassesAnalysis classesAnalyzer )
     {
         this.dependencyTree = dependencyTree;
         this.projectDependencies = dependencyTree.getRootNode().getChildren();
-        this.jarAnalyzerFactory = jarAnalyzerFactory;
+        this.classesAnalyzer = classesAnalyzer;
 
         /*
          * Workaround to ensure proper File objects in the Artifacts from the ReportResolutionListener
@@ -60,8 +61,8 @@
         }
 
         mapArtifactFiles( dependencyTree.getRootNode(), projectMap );
-    } 
-    
+    }
+
     private void mapArtifactFiles( DependencyNode node, Map projectMap )
     {
         List childs = node.getChildren();
@@ -125,15 +126,20 @@
         return dependenciesByScope;
     }
 
-    public JarDependencyDetails getJarDependencyDetails( Artifact artifact )
-        throws JarAnalyzerException
+    public JarData getJarDependencyDetails( Artifact artifact )
+        throws IOException
     {
-        File artifactFile = artifact.getFile();
-        
-        JarAnalyzer jar = jarAnalyzerFactory.getJarAnalyzer( artifactFile ); 
-        
-        JarClasses jarClasses = jar.getClasses();
+        JarAnalyzer jarAnalyzer = new JarAnalyzer( artifact.getFile() );
+
+        try
+        {
+            classesAnalyzer.analyze( jarAnalyzer );
+        }
+        finally
+        {
+            jarAnalyzer.closeQuietly();
+        }
 
-        return new JarDependencyDetails( jarClasses, jar.isSealed(), jar.getEntries() );
+        return jarAnalyzer.getJarData();
     }
 }

Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer/DependenciesRenderer.java Sun Jul  1 21:50:57 2007
@@ -32,17 +32,17 @@
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.report.projectinfo.dependencies.Dependencies;
 import org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration;
-import org.apache.maven.report.projectinfo.dependencies.JarDependencyDetails;
 import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 import org.apache.maven.shared.dependency.tree.DependencyNode;
 import org.apache.maven.shared.dependency.tree.DependencyTree;
-import org.apache.maven.shared.jar.JarAnalyzerException;
+import org.apache.maven.shared.jar.JarData;
 import org.apache.maven.wagon.Wagon;
 import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.IOException;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -174,7 +174,7 @@
             // org.apache.maven.wagon.Wagon.resourceExists(Ljava/lang/String;)Z
             try
             {
-                Wagon.class.getDeclaredMethod( "resourceExists", new Class[] { String.class } );
+                Wagon.class.getDeclaredMethod( "resourceExists", new Class[]{String.class} );
             }
             catch ( NoSuchMethodException e )
             {
@@ -195,7 +195,7 @@
         String classifier = getReportString( "report.dependencies.column.classifier" );
         String type = getReportString( "report.dependencies.column.type" );
         String optional = getReportString( "report.dependencies.column.optional" );
-        return new String[] { groupId, artifactId, version, classifier, type, optional };
+        return new String[]{groupId, artifactId, version, classifier, type, optional};
     }
 
     private void renderSectionProjectDependencies()
@@ -291,18 +291,12 @@
         String debug = getReportString( "report.dependencies.file.details.column.debug" );
         String sealed = getReportString( "report.dependencies.file.details.column.sealed" );
 
-        String[] tableHeader = new String[] { filename, size, entries, classes, packages, jdkrev, debug, sealed };
+        String[] tableHeader = new String[]{filename, size, entries, classes, packages, jdkrev, debug, sealed};
         tableHeader( tableHeader );
 
-        int[] justification = new int[] {
-            Parser.JUSTIFY_LEFT,
-            Parser.JUSTIFY_RIGHT,
-            Parser.JUSTIFY_RIGHT,
-            Parser.JUSTIFY_RIGHT,
-            Parser.JUSTIFY_RIGHT,
-            Parser.JUSTIFY_CENTER,
-            Parser.JUSTIFY_CENTER,
-            Parser.JUSTIFY_CENTER };
+        int[] justification = new int[]{Parser.JUSTIFY_LEFT, Parser.JUSTIFY_RIGHT, Parser.JUSTIFY_RIGHT,
+            Parser.JUSTIFY_RIGHT, Parser.JUSTIFY_RIGHT, Parser.JUSTIFY_CENTER, Parser.JUSTIFY_CENTER,
+            Parser.JUSTIFY_CENTER};
         sink.tableRows( justification, true );
 
         int totaldeps = 0;
@@ -356,7 +350,7 @@
                 {
                     try
                     {
-                        JarDependencyDetails jarDetails = dependencies.getJarDependencyDetails( artifact );
+                        JarData jarDetails = dependencies.getJarDependencyDetails( artifact );
 
                         String debugstr = "release";
                         if ( jarDetails.isDebugPresent() )
@@ -372,9 +366,9 @@
                             totalsealed++;
                         }
 
-                        totalentries += jarDetails.getEntries();
-                        totalclasses += jarDetails.getClassSize();
-                        totalpackages += jarDetails.getPackageSize();
+                        totalentries += jarDetails.getNumEntries();
+                        totalclasses += jarDetails.getNumClasses();
+                        totalpackages += jarDetails.getNumPackages();
 
                         try
                         {
@@ -385,47 +379,30 @@
                             // ignore
                         }
 
-                        tableRow( new String[] {
-                            artifactFile.getName(),
-                            decFormat.format( artifactFile.length() ),
-                            decFormat.format( jarDetails.getEntries() ),
-                            decFormat.format( jarDetails.getClassSize() ),
-                            decFormat.format( jarDetails.getPackageSize() ),
-                            jarDetails.getJdkRevision(),
-                            debugstr,
-                            sealedstr } );
+                        tableRow( new String[]{artifactFile.getName(), decFormat.format( artifactFile.length() ),
+                            decFormat.format( jarDetails.getNumEntries() ),
+                            decFormat.format( jarDetails.getNumClasses() ),
+                            decFormat.format( jarDetails.getNumPackages() ), jarDetails.getJdkRevision(), debugstr,
+                            sealedstr} );
                     }
-                    catch ( JarAnalyzerException e )
+                    catch ( IOException e )
                     {
                         createExceptionInfoTableRow( artifact, artifactFile, e );
                     }
                 }
                 else
                 {
-                    tableRow( new String[] {
-                        artifactFile.getName(),
-                        decFormat.format( artifactFile.length() ),
-                        "",
-                        "",
-                        "",
-                        "",
-                        "",
-                        "" } );
+                    tableRow( new String[]{artifactFile.getName(), decFormat.format( artifactFile.length() ), "", "",
+                        "", "", "", ""} );
                 }
             }
         }
 
         tableHeader[0] = "Total";
         tableHeader( tableHeader );
-        tableRow( new String[] {
-            "" + totaldeps + " total dependencies",
-            decFormat.format( totaldepsize ),
-            decFormat.format( totalentries ),
-            decFormat.format( totalclasses ),
-            decFormat.format( totalpackages ),
-            String.valueOf( highestjdk ),
-            decFormat.format( totaldebug ),
-            decFormat.format( totalsealed ) } );
+        tableRow( new String[]{"" + totaldeps + " total dependencies", decFormat.format( totaldepsize ),
+            decFormat.format( totalentries ), decFormat.format( totalclasses ), decFormat.format( totalpackages ),
+            String.valueOf( highestjdk ), decFormat.format( totaldebug ), decFormat.format( totalsealed )} );
 
         sink.tableRows_();
 
@@ -435,7 +412,7 @@
 
     private void createExceptionInfoTableRow( Artifact artifact, File artifactFile, Exception e )
     {
-        tableRow( new String[] { artifact.getId(), artifactFile.getAbsolutePath(), e.getMessage(), "", "", "", "", "" } );
+        tableRow( new String[]{artifact.getId(), artifactFile.getAbsolutePath(), e.getMessage(), "", "", "", "", ""} );
     }
 
     private void populateRepositoryMap( Map repos, List rawRepos )
@@ -485,7 +462,7 @@
         String release = getReportString( "report.dependencies.repo.locations.column.release" );
         String snapshot = getReportString( "report.dependencies.repo.locations.column.snapshot" );
 
-        String[] tableHeader = new String[] { repoid, url, release, snapshot };
+        String[] tableHeader = new String[]{repoid, url, release, snapshot};
         tableHeader( tableHeader );
 
         String releaseEnabled = getReportString( "report.dependencies.repo.locations.cell.release.enabled" );
@@ -560,8 +537,8 @@
                     boolean dependencyExists = false;
 
                     // check snapshots in snapshots repository only and releases in release repositories...
-                    if ( ( dependency.isSnapshot() && repo.getSnapshots().isEnabled() )
-                        || ( !dependency.isSnapshot() && repo.getReleases().isEnabled() ) )
+                    if ( ( dependency.isSnapshot() && repo.getSnapshots().isEnabled() ) ||
+                        ( !dependency.isSnapshot() && repo.getReleases().isEnabled() ) )
                     {
                         dependencyExists = repoUtils.dependencyExistsInRepo( repo, dependency );
                     }
@@ -664,13 +641,8 @@
 
     private String[] getArtifactRow( Artifact artifact )
     {
-        return new String[] {
-            artifact.getGroupId(),
-            artifact.getArtifactId(),
-            artifact.getVersion(),
-            artifact.getClassifier(),
-            artifact.getType(),
-            artifact.isOptional() ? "(optional)" : " " };
+        return new String[]{artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+            artifact.getClassifier(), artifact.getType(), artifact.isOptional() ? "(optional)" : " "};
     }
 
     private void printDependencyListing( DependencyNode node )

Modified: maven/sandbox/trunk/shared/maven-shared-jar/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/pom.xml?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/pom.xml (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/pom.xml Sun Jul  1 21:50:57 2007
@@ -48,6 +48,7 @@
       <plugin>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-maven-plugin</artifactId>
+        <version>1.3.3</version>
         <executions>
           <execution>
             <goals>
@@ -77,6 +78,29 @@
       </plugin>
       <plugin>
         <artifactId>maven-javadoc-plugin</artifactId>
+        <version>2.2</version>
+        <!-- TODO: move configuration to parent POM -->
+        <configuration>
+          <!-- TODO: not needed under javadoc plugin 2.3, once released -->
+          <overview>${basedir}/src/main/javadoc/overview.html</overview>
+          <tags>
+            <tag>
+              <name>todo</name>
+              <placement>a</placement>
+              <head>TODO:</head>
+            </tag>
+            <tag>
+              <name>plexus.requirement</name>
+              <placement>f</placement>
+              <head>Plexus Requirement:</head>
+            </tag>
+            <tag>
+              <name>plexus.component</name>
+              <placement>t</placement>
+              <head>Plexus Component:</head>
+            </tag>
+          </tags>
+        </configuration>
       </plugin>
       <plugin>
         <artifactId>maven-surefire-report-plugin</artifactId>

Added: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java?view=auto&rev=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java (added)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java Sun Jul  1 21:50:57 2007
@@ -0,0 +1,239 @@
+package org.apache.maven.shared.jar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Open a JAR file to be analyzed. Note that once created, the {@link #closeQuietly()} method should be called to
+ * release the associated file handle.
+ * <p/>
+ * Typical usage:
+ * <pre>
+ *  JarAnalyzer jar = new JarAnalyzer( jarFile );
+ * <p/>
+ *  try
+ *  {
+ *      // do some analysis, such as:
+ *      jarClasses = jarClassAnalyzer.analyze( jar );
+ *  }
+ *  finally
+ *  {
+ *      jar.closeQuietly();
+ *  }
+ * <p/>
+ *  // use jar.getJarData() in some way, or the data returned by the JAR analyzer. jar itself can no longer be used.
+ * </pre>
+ * <p/>
+ * Note: that the actual data is separated from this class by design to minimise the chance of forgetting to close the
+ * JAR file. The {@link org.apache.maven.shared.jar.JarData} class exposed, as well as any data returned by actual
+ * analyzers that use this class, can be used safely once this class is out of scope.
+ *
+ * @see org.apache.maven.shared.jar.identification.JarIdentificationAnalysis#analyze(JarAnalyzer)
+ * @see org.apache.maven.shared.jar.classes.JarClassesAnalysis#analyze(JarAnalyzer)
+ */
+public class JarAnalyzer
+{
+    /**
+     * Pattern to filter JAR entries for class files.
+     *
+     * @todo why are inner classes and other potentially valid classes omitted? (It flukes it by finding everything after $)
+     */
+    private static final Pattern CLASS_FILTER = Pattern.compile( "[A-Za-z0-9]*\\.class$" );
+
+    /**
+     * Pattern to filter JAR entries for Maven POM files.
+     */
+    private static final Pattern MAVEN_POM_FILTER = Pattern.compile( "META-INF/maven/.*/pom\\.xml$" );
+
+    /**
+     * Pattern to filter JAR entries for text files that may contain a version.
+     */
+    private static final Pattern VERSION_FILTER = Pattern.compile( "[Vv][Ee][Rr][Ss][Ii][Oo][Nn]" );
+
+    /**
+     * The associated JAR file.
+     */
+    private final JarFile jarFile;
+
+    /**
+     * Contains information about the data collected so far.
+     */
+    private final JarData jarData;
+
+    /**
+     * Constructor. Opens the JAR file, so should be matched by a call to {@link #closeQuietly()}.
+     *
+     * @param file the JAR file to open
+     * @throws java.io.IOException if there is a problem opening the JAR file, or reading the manifest. The JAR file will be closed if this occurs.
+     */
+    public JarAnalyzer( File file )
+        throws IOException
+    {
+        this.jarFile = new JarFile( file );
+
+        // Obtain entries list.
+        List entries = Collections.list( jarFile.entries() );
+
+        // Sorting of list is done by name to ensure a bytecode hash is always consistent.
+        Collections.sort( entries, new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                JarEntry entry1 = (JarEntry) o1;
+                JarEntry entry2 = (JarEntry) o2;
+
+                return entry1.getName().compareTo( entry2.getName() );
+            }
+        } );
+
+        Manifest manifest;
+        try
+        {
+            manifest = jarFile.getManifest();
+        }
+        catch ( IOException e )
+        {
+            closeQuietly();
+            throw e;
+        }
+        this.jarData = new JarData( file, manifest, entries );
+    }
+
+    /**
+     * Get the data for an individual entry in the JAR. The caller should closeQuietly the input stream, and should not retain
+     * the stream as the JAR file may be closed elsewhere.
+     *
+     * @param entry the JAR entry to read from
+     * @return the input stream of the individual JAR entry.
+     * @throws java.io.IOException if there is a problem opening the individual entry
+     */
+    public InputStream getEntryInputStream( JarEntry entry )
+        throws IOException
+    {
+        return jarFile.getInputStream( entry );
+    }
+
+    /**
+     * Close the associated JAR file, ignoring any errors that may occur.
+     */
+    public void closeQuietly()
+    {
+        try
+        {
+            jarFile.close();
+        }
+        catch ( IOException e )
+        {
+            // not much we can do about it but ignore it
+        }
+    }
+
+    /**
+     * Filter a list of JAR entries against the pattern.
+     *
+     * @param pattern the pattern to filter against
+     * @return the list of files found, in {@link java.util.jar.JarEntry} elements
+     */
+    public List filterEntries( Pattern pattern )
+    {
+        List ret = new ArrayList();
+
+        Iterator it = getEntries().iterator();
+        while ( it.hasNext() )
+        {
+            JarEntry entry = (JarEntry) it.next();
+
+            Matcher mat = pattern.matcher( entry.getName() );
+            if ( mat.find() )
+            {
+                ret.add( entry );
+            }
+        }
+        return ret;
+    }
+
+    /**
+     * Get all the classes in the JAR.
+     *
+     * @return the list of files found, in {@link java.util.jar.JarEntry} elements
+     */
+    public List getClassEntries()
+    {
+        return filterEntries( CLASS_FILTER );
+    }
+
+    /**
+     * Get all the Maven POM entries in the JAR.
+     *
+     * @return the list of files found, in {@link java.util.jar.JarEntry} elements
+     */
+    public List getMavenPomEntries()
+    {
+        return filterEntries( MAVEN_POM_FILTER );
+    }
+
+    /**
+     * Get all the version text files in the JAR.
+     *
+     * @return the list of files found, in {@link java.util.jar.JarEntry} elements
+     */
+    public List getVersionEntries()
+    {
+        return filterEntries( VERSION_FILTER );
+    }
+
+    /**
+     * Get all the contained files in the JAR.
+     *
+     * @return the list of files found, in {@link java.util.jar.JarEntry} elements
+     */
+    public List getEntries()
+    {
+        return jarData.getEntries();
+    }
+
+    /**
+     * Get the file that was opened by this analyzer.
+     *
+     * @return the JAR file reference
+     */
+    public File getFile()
+    {
+        return jarData.getFile();
+    }
+
+    public JarData getJarData()
+    {
+        return jarData;
+    }
+}

Added: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java?view=auto&rev=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java (added)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java Sun Jul  1 21:50:57 2007
@@ -0,0 +1,188 @@
+package org.apache.maven.shared.jar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.shared.jar.classes.JarClasses;
+import org.apache.maven.shared.jar.identification.JarIdentification;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * Class that contains details of a single JAR file and it's entries.
+ */
+public final class JarData
+{
+    /**
+     * The JAR file.
+     */
+    private final File file;
+
+    /**
+     * Whether the JAR file is sealed.
+     */
+    private final boolean sealed;
+
+    /**
+     * The hashcode for the entire file's contents.
+     */
+    private String fileHash;
+
+    /**
+     * The hashcode for the file's class data contents.
+     */
+    private String bytecodeHash;
+
+    /**
+     * The JAR's manifest.
+     */
+    private final Manifest manifest;
+
+    /**
+     * Information about the JAR's classes.
+     */
+    private JarClasses jarClasses;
+
+    /**
+     * The JAR entries.
+     */
+    private final List entries;
+
+    /**
+     * Information about the JAR's identifying features.
+     */
+    private JarIdentification jarIdentification;
+
+    /**
+     * Constructor.
+     *
+     * @param file     the JAR file
+     * @param manifest the JAR manifest
+     * @param entries  the JAR entries
+     */
+    public JarData( File file, Manifest manifest, List entries )
+    {
+        this.file = file;
+
+        this.manifest = manifest;
+
+        this.entries = Collections.unmodifiableList( entries );
+
+        boolean sealed = false;
+        if ( this.manifest != null )
+        {
+            String sval = this.manifest.getMainAttributes().getValue( Attributes.Name.SEALED );
+            if ( StringUtils.isNotEmpty( sval ) )
+            {
+                sealed = "true".equalsIgnoreCase( sval.trim() );
+            }
+        }
+        this.sealed = sealed;
+    }
+
+    public List getEntries()
+    {
+        return entries;
+    }
+
+    public Manifest getManifest()
+    {
+        return manifest;
+    }
+
+    public File getFile()
+    {
+        return file;
+    }
+
+    public boolean isSealed()
+    {
+        return sealed;
+    }
+
+    public void setFileHash( String fileHash )
+    {
+        this.fileHash = fileHash;
+    }
+
+    public String getFileHash()
+    {
+        return fileHash;
+    }
+
+    public void setBytecodeHash( String bytecodeHash )
+    {
+        this.bytecodeHash = bytecodeHash;
+    }
+
+    public String getBytecodeHash()
+    {
+        return bytecodeHash;
+    }
+
+    public boolean isDebugPresent()
+    {
+        return jarClasses.isDebugPresent();
+    }
+
+    public void setJarClasses( JarClasses jarClasses )
+    {
+        this.jarClasses = jarClasses;
+    }
+
+    public int getNumEntries()
+    {
+        return entries.size();
+    }
+
+    public int getNumClasses()
+    {
+        return jarClasses.getClassNames().size();
+    }
+
+    public int getNumPackages()
+    {
+        return jarClasses.getPackages().size();
+    }
+
+    public String getJdkRevision()
+    {
+        return jarClasses.getJdkRevision();
+    }
+
+    public void setJarIdentification( JarIdentification jarIdentification )
+    {
+        this.jarIdentification = jarIdentification;
+    }
+
+    public JarIdentification getJarIdentification()
+    {
+        return jarIdentification;
+    }
+
+    public JarClasses getJarClasses()
+    {
+        return jarClasses;
+    }
+}

Propchange: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java Sun Jul  1 21:50:57 2007
@@ -31,30 +31,43 @@
 import java.util.regex.Pattern;
 
 /**
- * ImportVisitor
+ * Implementation of a BCEL class visitor that analyzes a class and collects imports.
  */
 public class ImportVisitor
     extends EmptyVisitor
 {
+    /**
+     * The list of imports discovered.
+     */
     private List imports;
 
+    /**
+     * The Java class that is being analyzed.
+     */
     private JavaClass javaClass;
 
-    private Pattern qualifiedPat;
+    /**
+     * Pattern to detect if the import is qualified and allows retrieval of the actual import name from the string via the group 1.
+     */
+    private static final Pattern QUALIFIED_IMPORT_PATTERN = Pattern.compile( "L([a-zA-Z][a-zA-Z0-9\\.]+);" );
 
-    private Pattern validUtfPat;
+    /**
+     * Pattern that checks whether a string is valid UTF-8. Imports that are not are ignored.
+     */
+    private static final Pattern VALID_UTF8_PATTERN = Pattern.compile( "^[\\(\\)\\[A-Za-z0-9;/]+$" );
 
     /**
      * Create an Import visitor.
      *
-     * @param javaClass the javaclass to work off of.
+     * @param javaClass the javaclass to work from
      */
     public ImportVisitor( JavaClass javaClass )
     {
         this.javaClass = javaClass;
+
+        // Create a list that is guaranteed to be unique while retaining it's list qualities (LinkedHashSet does not
+        // expose the list interface even if natural ordering is retained)  
         this.imports = SetUniqueList.decorate( new ArrayList() );
-        this.qualifiedPat = Pattern.compile( "L([a-zA-Z][a-zA-Z0-9\\.]+);" );
-        this.validUtfPat = Pattern.compile( "^[\\(\\)\\[A-Za-z0-9;/]+$" );
     }
 
     /**
@@ -89,7 +102,7 @@
             name = name.substring( 0, name.length() - 6 );
         }
 
-        Matcher mat = qualifiedPat.matcher( name );
+        Matcher mat = QUALIFIED_IMPORT_PATTERN.matcher( name );
         if ( mat.find() )
         {
             this.imports.add( mat.group( 1 ) );
@@ -116,7 +129,7 @@
         }
 
         // Only valid characters please.
-        if ( !validUtfPat.matcher( ret ).matches() )
+        if ( !VALID_UTF8_PATTERN.matcher( ret ).matches() )
         {
             return;
         }
@@ -144,7 +157,7 @@
             return;
         }
 
-        Matcher mat = qualifiedPat.matcher( ret );
+        Matcher mat = QUALIFIED_IMPORT_PATTERN.matcher( ret );
         char prefix = ret.charAt( 0 );
 
         if ( prefix == '(' )

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java Sun Jul  1 21:50:57 2007
@@ -22,80 +22,114 @@
 import org.apache.commons.collections.list.SetUniqueList;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
- * Facts about the classes within a JarAnalyzer File.
+ * Gathered facts about the classes within a JAR file.
+ *
+ * @see org.apache.maven.shared.jar.classes.JarClassesAnalysis#analyze(org.apache.maven.shared.jar.JarAnalyzer)
  */
 public class JarClasses
 {
+    /**
+     * The list of imports in the classes in the JAR.
+     */
     private List imports;
 
+    /**
+     * A list of packages represented by classes in the JAR.
+     */
     private List packages;
 
+    /**
+     * A list of the classes that in the JAR.
+     */
     private List classNames;
 
+    /**
+     * A list of methods within the classes in the JAR.
+     */
     private List methods;
 
+    /**
+     * Whether the JAR contains any code with debug information. If there is a mix of debug and release code, this will
+     * still be true.
+     */
     private boolean isDebugPresent;
 
+    /**
+     * The highest JVM revision available in any class files. While the JAR may work on earlier JVMs if particular
+     * classes are not used, this is the minimum JVM that guarantees compatibility.
+     */
     private String jdkRevision;
 
     /**
-     * Create Empty JarFacts.
+     * Constructor to create an empty instance.
      */
     public JarClasses()
     {
+        // Unique list decorators are used to ensure natural ordering is retained, the list interface is availble, and
+        // that duplicates are not entered.
         imports = SetUniqueList.decorate( new ArrayList() );
         packages = SetUniqueList.decorate( new ArrayList() );
         classNames = SetUniqueList.decorate( new ArrayList() );
         methods = SetUniqueList.decorate( new ArrayList() );
     }
 
+    /**
+     * Add a discovered class to the record.
+     *
+     * @param name the name of the class
+     */
     public void addClassName( String name )
     {
         this.classNames.add( name );
     }
 
     /**
-     * Add an Import.
+     * Add a discovered package to the record.
      *
-     * @param iname the import name
+     * @param name the name of the package
      */
-    public void addImport( String iname )
+    public void addPackage( String name )
     {
-        this.imports.add( iname );
+        this.packages.add( name );
     }
 
     /**
-     * Add a Package name.
+     * Add a discovered method to the record.
      *
-     * @param pname the package name
+     * @param name the name of the method
      */
-    public void addPackage( String pname )
+    public void addMethod( String name )
     {
-        this.packages.add( pname );
+        this.methods.add( name );
     }
 
-    public List getClassNames()
+    /**
+     * Add a list of discovered imports to the record.
+     *
+     * @param imports the imports to add. Each item should be a String to avoid down the line ClassCastExceptions.
+     */
+    public void addImports( List imports )
     {
-        return classNames;
+        this.imports.addAll( imports );
     }
 
-    /**
-     * @return Returns the imports.
-     */
     public List getImports()
     {
-        return imports;
+        return Collections.unmodifiableList( imports );
+    }
+
+    public List getClassNames()
+    {
+        return Collections.unmodifiableList( classNames );
     }
 
-    /**
-     * @return Returns the packages.
-     */
     public List getPackages()
     {
-        return packages;
+        return Collections.unmodifiableList( packages );
     }
 
     public boolean isDebugPresent()
@@ -118,13 +152,8 @@
         this.jdkRevision = jdkRevision;
     }
 
-    public void addMethod( String method )
-    {
-        this.methods.add( method );
-    }
-
     public List getMethods()
     {
-        return methods;
+        return Collections.unmodifiableList( methods );
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java Sun Jul  1 21:50:57 2007
@@ -34,9 +34,13 @@
 import java.util.jar.JarEntry;
 
 /**
- * JarAnalyzer Classes Analyzer
+ * Analyze the classes in a JAR file. This class is thread safe and immutable as it retains no state.
+ * <p/>
+ * Note that you must first create an instance of {@link org.apache.maven.shared.jar.JarAnalyzer} - see its Javadoc for
+ * a typical use.
  *
- * @plexus.component role="org.apache.maven.shared.jar.classes.JarClassesAnalysis"
+ * @plexus.component role="org.apache.maven.shared.jar.classes.JarClassesAnalysis" role-hint="default"
+ * @see #analyze(org.apache.maven.shared.jar.JarAnalyzer)
  */
 public class JarClassesAnalysis
     extends AbstractLogEnabled
@@ -54,112 +58,121 @@
     private static final double JAVA_1_1_CLASS_VERSION = 45.3;
 
     /**
-     * Analyze and populate the <code>jar.information.classes</code> object.
+     * Analyze a JAR and find any classes and their details. Note that if the provided JAR analyzer has previously
+     * analyzed the JAR, the cached results will be returned. You must obtain a new JAR analyzer to the re-read the
+     * contents of the file.
      *
-     * @param jar the jar analyzer to use
+     * @param jarAnalyzer the JAR to analyze. This must not yet have been closed.
+     * @return the details of the classes found
      */
-    public void analyze( JarAnalyzer jar )
+    public JarClasses analyze( JarAnalyzer jarAnalyzer )
     {
-        String jarfilename = jar.getFile().getAbsolutePath();
-        JarClasses classes = new JarClasses();
-
-        List classList = jar.getNameRegexEntryList( "[A-Za-z0-9]*\\.class$" );
+        JarClasses classes = jarAnalyzer.getJarData().getJarClasses();
+        if ( classes == null )
+        {
+            String jarfilename = jarAnalyzer.getFile().getAbsolutePath();
+            classes = new JarClasses();
 
-        classes.setDebugPresent( false );
+            List classList = jarAnalyzer.getClassEntries();
 
-        double maxVersion = 0.0;
+            classes.setDebugPresent( false );
 
-        Iterator it = classList.iterator();
-        while ( it.hasNext() )
-        {
-            JarEntry entry = (JarEntry) it.next();
-            String classname = entry.getName();
+            double maxVersion = 0.0;
 
-            try
+            Iterator it = classList.iterator();
+            while ( it.hasNext() )
             {
-                ClassParser classParser = new ClassParser( jarfilename, classname );
+                JarEntry entry = (JarEntry) it.next();
+                String classname = entry.getName();
 
-                JavaClass javaClass = classParser.parse();
+                try
+                {
+                    ClassParser classParser = new ClassParser( jarfilename, classname );
 
-                String classSignature = javaClass.getClassName();
+                    JavaClass javaClass = classParser.parse();
 
-                if ( !classes.isDebugPresent() )
-                {
-                    if ( hasDebugSymbols( javaClass ) )
+                    String classSignature = javaClass.getClassName();
+
+                    if ( !classes.isDebugPresent() )
                     {
-                        classes.setDebugPresent( true );
+                        if ( hasDebugSymbols( javaClass ) )
+                        {
+                            classes.setDebugPresent( true );
+                        }
                     }
-                }
 
-                double classVersion = javaClass.getMajor();
-                if ( javaClass.getMinor() > 0 )
-                {
-                    classVersion = classVersion + 1 / (double) javaClass.getMinor();
-                }
+                    double classVersion = javaClass.getMajor();
+                    if ( javaClass.getMinor() > 0 )
+                    {
+                        classVersion = classVersion + 1 / (double) javaClass.getMinor();
+                    }
 
-                if ( classVersion > maxVersion )
-                {
-                    maxVersion = classVersion;
-                }
+                    if ( classVersion > maxVersion )
+                    {
+                        maxVersion = classVersion;
+                    }
 
-                Method[] methods = javaClass.getMethods();
-                for ( int i = 0; i < methods.length; i++ )
-                {
-                    classes.addMethod( classSignature + "." + methods[i].getName() + methods[i].getSignature() );
-                }
+                    Method[] methods = javaClass.getMethods();
+                    for ( int i = 0; i < methods.length; i++ )
+                    {
+                        classes.addMethod( classSignature + "." + methods[i].getName() + methods[i].getSignature() );
+                    }
+
+                    String classPackageName = javaClass.getPackageName();
 
-                String classPackageName = javaClass.getPackageName();
+                    classes.addClassName( classSignature );
+                    classes.addPackage( classPackageName );
 
-                classes.addClassName( classSignature );
-                classes.addPackage( classPackageName );
+                    ImportVisitor importVisitor = new ImportVisitor( javaClass );
+                    DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
+                    javaClass.accept( descVisitor );
 
-                ImportVisitor importVisitor = new ImportVisitor( javaClass );
-                DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
-                javaClass.accept( descVisitor );
+                    classes.addImports( importVisitor.getImports() );
+                }
+                catch ( ClassFormatException e )
+                {
+                    getLogger().warn( "Unable to process class " + classname + " in JarAnalyzer File " + jarfilename,
+                                      e );
+                }
+                catch ( IOException e )
+                {
+                    getLogger().warn( "Unable to process JarAnalyzer File " + jarfilename, e );
+                }
+            }
 
-                addImports( classes, importVisitor.getImports() );
+            // TODO: check these since they are > instead of >=
+            if ( maxVersion >= JAVA_1_6_CLASS_VERSION )
+            {
+                classes.setJdkRevision( "1.6" );
             }
-            catch ( ClassFormatException e )
+            else if ( maxVersion >= JAVA_1_5_CLASS_VERSION )
             {
-                getLogger().warn( "Unable to process class " + classname + " in JarAnalyzer File " + jar.getFile(), e );
+                classes.setJdkRevision( "1.5" );
             }
-            catch ( IOException e )
+            else if ( maxVersion > JAVA_1_4_CLASS_VERSION )
             {
-                getLogger().warn( "Unable to process JarAnalyzer File " + jar.getFile(), e );
+                classes.setJdkRevision( "1.4" );
+            }
+            else if ( maxVersion > JAVA_1_3_CLASS_VERSION )
+            {
+                classes.setJdkRevision( "1.3" );
+            }
+            else if ( maxVersion > JAVA_1_2_CLASS_VERSION )
+            {
+                classes.setJdkRevision( "1.2" );
+            }
+            else if ( maxVersion > JAVA_1_1_CLASS_VERSION )
+            {
+                classes.setJdkRevision( "1.1" );
+            }
+            else if ( maxVersion > 0 )
+            {
+                classes.setJdkRevision( "1.0" );
             }
-        }
 
-        // TODO: check these since they are > instead of >=
-        if ( maxVersion >= JAVA_1_6_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.6" );
-        }
-        else if ( maxVersion >= JAVA_1_5_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.5" );
-        }
-        else if ( maxVersion > JAVA_1_4_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.4" );
-        }
-        else if ( maxVersion > JAVA_1_3_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.3" );
-        }
-        else if ( maxVersion > JAVA_1_2_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.2" );
-        }
-        else if ( maxVersion > JAVA_1_1_CLASS_VERSION )
-        {
-            classes.setJdkRevision( "1.1" );
-        }
-        else
-        {
-            classes.setJdkRevision( "1.0" );
+            jarAnalyzer.getJarData().setJarClasses( classes );
         }
-
-        jar.setClasses( classes );
+        return classes;
     }
 
     private boolean hasDebugSymbols( JavaClass javaClass )
@@ -175,16 +188,6 @@
                 break;
             }
         }
-
         return ret;
-    }
-
-    private void addImports( JarClasses facts, List imports )
-    {
-        Iterator it = imports.iterator();
-        while ( it.hasNext() )
-        {
-            facts.addImport( (String) it.next() );
-        }
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java Sun Jul  1 21:50:57 2007
@@ -20,31 +20,199 @@
  */
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
- * JarAnalyzer Taxon, the set of Maven dependency information both found and potential.
+ * Gathered Maven information about the JAR file. Stores both assumed/validated values and potential values.
+ *
+ * @see org.apache.maven.shared.jar.identification.JarIdentificationAnalysis#analyze(org.apache.maven.shared.jar.JarAnalyzer)
  */
 public class JarIdentification
 {
-    private boolean wellKnown;
-
+    /**
+     * The group ID derived or guessed from the list of potentials of the JAR.
+     */
     private String groupId;
 
+    /**
+     * The artifact ID derived or guessed from the list of potentials of the JAR.
+     */
     private String artifactId;
 
+    /**
+     * The version derived or guessed from the list of potentials of the JAR.
+     */
     private String version;
 
+    /**
+     * The project name derived or guessed from the list of potentials of the JAR.
+     */
     private String name;
 
+    /**
+     * The vendor (organization name) derived or guessed from the list of potentials of the JAR.
+     */
     private String vendor;
 
-    private List potentials;
+    /**
+     * The list of possible group IDs discovered.
+     */
+    private List potentialGroupIds = new ArrayList();
+
+    /**
+     * The list of possible artifact IDs discovered.
+     */
+    private List potentialArtifactIds = new ArrayList();
+
+    /**
+     * The list of possible versions discovered.
+     */
+    private List potentialVersions = new ArrayList();
+
+    /**
+     * The list of possible artifact names discovered.
+     */
+    private List potentialNames = new ArrayList();
+
+    /**
+     * The list of possible vendors discovered.
+     */
+    private List potentialVendors = new ArrayList();
+
+    /**
+     * Add a validated group ID.
+     *
+     * @param groupId the group ID discovered
+     */
+    public void addAndSetGroupId( String groupId )
+    {
+        if ( groupId != null )
+        {
+            this.groupId = groupId;
+        }
+
+        addGroupId( groupId );
+    }
+
+    /**
+     * Add a potential group ID.
+     *
+     * @param groupId the group ID discovered
+     */
+    public void addGroupId( String groupId )
+    {
+        addUnique( potentialGroupIds, groupId );
+    }
+
+    /**
+     * Add a validated artifact ID.
+     *
+     * @param artifactId the artifact ID discovered
+     */
+    public void addAndSetArtifactId( String artifactId )
+    {
+        if ( artifactId != null )
+        {
+            this.artifactId = artifactId;
+        }
+
+        addArtifactId( artifactId );
+    }
+
+    /**
+     * Add a potential artifact ID.
+     *
+     * @param artifactId the artifact ID discovered
+     */
+    public void addArtifactId( String artifactId )
+    {
+        addUnique( potentialArtifactIds, artifactId );
+    }
+
+    /**
+     * Add a validated version.
+     *
+     * @param version the version discovered
+     */
+    public void addAndSetVersion( String version )
+    {
+        if ( version != null )
+        {
+            this.version = version;
+        }
+
+        addVersion( version );
+    }
+
+    /**
+     * Add a potential version.
+     *
+     * @param version the version discovered
+     */
+    public void addVersion( String version )
+    {
+        addUnique( potentialVersions, version );
+    }
+
+    /**
+     * Add a validated vendor name.
+     *
+     * @param name the vendor name discovered
+     */
+    public void addAndSetVendor( String name )
+    {
+        if ( name != null )
+        {
+            vendor = name;
+        }
+
+        addVendor( name );
+    }
+
+    /**
+     * Add a potential vendor name.
+     *
+     * @param name the vendor name discovered
+     */
+    public void addVendor( String name )
+    {
+        addUnique( potentialVendors, name );
+    }
+
+    /**
+     * Add a validated artifact name.
+     *
+     * @param name the artifact name discovered
+     */
+    public void addAndSetName( String name )
+    {
+        if ( name != null )
+        {
+            this.name = name;
+        }
+
+        addName( name );
+    }
+
+    /**
+     * Add a potential artifact name.
+     *
+     * @param name the artifact name discovered
+     */
+    public void addName( String name )
+    {
+        addUnique( potentialNames, name );
+    }
 
-    public JarIdentification()
+    private static void addUnique( List list, String value )
     {
-        potentials = new ArrayList();
+        if ( value != null )
+        {
+            if ( !list.contains( value ) )
+            {
+                list.add( value );
+            }
+        }
     }
 
     public String getArtifactId()
@@ -77,11 +245,6 @@
         this.name = name;
     }
 
-    public List getPotentials()
-    {
-        return potentials;
-    }
-
     public String getVendor()
     {
         return vendor;
@@ -102,88 +265,28 @@
         this.version = version;
     }
 
-    public boolean isWellKnown()
+    public List getPotentialVersions()
     {
-        return wellKnown;
+        return potentialVersions;
     }
 
-    public void setWellKnown( boolean wellKnown )
+    public List getPotentialNames()
     {
-        this.wellKnown = wellKnown;
+        return potentialNames;
     }
 
-    public List getGroupIds()
+    public List getPotentialGroupIds()
     {
-        List ret = new ArrayList();
-        Iterator it = potentials.iterator();
-        while ( it.hasNext() )
-        {
-            AbstractJarIdentificationExposer exposer = (AbstractJarIdentificationExposer) it.next();
-            if ( exposer.getGroupIds() != null )
-            {
-                ret.addAll( exposer.getGroupIds() );
-            }
-        }
-        return ret;
+        return potentialGroupIds;
     }
 
-    public List getArtifactIds()
+    public List getPotentialArtifactIds()
     {
-        List ret = new ArrayList();
-        Iterator it = potentials.iterator();
-        while ( it.hasNext() )
-        {
-            AbstractJarIdentificationExposer exposer = (AbstractJarIdentificationExposer) it.next();
-            if ( exposer.getArtifactIds() != null )
-            {
-                ret.addAll( exposer.getArtifactIds() );
-            }
-        }
-        return ret;
-    }
-
-    public List getVersions()
-    {
-        List ret = new ArrayList();
-        Iterator it = potentials.iterator();
-        while ( it.hasNext() )
-        {
-            AbstractJarIdentificationExposer exposer = (AbstractJarIdentificationExposer) it.next();
-            if ( exposer.getVersions() != null )
-            {
-                ret.addAll( exposer.getVersions() );
-            }
-        }
-        return ret;
+        return potentialArtifactIds;
     }
 
-    public List getNames()
+    public List getPotentialVendors()
     {
-        List ret = new ArrayList();
-        Iterator it = potentials.iterator();
-        while ( it.hasNext() )
-        {
-            AbstractJarIdentificationExposer exposer = (AbstractJarIdentificationExposer) it.next();
-            if ( exposer.getNames() != null )
-            {
-                ret.addAll( exposer.getNames() );
-            }
-        }
-        return ret;
-    }
-
-    public List getVendors()
-    {
-        List ret = new ArrayList();
-        Iterator it = potentials.iterator();
-        while ( it.hasNext() )
-        {
-            AbstractJarIdentificationExposer exposer = (AbstractJarIdentificationExposer) it.next();
-            if ( exposer.getVendors() != null )
-            {
-                ret.addAll( exposer.getVendors() );
-            }
-        }
-        return ret;
+        return potentialVendors;
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java Sun Jul  1 21:50:57 2007
@@ -22,122 +22,111 @@
 import org.apache.maven.shared.jar.JarAnalyzer;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
 /**
- * JarAnalyzer Taxon Analyzer
+ * Analyze the JAR file to identify Maven artifact metadata. This class is thread safe and immutable as long as all
+ * provided exposers are, as it retains no state.
+ * <p/>
+ * If using Plexus, the class will use all available exposers in the container.
+ * <p/>
+ * If not using Plexus, the exposers must be set using {@link #setExposers(java.util.List)} before calling
+ * {@link #analyze(org.apache.maven.shared.jar.JarAnalyzer)}
+ * <p/>
+ * Note that you must first create an instance of {@link org.apache.maven.shared.jar.JarAnalyzer} - see its Javadoc for
+ * a typical use.
  *
- * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationAnalysis"
+ * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationAnalysis" role-hint="default"
  */
 public class JarIdentificationAnalysis
 {
     /**
+     * The Maven information exposers to use during identification.
+     *
      * @plexus.requirement role="org.apache.maven.shared.jar.identification.JarIdentificationExposer"
-     * @noinspection UnusedDeclaration,MismatchedQueryAndUpdateOfCollection
      */
     private List exposers;
 
-    public void analyze( JarAnalyzer jar )
+    /**
+     * Analyze a JAR and find any associated Maven metadata. Note that if the provided JAR analyzer has previously
+     * analyzed the JAR, the cached results will be returned. You must obtain a new JAR analyzer to the re-read the
+     * contents of the file.
+     *
+     * @param jarAnalyzer the JAR to analyze. This must not yet have been closed.
+     * @return the Maven metadata discovered
+     */
+    public JarIdentification analyze( JarAnalyzer jarAnalyzer )
     {
-        JarIdentification taxon = new JarIdentification();
+        JarIdentification taxon = jarAnalyzer.getJarData().getJarIdentification();
+        if ( taxon != null )
+        {
+            return taxon;
+        }
+
+        taxon = new JarIdentification();
 
         for ( Iterator i = exposers.iterator(); i.hasNext(); )
         {
             JarIdentificationExposer exposer = (JarIdentificationExposer) i.next();
-            exposer.initialize();
-            exposer.setJar( jar );
-            addExposer( taxon, exposer );
+            exposer.expose( taxon, jarAnalyzer );
         }
 
         normalize( taxon );
 
-        jar.setIdentification( taxon );
-    }
-
-    private void addExposer( JarIdentification taxon, JarIdentificationExposer exposer )
-    {
-        taxon.getPotentials().add( exposer );
-        exposer.expose();
+        jarAnalyzer.getJarData().setJarIdentification( taxon );
 
-        if ( exposer.isAuthoritative() )
-        {
-            if ( StringUtils.isEmpty( taxon.getGroupId() ) && isNotEmpty( exposer.getGroupIds() ) )
-            {
-                taxon.setGroupId( (String) exposer.getGroupIds().get( 0 ) );
-            }
-
-            if ( StringUtils.isEmpty( taxon.getArtifactId() ) && isNotEmpty( exposer.getArtifactIds() ) )
-            {
-                taxon.setArtifactId( (String) exposer.getArtifactIds().get( 0 ) );
-            }
-
-            if ( StringUtils.isEmpty( taxon.getVersion() ) && isNotEmpty( exposer.getVersions() ) )
-            {
-                taxon.setVersion( (String) exposer.getVersions().get( 0 ) );
-            }
-
-            if ( StringUtils.isEmpty( taxon.getName() ) && isNotEmpty( exposer.getNames() ) )
-            {
-                taxon.setName( (String) exposer.getNames().get( 0 ) );
-            }
-
-            if ( StringUtils.isEmpty( taxon.getVendor() ) && isNotEmpty( exposer.getVendors() ) )
-            {
-                taxon.setVendor( (String) exposer.getVendors().get( 0 ) );
-            }
-        }
+        return taxon;
     }
 
     private void normalize( JarIdentification taxon )
     {
         if ( StringUtils.isEmpty( taxon.getGroupId() ) )
         {
-            taxon.setGroupId( pickSmallest( taxon.getGroupIds() ) );
+            taxon.setGroupId( pickSmallest( taxon.getPotentialGroupIds() ) );
         }
 
         if ( StringUtils.isEmpty( taxon.getArtifactId() ) )
         {
-            taxon.setArtifactId( pickLargest( taxon.getArtifactIds() ) );
+            taxon.setArtifactId( pickLargest( taxon.getPotentialArtifactIds() ) );
         }
 
         if ( StringUtils.isEmpty( taxon.getVersion() ) )
         {
-            taxon.setVersion( pickSmallest( taxon.getVersions() ) );
+            taxon.setVersion( pickSmallest( taxon.getPotentialVersions() ) );
         }
 
         if ( StringUtils.isEmpty( taxon.getName() ) )
         {
-            taxon.setName( pickLargest( taxon.getNames() ) );
+            taxon.setName( pickLargest( taxon.getPotentialNames() ) );
         }
 
         if ( StringUtils.isEmpty( taxon.getVendor() ) )
         {
-            taxon.setVendor( pickLargest( taxon.getVendors() ) );
+            taxon.setVendor( pickLargest( taxon.getPotentialVendors() ) );
         }
     }
 
     private String pickSmallest( List list )
     {
-        if ( isEmpty( list ) )
-        {
-            return null;
-        }
-
-        int size = Integer.MAX_VALUE;
         String smallest = null;
-        Iterator it = list.iterator();
-        while ( it.hasNext() )
-        {
-            String val = (String) it.next();
 
-            if ( StringUtils.isNotEmpty( val ) )
+        if ( !list.isEmpty() )
+        {
+            int size = Integer.MAX_VALUE;
+            Iterator it = list.iterator();
+            while ( it.hasNext() )
             {
-                if ( val.length() < size )
+                String val = (String) it.next();
+
+                if ( StringUtils.isNotEmpty( val ) )
                 {
-                    smallest = val;
-                    size = val.length();
+                    if ( val.length() < size )
+                    {
+                        smallest = val;
+                        size = val.length();
+                    }
                 }
             }
         }
@@ -147,37 +136,29 @@
 
     private String pickLargest( List list )
     {
-        if ( isEmpty( list ) )
-        {
-            return null;
-        }
-
-        int size = Integer.MIN_VALUE;
         String largest = null;
-        Iterator it = list.iterator();
-        while ( it.hasNext() )
+        if ( !list.isEmpty() )
         {
-            String val = (String) it.next();
-            if ( StringUtils.isNotEmpty( val ) )
+            int size = Integer.MIN_VALUE;
+            Iterator it = list.iterator();
+            while ( it.hasNext() )
             {
-                if ( val.length() > size )
+                String val = (String) it.next();
+                if ( StringUtils.isNotEmpty( val ) )
                 {
-                    largest = val;
-                    size = val.length();
+                    if ( val.length() > size )
+                    {
+                        largest = val;
+                        size = val.length();
+                    }
                 }
             }
         }
-
         return largest;
     }
 
-    private boolean isEmpty( Collection coll )
-    {
-        return coll == null || coll.isEmpty();
-    }
-
-    private boolean isNotEmpty( Collection coll )
+    public void setExposers( List exposers )
     {
-        return coll != null && !coll.isEmpty();
+        this.exposers = Collections.unmodifiableList( exposers );
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationExposer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationExposer.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationExposer.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationExposer.java Sun Jul  1 21:50:57 2007
@@ -21,33 +21,19 @@
 
 import org.apache.maven.shared.jar.JarAnalyzer;
 
-import java.util.List;
-
 /**
- * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
- * @version $Id$
+ * Expose information from a JAR during the identification process. Implementations should be made to be thread safe.
+ *
+ * @see org.apache.maven.shared.jar.identification.JarIdentificationAnalysis
  */
 public interface JarIdentificationExposer
 {
-    String ROLE = JarIdentificationExposer.class.getName();
-
-    void setJar( JarAnalyzer jar );
-
-    void initialize();
-
-    void expose();
-
-    boolean isAuthoritative();
-
-    String getExposerName();
-
-    List getGroupIds();
-
-    List getArtifactIds();
-
-    List getVersions();
-
-    List getNames();
-
-    List getVendors();
+    /**
+     * Expose metadata during the identification process.
+     *
+     * @param identification the identification record to populate with the exposed metadata
+     * @param jarAnalyzer    the JAR to obtain the information from. Should be treated as read only, with the exception
+     *                       of caching the metadata if it would be identical when run over the same file again.
+     */
+    void expose( JarIdentification identification, JarAnalyzer jarAnalyzer );
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java Sun Jul  1 21:50:57 2007
@@ -22,7 +22,11 @@
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Organization;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.shared.jar.identification.AbstractJarIdentificationExposer;
+import org.apache.maven.shared.jar.JarAnalyzer;
+import org.apache.maven.shared.jar.identification.JarIdentification;
+import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.IOException;
@@ -33,57 +37,65 @@
 
 
 /**
- * JarAnalyzer Taxon Exposer for the Embedded Maven Model.
+ * Exposer that examines a JAR file for any embedded Maven metadata for identification.
  *
  * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationExposer" role-hint="embeddedMavenModel"
  */
 public class EmbeddedMavenModelExposer
-    extends AbstractJarIdentificationExposer
+    extends AbstractLogEnabled
+    implements JarIdentificationExposer
 {
-    public void expose()
+    public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List entries = getJar().getNameRegexEntryList( "META-INF/maven/.*/pom\\.xml$" ); //$NON-NLS-1$
+        List entries = jarAnalyzer.getMavenPomEntries();
         if ( entries.isEmpty() )
         {
             return;
         }
 
+        if ( entries.size() > 1 )
+        {
+            getLogger().warn(
+                "More than one Maven model entry was found in the JAR, using only the first of: " + entries );
+        }
+
         JarEntry pom = (JarEntry) entries.get( 0 );
         MavenXpp3Reader pomreader = new MavenXpp3Reader();
+        InputStream is = null;
         try
         {
-            InputStream istream = getJar().getEntryInputStream( pom );
-            InputStreamReader isreader = new InputStreamReader( istream );
+            is = jarAnalyzer.getEntryInputStream( pom );
+            InputStreamReader isreader = new InputStreamReader( is );
             Model model = pomreader.read( isreader );
 
-            addGroupId( model.getGroupId() );
-            addArtifactId( model.getArtifactId() );
-            addVersion( model.getVersion() );
-            addName( model.getName() );
+            identification.addAndSetGroupId( model.getGroupId() );
+            identification.addAndSetArtifactId( model.getArtifactId() );
+            identification.addAndSetVersion( model.getVersion() );
+            identification.addAndSetName( model.getName() );
+
+            // TODO: suboptimal - we are reproducing Maven's built in default
+            if ( model.getName() == null )
+            {
+                identification.addAndSetName( model.getArtifactId() );
+            }
 
             Organization org = model.getOrganization();
             if ( org != null )
             {
-                addVendor( org.getName() );
+                identification.addAndSetVendor( org.getName() );
             }
         }
         catch ( IOException e )
         {
-            getLogger().error( "Unable to read model " + pom.getName() + " in " + getJar().getFilename() + ".", e );
+            getLogger().error( "Unable to read model " + pom.getName() + " in " + jarAnalyzer.getFile() + ".", e );
         }
         catch ( XmlPullParserException e )
         {
-            getLogger().error( "Unable to parse model " + pom.getName() + " in " + getJar().getFilename() + ".", e );
+            getLogger().error( "Unable to parse model " + pom.getName() + " in " + jarAnalyzer.getFile() + ".", e );
+        }
+        finally
+        {
+            IOUtil.close( is );
         }
-    }
-
-    public String getExposerName()
-    {
-        return "Embedded Model";
-    }
-
-    public boolean isAuthoritative()
-    {
-        return true;
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/FilenameExposer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/FilenameExposer.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/FilenameExposer.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/FilenameExposer.java Sun Jul  1 21:50:57 2007
@@ -19,7 +19,9 @@
  * under the License.
  */
 
-import org.apache.maven.shared.jar.identification.AbstractJarIdentificationExposer;
+import org.apache.maven.shared.jar.JarAnalyzer;
+import org.apache.maven.shared.jar.identification.JarIdentification;
+import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 import org.codehaus.plexus.util.FileUtils;
 
 import java.util.regex.Matcher;
@@ -27,39 +29,31 @@
 
 
 /**
- * JarAnalyzer Taxon Exposer based on Filename patterns.
+ * Exposer that examines a JAR file to derive Maven metadata from the pattern of the JAR's filename.
+ * Will match the format <i>artifactId</i>-<i>version</i>.jar.
  *
  * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationExposer" role-hint="filename"
  */
 public class FilenameExposer
-    extends AbstractJarIdentificationExposer
+    implements JarIdentificationExposer
 {
-    public String getExposerName()
-    {
-        return "Filename";
-    }
-
-    public boolean isAuthoritative()
-    {
-        return false;
-    }
+    private static final Pattern VERSION_PATTERN = Pattern.compile( "-[0-9]" );
 
-    public void expose()
+    public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        String fname = FileUtils.removeExtension( getJar().getFile().getName() );
-        Pattern verSplit = Pattern.compile( "-[0-9]" ); //$NON-NLS-1$
-        Matcher mat = verSplit.matcher( fname );
+        String filename = FileUtils.removeExtension( jarAnalyzer.getFile().getName() );
+        Matcher mat = VERSION_PATTERN.matcher( filename );
         if ( mat.find() )
         {
-            String prefix = fname.substring( 0, mat.start() );
-            addArtifactId( prefix );
-            addName( prefix );
-            addVersion( fname.substring( mat.end() - 1 ) );
+            String prefix = filename.substring( 0, mat.start() );
+            identification.addArtifactId( prefix );
+            identification.addName( prefix );
+            identification.addVersion( filename.substring( mat.end() - 1 ) );
         }
         else
         {
-            addArtifactId( fname );
-            addName( fname );
+            identification.addArtifactId( filename );
+            identification.addName( filename );
         }
     }
 }

Modified: maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java?view=diff&rev=552400&r1=552399&r2=552400
==============================================================================
--- maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java (original)
+++ maven/sandbox/trunk/shared/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java Sun Jul  1 21:50:57 2007
@@ -19,58 +19,46 @@
  * under the License.
  */
 
+import org.apache.maven.shared.jar.JarAnalyzer;
 import org.apache.maven.shared.jar.classes.JarClasses;
 import org.apache.maven.shared.jar.classes.JarClassesAnalysis;
-import org.apache.maven.shared.jar.identification.AbstractJarIdentificationExposer;
+import org.apache.maven.shared.jar.identification.JarIdentification;
+import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 
 import java.util.Iterator;
 
 
 /**
- * JarAnalyzer Taxon Exposer for the information from JarClasses.
+ * Exposer that examines a JAR file to derive Maven metadata from the classes in a JAR. It will currently identify
+ * potential group IDs from the class packages.
+ * <p/>
+ * Note: if not being used from Plexus, the {@link #setAnalyzer(org.apache.maven.shared.jar.classes.JarClassesAnalysis)}
+ * method must be called to avoid a NullPointerException during the expose method.
  *
  * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationExposer" role-hint="jarClasses"
  */
 public class JarClassesExposer
-    extends AbstractJarIdentificationExposer
+    implements JarIdentificationExposer
 {
     /**
      * @plexus.requirement
-     * @noinspection UnusedDeclaration
      */
     private JarClassesAnalysis analyzer;
 
-    public String getExposerName()
+    public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        return "JarAnalyzer Classes";
-    }
-
-    public boolean isAuthoritative()
-    {
-        return false;
-    }
-
-    public void expose()
-    {
-        JarClasses jarclasses = getJar().getClasses();
-
-        if ( jarclasses == null )
-        {
-            analyzer.analyze( getJar() );
-            jarclasses = getJar().getClasses();
-        }
-
-        if ( jarclasses == null )
-        {
-            getLogger().error( "Unable to process null JarClasses on " + getJar().getFilename() );
-            return;
-        }
+        JarClasses jarclasses = analyzer.analyze( jarAnalyzer );
 
         Iterator it = jarclasses.getPackages().iterator();
         while ( it.hasNext() )
         {
             String packagename = (String) it.next();
-            addGroupId( packagename );
+            identification.addGroupId( packagename );
         }
+    }
+
+    public void setAnalyzer( JarClassesAnalysis analyzer )
+    {
+        this.analyzer = analyzer;
     }
 }



Mime
View raw message