Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JarClassesExposer |
|
| 1.5;1.5 |
1 | package org.apache.maven.shared.jar.identification.exposers; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.shared.jar.JarAnalyzer; | |
23 | import org.apache.maven.shared.jar.classes.JarClasses; | |
24 | import org.apache.maven.shared.jar.classes.JarClassesAnalysis; | |
25 | import org.apache.maven.shared.jar.identification.JarIdentification; | |
26 | import org.apache.maven.shared.jar.identification.JarIdentificationExposer; | |
27 | ||
28 | import java.util.Iterator; | |
29 | ||
30 | ||
31 | /** | |
32 | * Exposer that examines a JAR file to derive Maven metadata from the classes in a JAR. It will currently identify | |
33 | * potential group IDs from the class packages. | |
34 | * <p/> | |
35 | * Note: if not being used from Plexus, the {@link #setAnalyzer(org.apache.maven.shared.jar.classes.JarClassesAnalysis)} | |
36 | * method must be called to avoid a NullPointerException during the expose method. | |
37 | * | |
38 | * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationExposer" role-hint="jarClasses" | |
39 | */ | |
40 | 0 | public class JarClassesExposer |
41 | implements JarIdentificationExposer | |
42 | { | |
43 | /** | |
44 | * @plexus.requirement | |
45 | */ | |
46 | private JarClassesAnalysis analyzer; | |
47 | ||
48 | public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer ) | |
49 | { | |
50 | 0 | JarClasses jarclasses = analyzer.analyze( jarAnalyzer ); |
51 | ||
52 | 0 | Iterator it = jarclasses.getPackages().iterator(); |
53 | 0 | while ( it.hasNext() ) |
54 | { | |
55 | 0 | String packagename = (String) it.next(); |
56 | 0 | identification.addGroupId( packagename ); |
57 | 0 | } |
58 | 0 | } |
59 | ||
60 | public void setAnalyzer( JarClassesAnalysis analyzer ) | |
61 | { | |
62 | 0 | this.analyzer = analyzer; |
63 | 0 | } |
64 | } |