Author: jvanzyl Date: Sat Nov 18 23:02:19 2006 New Revision: 476739 URL: http://svn.apache.org/viewvc?view=rev&rev=476739 Log: o using the doxia book stuff from the command line, added a little cli option
Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java (with props) Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/pom.xml Modified: maven/doxia/trunk/doxia-sandbox/doxia-book/pom.xml URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/pom.xml?view=diff&rev=476739&r1=476738&r2=476739 ============================================================================== --- maven/doxia/trunk/doxia-sandbox/doxia-book/pom.xml (original) +++ maven/doxia/trunk/doxia-sandbox/doxia-book/pom.xml Sat Nov 18 23:02:19 2006 @@ -1,25 +1,25 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<!-- -/* - * Copyright 2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<?xml version="1.0" encoding="ISO-8859-1"?> + +<!-- +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -50,11 +50,16 @@ <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-container-default</artifactId> <version>1.0-alpha-8</version> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-i18n</artifactId> - <version>1.0-beta-6</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-i18n</artifactId> + <version>1.0-beta-6</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-cli</artifactId> + <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> Added: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java?view=auto&rev=476739 ============================================================================== --- maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java (added) +++ maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java Sat Nov 18 23:02:19 2006 @@ -0,0 +1,69 @@ +package org.apache.maven.doxia.book; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; +import org.apache.maven.doxia.book.model.BookModel; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.tools.cli.AbstractCli; +import org.codehaus.plexus.util.FileUtils; + +import java.io.File; +import java.util.List; + +/** + * @author Jason van Zyl + */ +public class BookDoxiaCli + extends AbstractCli +{ + public static void main( String[] args ) + throws Exception + { + new BookDoxiaCli().execute( args ); + } + + public String getPomPropertiesPath() + { + return "META-INF/maven/org.apache.maven.doxia/doxia-book/pom.properties"; + } + + public Options buildCliOptions( Options options ) + { + options.addOption( OptionBuilder.withLongOpt( "book-xml" ).hasArg().withDescription( + "book xml file." ) + .create( 'b' ) ); + + options.addOption( OptionBuilder.withLongOpt( "content" ).hasArg().withDescription( + "book content" ) + .create( 'c' ) ); + + options.addOption( OptionBuilder.withLongOpt( "output" ).hasArg().withDescription( + "output directory" ) + .create( 'o' ) ); + + return options; + } + + public void invokePlexusComponent( CommandLine cli, + PlexusContainer plexus ) + throws Exception + { + BookDoxia doxia = (BookDoxia) plexus.lookup( BookDoxia.ROLE ); + + String bookXml = cli.getOptionValue( 'b' ); + + String content = cli.getOptionValue( 'c' ); + + String output = cli.getOptionValue( 'o' ); + + File book1 = new File( bookXml ); + + List files = FileUtils.getFiles( new File( content ), "**/*.apt, **/*.xml", "" ); + + BookModel book = doxia.loadBook( book1 ); + + doxia.renderBook( book, "xdoc", files, new File( output ) ); + } + +} Propchange: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/doxia/trunk/doxia-sandbox/doxia-book/src/main/java/org/apache/maven/doxia/book/BookDoxiaCli.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision