Coverage Report - org.apache.maven.shared.jar.identification.exposers.ManifestExposer
 
Classes in this File Line Coverage Branch Coverage Complexity
ManifestExposer
0%
0/20
0%
0/4
2
 
 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.identification.JarIdentification;
 24  
 import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 25  
 
 26  
 import java.util.Iterator;
 27  
 import java.util.Map;
 28  
 import java.util.jar.Attributes;
 29  
 import java.util.jar.Manifest;
 30  
 
 31  
 /**
 32  
  * Exposer that examines a JAR's manifest to derive Maven metadata.
 33  
  *
 34  
  * @plexus.component role="org.apache.maven.shared.jar.identification.JarIdentificationExposer" role-hint="manifest"
 35  
  */
 36  0
 public class ManifestExposer
 37  
     implements JarIdentificationExposer
 38  
 {
 39  
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
 40  
     {
 41  0
         Manifest manifest = jarAnalyzer.getJarData().getManifest();
 42  0
         if ( manifest != null )
 43  
         {
 44  0
             addManifestAttributeValues( manifest.getMainAttributes(), identification );
 45  
 
 46  0
             Map entries = manifest.getEntries();
 47  0
             Iterator itentries = entries.entrySet().iterator();
 48  0
             while ( itentries.hasNext() )
 49  
             {
 50  0
                 Map.Entry entry = (Map.Entry) itentries.next();
 51  0
                 Attributes attribs = (Attributes) entry.getValue();
 52  
 
 53  0
                 addManifestAttributeValues( attribs, identification );
 54  0
             }
 55  
         }
 56  0
     }
 57  
 
 58  
     private void addManifestAttributeValues( Attributes attribs, JarIdentification identification )
 59  
     {
 60  0
         identification.addName( attribs.getValue( Attributes.Name.IMPLEMENTATION_TITLE ) );
 61  0
         identification.addVersion( attribs.getValue( Attributes.Name.IMPLEMENTATION_VERSION ) );
 62  0
         identification.addVendor( attribs.getValue( Attributes.Name.IMPLEMENTATION_VENDOR ) );
 63  
 
 64  0
         identification.addName( attribs.getValue( Attributes.Name.SPECIFICATION_TITLE ) );
 65  0
         identification.addVersion( attribs.getValue( Attributes.Name.SPECIFICATION_VERSION ) );
 66  0
         identification.addVendor( attribs.getValue( Attributes.Name.SPECIFICATION_VENDOR ) );
 67  
 
 68  0
         identification.addGroupId( attribs.getValue( Attributes.Name.EXTENSION_NAME ) );
 69  0
     }
 70  
 }