1 | |
package org.apache.maven.doxia.book; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
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 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class BookDoxiaCli |
39 | |
extends AbstractCli |
40 | |
{ |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public static void main( String[] args ) |
48 | |
throws Exception |
49 | |
{ |
50 | 0 | new BookDoxiaCli().execute( args ); |
51 | 0 | } |
52 | |
|
53 | |
|
54 | |
public String getPomPropertiesPath() |
55 | |
{ |
56 | 0 | return "META-INF/maven/org.apache.maven.doxia/doxia-book/pom.properties"; |
57 | |
} |
58 | |
|
59 | |
|
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 | |
|
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 | |
} |