Maven Shared Components: Jar Analyzer

The Maven Jar Analyzer components can be used to gather various pieces of information about a given JAR file. Currently, the following operations are supported:

Maven Artifact Identification

To determine the Maven artifact metadata for a particular JAR, the {@link org.apache.maven.shared.jar.identification.JarIdentificationAnalysis} class is used. The class can be obtained through Plexus, or created standalone (in which case, see the class Javadoc for information on proper wiring).

Note that to use the class, you must first obtain a {@link org.apache.maven.shared.jar.JarAnalyzer} instance as instructed in its Javadoc.

The resulting information will be populated in the returned {@link org.apache.maven.shared.jar.identification.JarIdentification} class.

Example usage:

        JarAnalyzer jar = new JarAnalyzer( jarFile );
        JarIdenfitication jarIdenfitication;
        try
        {
            // instance must have been previously obtained through Plexus or created as instructed in its Javadoc
            jarIdenfitication = jarIdenfiticationAnalyzer.analyze( jar );
        }
        finally
        {
            jar.closeQuietly();
        }

        // continue to use jarIdenfitication or jar.getJarData()
    

Java Class Analysis

To determine the Java class metadata for a particular JAR, the {@link org.apache.maven.shared.jar.classes.JarClassesAnalysis} class is used. The class can be obtained through Plexus, or created standalone (in which case, see the class Javadoc for information on proper wiring).

Note that to use the class, you must first obtain a {@link org.apache.maven.shared.jar.JarAnalyzer} instance as instructed in its Javadoc.

The resulting information will be populated in the returned {@link org.apache.maven.shared.jar.classes.JarClasses} class.

Example usage:

        JarAnalyzer jar = new JarAnalyzer( jarFile );
        JarClasses jarClasses;
        try
        {
            // instance must have been previously obtained through Plexus or created as instructed in its Javadoc
            jarClasses = jarClassAnalyzer.analyze( jar );
        }
        finally
        {
            jar.closeQuietly();
        }

        // continue to use jarClasses or jar.getJarData()