Coverage Report - org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli
 
Classes in this File Line Coverage Branch Coverage Complexity
PlexusMetadataGeneratorCli
0 %
0/21
N/A
1
 
 1  
 package org.codehaus.plexus.metadata;
 2  
 
 3  
 import java.io.File;
 4  
 import java.util.Arrays;
 5  
 import java.util.Collections;
 6  
 
 7  
 import org.apache.commons.cli.CommandLine;
 8  
 import org.apache.commons.cli.OptionBuilder;
 9  
 import org.apache.commons.cli.Options;
 10  
 import org.codehaus.plexus.PlexusContainer;
 11  
 import org.codehaus.plexus.tools.cli.AbstractCli;
 12  
 
 13  0
 public class PlexusMetadataGeneratorCli
 14  
     extends AbstractCli
 15  
 {
 16  
     public static final char SOURCE_DIRECTORY = 's';
 17  
     public static final char SOURCE_ENCODING = 'e';
 18  
     public static final char CLASSES_DIRECTORY = 'c';
 19  
     public static final char OUTPUT_FILE = 'o';
 20  
     public static final char DESCRIPTORS_DIRECTORY = 'm';
 21  
 
 22  
     public static void main( String[] args )
 23  
         throws Exception
 24  
     {
 25  0
         new PlexusMetadataGeneratorCli().execute( args );
 26  0
     }
 27  
 
 28  
     @Override
 29  
     public String getPomPropertiesPath()
 30  
     {
 31  0
         return "META-INF/maven/org.codehaus.plexus/plexus-metadata-generator/pom.properties";
 32  
     }
 33  
 
 34  
     @Override
 35  
     @SuppressWarnings("static-access")
 36  
     public Options buildCliOptions( Options options )
 37  
     {
 38  0
         options.addOption( OptionBuilder.withLongOpt( "source" ).hasArg().withDescription( "Source directory." ).create( SOURCE_DIRECTORY ) );
 39  0
         options.addOption( OptionBuilder.withLongOpt( "encoding" ).hasArg().withDescription( "Source file encoding." ).create( SOURCE_ENCODING ) );
 40  0
         options.addOption( OptionBuilder.withLongOpt( "classes" ).hasArg().withDescription( "Classes directory." ).create( CLASSES_DIRECTORY ) );
 41  0
         options.addOption( OptionBuilder.withLongOpt( "output" ).hasArg().withDescription( "Output directory." ).create( OUTPUT_FILE ) );
 42  0
         options.addOption( OptionBuilder.withLongOpt( "descriptors" ).hasArg().withDescription( "Descriptors directory." ).create( DESCRIPTORS_DIRECTORY ) );
 43  0
         return options;
 44  
     }    
 45  
 
 46  
     public void invokePlexusComponent( CommandLine cli, PlexusContainer plexus )
 47  
         throws Exception
 48  
     {
 49  0
         MetadataGenerator metadataGenerator = plexus.lookup( MetadataGenerator.class );
 50  
         
 51  0
         MetadataGenerationRequest request = new MetadataGenerationRequest();        
 52  0
         request.classesDirectory = new File( cli.getOptionValue( CLASSES_DIRECTORY ) );
 53  0
         request.classpath = Collections.emptyList();
 54  0
         request.sourceDirectories = Arrays.asList( new String[]{ new File( cli.getOptionValue( SOURCE_DIRECTORY ) ).getAbsolutePath() } );
 55  0
         request.sourceEncoding = cli.getOptionValue( SOURCE_ENCODING );
 56  0
         request.useContextClassLoader = true;
 57  0
         request.outputFile = new File( cli.getOptionValue( OUTPUT_FILE ) );
 58  0
         request.componentDescriptorDirectory = new File( cli.getOptionValue( DESCRIPTORS_DIRECTORY ) );
 59  
         
 60  0
         metadataGenerator.generateDescriptor( request );
 61  0
     }
 62  
 }