Coverage Report - org.apache.maven.doxia.book.BookDoxiaCli
 
Classes in this File Line Coverage Branch Coverage Complexity
BookDoxiaCli
0%
0/17
N/A
1
 
 1  
 package org.apache.maven.doxia.book;
 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.commons.cli.CommandLine;
 23  
 import org.apache.commons.cli.OptionBuilder;
 24  
 import org.apache.commons.cli.Options;
 25  
 import org.apache.maven.doxia.book.model.BookModel;
 26  
 import org.codehaus.plexus.PlexusContainer;
 27  
 import org.codehaus.plexus.tools.cli.AbstractCli;
 28  
 import org.codehaus.plexus.util.FileUtils;
 29  
 
 30  
 import java.io.File;
 31  
 import java.util.List;
 32  
 
 33  
 /**
 34  
  * Invoke BookDoxia from the command line.
 35  
  *
 36  
  * @author Jason van Zyl
 37  
  */
 38  0
 public class BookDoxiaCli
 39  
     extends AbstractCli
 40  
 {
 41  
     /**
 42  
      * Execute the BookDoxia command line interface.
 43  
      *
 44  
      * @param args command line options.
 45  
      * @throws Exception if something goes wrong.
 46  
      */
 47  
     public static void main( String[] args )
 48  
         throws Exception
 49  
     {
 50  0
         new BookDoxiaCli().execute( args );
 51  0
     }
 52  
 
 53  
     /** {@inheritDoc} */
 54  
     public String getPomPropertiesPath()
 55  
     {
 56  0
         return "META-INF/maven/org.apache.maven.doxia/doxia-book/pom.properties";
 57  
     }
 58  
 
 59  
     /** {@inheritDoc} */
 60  
     public Options buildCliOptions( Options options )
 61  
     {
 62  0
         options.addOption( OptionBuilder.withLongOpt( "book-xml" ).hasArg().withDescription(
 63  
             "book xml file." )
 64  
             .create( 'b' ) );
 65  
 
 66  0
         options.addOption( OptionBuilder.withLongOpt( "content" ).hasArg().withDescription(
 67  
             "book content" )
 68  
             .create( 'c' ) );
 69  
 
 70  0
         options.addOption( OptionBuilder.withLongOpt( "output" ).hasArg().withDescription(
 71  
             "output directory" )
 72  
             .create( 'o' ) );
 73  
 
 74  0
         return options;
 75  
     }
 76  
 
 77  
     /** {@inheritDoc} */
 78  
     public void invokePlexusComponent( CommandLine cli,
 79  
                                        PlexusContainer plexus )
 80  
         throws Exception
 81  
     {
 82  0
         BookDoxia doxia = (BookDoxia) plexus.lookup( BookDoxia.ROLE );
 83  
 
 84  0
         String bookXml = cli.getOptionValue( 'b' );
 85  
 
 86  0
         String content = cli.getOptionValue( 'c' );
 87  
 
 88  0
         String output = cli.getOptionValue( 'o' );
 89  
 
 90  0
         File book1 = new File( bookXml );
 91  
 
 92  0
         List files = FileUtils.getFiles( new File( content ), "**/*.apt, **/*.xml", "" );
 93  
 
 94  0
         BookModel book = doxia.loadBook( book1 );
 95  
 
 96  0
         doxia.renderBook( book, "xdoc", files, new File( output ) );
 97  0
     }
 98  
 
 99  
 }