forked from pool/plexus-cli
88 lines
4.1 KiB
Diff
88 lines
4.1 KiB
Diff
|
|
From 03df6f6688419f2d85116647c78e36b203c9a16a Mon Sep 17 00:00:00 2001
|
||
|
|
From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba@bluewin.ch>
|
||
|
|
Date: Thu, 19 May 2022 09:30:24 +0200
|
||
|
|
Subject: [PATCH 1/2] Do not use commons-cli deprecated classes
|
||
|
|
|
||
|
|
---
|
||
|
|
.../plexus/tools/cli/AbstractCli.java | 32 +++++++++----------
|
||
|
|
1 file changed, 15 insertions(+), 17 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java b/src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java
|
||
|
|
index aac570d..de8f675 100644
|
||
|
|
--- a/src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java
|
||
|
|
+++ b/src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java
|
||
|
|
@@ -18,9 +18,9 @@ package org.codehaus.plexus.tools.cli;
|
||
|
|
|
||
|
|
import org.apache.commons.cli.CommandLine;
|
||
|
|
import org.apache.commons.cli.CommandLineParser;
|
||
|
|
-import org.apache.commons.cli.GnuParser;
|
||
|
|
+import org.apache.commons.cli.DefaultParser;
|
||
|
|
import org.apache.commons.cli.HelpFormatter;
|
||
|
|
-import org.apache.commons.cli.OptionBuilder;
|
||
|
|
+import org.apache.commons.cli.Option;
|
||
|
|
import org.apache.commons.cli.Options;
|
||
|
|
import org.apache.commons.cli.ParseException;
|
||
|
|
import org.codehaus.plexus.ContainerConfiguration;
|
||
|
|
@@ -47,17 +47,17 @@ public abstract class AbstractCli
|
||
|
|
// These are standard options that we would want to use for all our projects.
|
||
|
|
// ----------------------------------------------------------------------------
|
||
|
|
|
||
|
|
- public static final char QUIET = 'q';
|
||
|
|
+ public static final String QUIET = "q";
|
||
|
|
|
||
|
|
- public static final char DEBUG = 'X';
|
||
|
|
+ public static final String DEBUG = "X";
|
||
|
|
|
||
|
|
- public static final char ERRORS = 'e';
|
||
|
|
+ public static final String ERRORS = "e";
|
||
|
|
|
||
|
|
- public static final char HELP = 'h';
|
||
|
|
+ public static final String HELP = "h";
|
||
|
|
|
||
|
|
- public static final char VERSION = 'v';
|
||
|
|
+ public static final String VERSION = "v";
|
||
|
|
|
||
|
|
- public static final char SET_SYSTEM_PROPERTY = 'D';
|
||
|
|
+ public static final String SET_SYSTEM_PROPERTY = "D";
|
||
|
|
|
||
|
|
// ----------------------------------------------------------------------------
|
||
|
|
// Abstract methods
|
||
|
|
@@ -344,19 +344,17 @@ public abstract class AbstractCli
|
||
|
|
options = new Options();
|
||
|
|
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create(
|
||
|
|
- SET_SYSTEM_PROPERTY ) );
|
||
|
|
+ Option.builder( SET_SYSTEM_PROPERTY ).longOpt( "define" ).hasArg().desc( "Define a system property" ).build() );
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
|
||
|
|
+ Option.builder( HELP ).longOpt( "help" ).desc( "Display help information" ).build() );
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create( VERSION ) );
|
||
|
|
+ Option.builder( VERSION ).longOpt( "version" ).desc( "Display version information" ).build() );
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) );
|
||
|
|
+ Option.builder( QUIET ).longOpt( "quiet" ).desc( "Quiet output - only show errors" ).build() );
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) );
|
||
|
|
+ Option.builder( DEBUG ).longOpt( "debug" ).desc( "Produce execution debug output" ).build() );
|
||
|
|
options.addOption(
|
||
|
|
- OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create(
|
||
|
|
- ERRORS ) );
|
||
|
|
+ Option.builder( ERRORS ).longOpt( "errors" ).desc( "Produce execution error messages" ).build() );
|
||
|
|
|
||
|
|
return buildCliOptions( options );
|
||
|
|
}
|
||
|
|
@@ -367,7 +365,7 @@ public abstract class AbstractCli
|
||
|
|
// We need to eat any quotes surrounding arguments...
|
||
|
|
String[] cleanArgs = cleanArgs( args );
|
||
|
|
|
||
|
|
- CommandLineParser parser = new GnuParser();
|
||
|
|
+ CommandLineParser parser = new DefaultParser();
|
||
|
|
|
||
|
|
return parser.parse( buildDefaultCliOptions(), cleanArgs );
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.36.1
|
||
|
|
|