| 1 |
<!-- |
| 2 |
~ Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
~ or more contributor license agreements. See the NOTICE file |
| 4 |
~ distributed with this work for additional information |
| 5 |
~ regarding copyright ownership. The ASF licenses this file |
| 6 |
~ to you under the Apache License, Version 2.0 (the |
| 7 |
~ "License"); you may not use this file except in compliance |
| 8 |
~ with the License. You may obtain a copy of the License at |
| 9 |
~ |
| 10 |
~ http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
~ |
| 12 |
~ Unless required by applicable law or agreed to in writing, |
| 13 |
~ software distributed under the License is distributed on an |
| 14 |
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
~ KIND, either express or implied. See the License for the |
| 16 |
~ specific language governing permissions and limitations |
| 17 |
~ under the License. |
| 18 |
--> |
| 19 |
|
| 20 |
<html> |
| 21 |
<head> |
| 22 |
<title>Maven Shared Components: Jar Analyzer</title> |
| 23 |
</head> |
| 24 |
<body> |
| 25 |
|
| 26 |
<h1>Maven Shared Components: Jar Analyzer</h1> |
| 27 |
|
| 28 |
<p> |
| 29 |
The Maven Jar Analyzer components can be used to gather various pieces of information about a given JAR file. |
| 30 |
|
| 31 |
Currently, the following operations are supported: |
| 32 |
</p> |
| 33 |
<ul> |
| 34 |
<li><a href="#Identification">Maven Artifact Identification</a> - examine the JAR and its contents to try and |
| 35 |
determine any associated Maven metadata such as group and artifact ID. |
| 36 |
</li> |
| 37 |
<li><a href="#ClassAnalysis">Java Class Analysis</a> - examine ther JAR's class file contents to determine various |
| 38 |
pieces of Java metadata. |
| 39 |
</li> |
| 40 |
</ul> |
| 41 |
|
| 42 |
<h2 id="Identification">Maven Artifact Identification</h2> |
| 43 |
|
| 44 |
<p> |
| 45 |
To determine the Maven artifact metadata for a particular JAR, the |
| 46 |
{@link org.apache.maven.shared.jar.identification.JarIdentificationAnalysis} class is used. |
| 47 |
The class can be obtained through Plexus, or created standalone (in which case, see the class Javadoc for |
| 48 |
information on proper wiring). |
| 49 |
</p> |
| 50 |
|
| 51 |
<p> |
| 52 |
Note that to use the class, you must first obtain a {@link org.apache.maven.shared.jar.JarAnalyzer} instance as |
| 53 |
instructed in its Javadoc. |
| 54 |
</p> |
| 55 |
|
| 56 |
<p> |
| 57 |
The resulting information will be populated in the returned |
| 58 |
{@link org.apache.maven.shared.jar.identification.JarIdentification} class. |
| 59 |
</p> |
| 60 |
|
| 61 |
<p> |
| 62 |
Example usage: |
| 63 |
</p> |
| 64 |
|
| 65 |
<pre> |
| 66 |
JarAnalyzer jar = new JarAnalyzer( jarFile ); |
| 67 |
JarIdenfitication jarIdenfitication; |
| 68 |
try |
| 69 |
{ |
| 70 |
// instance must have been previously obtained through Plexus or created as instructed in its Javadoc |
| 71 |
jarIdenfitication = jarIdenfiticationAnalyzer.analyze( jar ); |
| 72 |
} |
| 73 |
finally |
| 74 |
{ |
| 75 |
jar.closeQuietly(); |
| 76 |
} |
| 77 |
|
| 78 |
// continue to use jarIdenfitication or jar.getJarData() |
| 79 |
</pre> |
| 80 |
|
| 81 |
<h2 id="ClassAnalysis">Java Class Analysis</h2> |
| 82 |
|
| 83 |
<p> |
| 84 |
To determine the Java class metadata for a particular JAR, the |
| 85 |
{@link org.apache.maven.shared.jar.classes.JarClassesAnalysis} class is used. |
| 86 |
The class can be obtained through Plexus, or created standalone (in which case, see the class Javadoc for |
| 87 |
information on proper wiring). |
| 88 |
</p> |
| 89 |
|
| 90 |
<p> |
| 91 |
Note that to use the class, you must first obtain a {@link org.apache.maven.shared.jar.JarAnalyzer} instance as |
| 92 |
instructed in its Javadoc. |
| 93 |
</p> |
| 94 |
|
| 95 |
<p> |
| 96 |
The resulting information will be populated in the returned |
| 97 |
{@link org.apache.maven.shared.jar.classes.JarClasses} class. |
| 98 |
</p> |
| 99 |
|
| 100 |
<p> |
| 101 |
Example usage: |
| 102 |
</p> |
| 103 |
<pre> |
| 104 |
JarAnalyzer jar = new JarAnalyzer( jarFile ); |
| 105 |
JarClasses jarClasses; |
| 106 |
try |
| 107 |
{ |
| 108 |
// instance must have been previously obtained through Plexus or created as instructed in its Javadoc |
| 109 |
jarClasses = jarClassAnalyzer.analyze( jar ); |
| 110 |
} |
| 111 |
finally |
| 112 |
{ |
| 113 |
jar.closeQuietly(); |
| 114 |
} |
| 115 |
|
| 116 |
// continue to use jarClasses or jar.getJarData() |
| 117 |
</pre> |
| 118 |
|
| 119 |
</body> |
| 120 |
</html> |