Author: hboutemy
Date: Sun Apr 29 22:33:19 2012
New Revision: 1332011
URL: http://svn.apache.org/viewvc?rev=1332011&view=rev
Log:
[MNG-5279] added CLI options to the code documentation site
Added:
maven/maven-3/trunk/maven-embedder/src/site/apt/
maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm (with props)
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
(with props)
Modified:
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
Modified:
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java?rev=1332011&r1=1332010&r2=1332011&view=diff
==============================================================================
---
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
(original)
+++
maven/maven-3/trunk/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
Sun Apr 29 22:33:19 2012
@@ -97,7 +97,7 @@ public class CLIManager
public static final String THREADS = "T";
- private Options options;
+ protected Options options;
@SuppressWarnings( "static-access" )
public CLIManager()
@@ -262,5 +262,4 @@ public class CLIManager
pw.flush();
}
-
}
Added: maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm?rev=1332011&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm (added)
+++ maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm Sun Apr 29
22:33:19 2012
@@ -0,0 +1,15 @@
+ -----
+ ${project.name}
+ -----
+ Hervé Boutemy
+ -----
+ 2012-04-29
+ -----
+
+${project.name}
+
+ ${project.description}
+
+Supported CLI Options
+
+%{snippet|file=${project.basedir}/target/test-classes/options.apt|verbatim=false}
Propchange: maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-embedder/src/site/apt/index.apt.vm
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
URL:
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java?rev=1332011&view=auto
==============================================================================
---
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
(added)
+++
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
Sun Apr 29 22:33:19 2012
@@ -0,0 +1,98 @@
+package org.apache.maven.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.commons.cli.Option;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+public class CLIManagerTest
+ extends PlexusTestCase
+{
+ private final static String LS = System.getProperty( "line.separator" );
+
+ private static class OptionComparator
+ implements Comparator<Option>
+ {
+ public int compare( Option opt1, Option opt2 )
+ {
+ return opt1.getOpt().compareToIgnoreCase( opt2.getOpt() );
+ }
+ }
+
+ private static class CLIManagerExtension
+ extends CLIManager
+ {
+ public Collection<Option> getOptions()
+ {
+ @SuppressWarnings( "unchecked" )
+ List<Option> optList = new ArrayList<Option>( options.getOptions()
);
+ Collections.sort( optList, new OptionComparator() );
+ return optList;
+ }
+ }
+
+ public String getOptionsAsApt()
+ {
+ StringBuilder sb = new StringBuilder();
+ boolean a = true;
+ sb.append( "<table border='1' class='zebra-striped'><tr
class='a'><th><b>Options</b></th><th><b>Description</b></th></tr>" );
+ for ( Option option : new CLIManagerExtension().getOptions() )
+ {
+ a = !a;
+ sb.append( "<tr class='" + ( a ? 'a' : 'b' ) + "'><td><code>-" );
+ sb.append( option.getOpt() );
+ sb.append( ",--" );
+ sb.append( option.getLongOpt() );
+ if ( option.hasArg() )
+ {
+ if ( option.hasArgName() )
+ {
+ sb.append( " <" ).append( option.getArgName() ).append(
">" );
+ }
+ else
+ {
+ sb.append( ' ' );
+ }
+ }
+ sb.append( "</code></td><td>" );
+ sb.append( option.getDescription() );
+ sb.append( "</td></tr>" );
+ sb.append( LS );
+ }
+ sb.append( "</table>" );
+ return sb.toString();
+ }
+
+ public void testOptionsAsApt()
+ throws IOException
+ {
+ File options = getTestFile( "target/test-classes/options.apt" );
+ FileUtils.fileWrite( options, "UTF-8", getOptionsAsApt() );
+ }
+}
Propchange:
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange:
maven/maven-3/trunk/maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain