[Git][java-team/plexus-cli][master] 4 commits: New upstream version 1.7

Andreas Tille (@tille) gitlab at salsa.debian.org
Sun Feb 23 20:50:16 GMT 2025



Andreas Tille pushed to branch master at Debian Java Maintainers / plexus-cli


Commits:
f65791b7 by Andreas Tille at 2025-02-23T21:48:24+01:00
New upstream version 1.7
- - - - -
dc200230 by Andreas Tille at 2025-02-23T21:48:24+01:00
Update upstream source from tag 'upstream/1.7'

Update to upstream version '1.7'
with Debian dir aa8e1ab382e5afed72622e256868d7a0332b2185
- - - - -
245833c3 by Andreas Tille at 2025-02-23T21:49:21+01:00
New upstream version

- - - - -
8a7c2383 by Andreas Tille at 2025-02-23T21:49:55+01:00
Do not use maven-scm-publish-plugin

- - - - -


15 changed files:

- + .github/dependabot.yml
- + .github/workflows/maven.yml
- + .gitignore
- + README.md
- debian/changelog
- debian/patches/0001-add-dependency-plexus-container-default-to-pom.xml.patch
- debian/patches/0002-junit-dependency.patch
- + debian/patches/0003-no-maven-scm-publish-plugin.patch
- debian/patches/series
- pom.xml
- src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java
- src/main/java/org/codehaus/plexus/tools/cli/Cli.java
- + src/site/site.xml
- src/test/java/org/codehaus/plexus/tools/cli/CliTest.java
- src/test/java/org/codehaus/plexus/tools/cli/TestCli.java


Changes:

=====================================
.github/dependabot.yml
=====================================
@@ -0,0 +1,27 @@
+#
+#  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.
+#
+version: 2
+updates:
+  - package-ecosystem: "maven"
+    directory: "/"
+    schedule:
+      interval: "daily"
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: "daily"
+


=====================================
.github/workflows/maven.yml
=====================================
@@ -0,0 +1,31 @@
+# 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.
+
+name: GitHub CI
+
+on: [push, pull_request]
+
+jobs:
+  build:
+    name: Build it
+    uses: codehaus-plexus/.github/.github/workflows/maven.yml at master
+
+  deploy:
+    name: Deploy
+    needs: build
+    uses: codehaus-plexus/.github/.github/workflows/maven-deploy.yml at master
+    secrets: inherit


=====================================
.gitignore
=====================================
@@ -0,0 +1,7 @@
+target/
+.project
+.classpath
+.settings/
+bin
+*.iml
+.idea


=====================================
README.md
=====================================
@@ -0,0 +1,7 @@
+Plexus-CLI
+===============
+
+[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/codehaus-plexus/plexus-cli.svg?label=License)](http://www.apache.org/licenses/)
+[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-cli.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.plexus/plexus-cli)
+
+The canonical git repository is located at https://github.com/codehaus-plexus/plexus-cli


=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+plexus-cli (1.7-1) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * New upstream version
+  * Do not use maven-scm-publish-plugin
+
+ -- Andreas Tille <tille at debian.org>  Sun, 23 Feb 2025 21:48:47 +0100
+
 plexus-cli (1.2-8) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/patches/0001-add-dependency-plexus-container-default-to-pom.xml.patch
=====================================
@@ -6,13 +6,11 @@ Subject: [PATCH] add dependency plexus-container-default to pom.xml
  pom.xml |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
 
-diff --git a/pom.xml b/pom.xml
-index 87f4c2d..f7f6d40 100644
 --- a/pom.xml
 +++ b/pom.xml
-@@ -37,6 +37,11 @@
-         </exclusion>
-       </exclusions>
+@@ -67,6 +67,11 @@
+       <version>1.3.0</version>
+       <scope>test</scope>
      </dependency>
 +    <dependency>
 +      <groupId>org.codehaus.plexus</groupId>
@@ -21,5 +19,4 @@ index 87f4c2d..f7f6d40 100644
 +    </dependency>
    </dependencies>
  
-   <scm>
--- 
+   <build>


=====================================
debian/patches/0002-junit-dependency.patch
=====================================
@@ -3,7 +3,7 @@ Author: Emmanuel Bourg <ebourg at apache.org>
 Forwarded: no
 --- a/pom.xml
 +++ b/pom.xml
-@@ -42,6 +42,12 @@
+@@ -72,6 +72,12 @@
        <artifactId>plexus-container-default</artifactId>
        <version>1.0-beta-3.0.7</version>
      </dependency>
@@ -15,4 +15,4 @@ Forwarded: no
 +    </dependency>
    </dependencies>
  
-   <scm>
+   <build>


=====================================
debian/patches/0003-no-maven-scm-publish-plugin.patch
=====================================
@@ -0,0 +1,31 @@
+Author: Andreas Tille <tille at debian.org>
+Last-Update: 2025-02-23
+Description: Do not use maven-scm-publish-plugin since we are offline anyway
+
+--- a/pom.xml
++++ b/pom.xml
+@@ -82,24 +82,6 @@
+ 
+   <build>
+     <plugins>
+-      <plugin>
+-        <groupId>org.apache.maven.plugins</groupId>
+-        <artifactId>maven-scm-publish-plugin</artifactId>
+-        <configuration>
+-          <!-- mono-module doesn't require site:stage -->
+-          <content>${project.reporting.outputDirectory}</content>
+-        </configuration>
+-        <executions>
+-          <execution>
+-            <!-- deploy site with maven-scm-publish-plugin -->
+-            <id>scm-publish</id>
+-            <goals>
+-              <goal>publish-scm</goal>
+-            </goals>
+-            <phase>site-deploy</phase>
+-          </execution>
+-        </executions>
+-      </plugin>
+     </plugins>
+   </build>
+ </project>


=====================================
debian/patches/series
=====================================
@@ -1,2 +1,3 @@
 0001-add-dependency-plexus-container-default-to-pom.xml.patch
 0002-junit-dependency.patch
+0003-no-maven-scm-publish-plugin.patch


=====================================
pom.xml
=====================================
@@ -1,47 +1,94 @@
-<?xml version="1.0"?><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">
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
   <parent>
-    <artifactId>plexus-tools</artifactId>
     <groupId>org.codehaus.plexus</groupId>
-    <version>1.0.8</version>
+    <artifactId>plexus</artifactId>
+    <version>16</version>
   </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <groupId>org.codehaus.plexus</groupId>
+
   <artifactId>plexus-cli</artifactId>
+  <version>1.7</version>
+
   <name>Plexus CLI</name>
   <description>Easily create CLIs with Plexus components</description>
-  <version>1.2</version>
-  <url>http://maven.apache.org</url>
+
+  <scm>
+    <connection>scm:git:https://github.com/codehaus-plexus/plexus-cli.git</connection>
+    <developerConnection>scm:git:https://github.com/codehaus-plexus/plexus-cli.git</developerConnection>
+    <tag>plexus-cli-1.7</tag>
+    <url>https://github.com/codehaus-plexus/plexus-cli/tree/${project.scm.tag}/</url>
+  </scm>
+  <issueManagement>
+    <system>github</system>
+    <url>https://github.com/codehaus-plexus/plexus-cli/issues</url>
+  </issueManagement>
+  <distributionManagement>
+    <site>
+      <id>github:gh-pages</id>
+      <url>${project.scm.developerConnection}</url>
+    </site>
+  </distributionManagement>
+
+  <properties>
+    <project.build.outputTimestamp>2023-12-23T21:44:13Z</project.build.outputTimestamp>
+  </properties>
+
   <dependencies>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
-      <version>1.0-alpha-34</version>
+      <groupId>org.eclipse.sisu</groupId>
+      <artifactId>org.eclipse.sisu.plexus</artifactId>
+      <version>0.3.5</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.4.7</version>
+      <version>4.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-xml</artifactId>
+      <version>3.0.0</version>
     </dependency>
     <dependency>
       <groupId>commons-cli</groupId>
       <artifactId>commons-cli</artifactId>
-      <version>1.0</version>
-      <exclusions>
-        <exclusion>
-          <artifactId>commons-lang</artifactId>
-          <groupId>commons-lang</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>commons-logging</artifactId>
-          <groupId>commons-logging</groupId>
-        </exclusion>
-      </exclusions>
+      <version>1.6.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-testing</artifactId>
+      <version>1.3.0</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 
-  <scm>
-    <connection>scm:svn:http://svn.codehaus.org/plexus/plexus-tools/tags/plexus-cli-1.2</connection>
-    <developerConnection>scm:svn:https://svn.codehaus.org/plexus/plexus-tools/tags/plexus-cli-1.2</developerConnection>
-    <url>http://fisheye.codehaus.org/browse/plexus/plexus-tools/tags/plexus-cli-1.2</url>
-  </scm>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-scm-publish-plugin</artifactId>
+        <configuration>
+          <!-- mono-module doesn't require site:stage -->
+          <content>${project.reporting.outputDirectory}</content>
+        </configuration>
+        <executions>
+          <execution>
+            <!-- deploy site with maven-scm-publish-plugin -->
+            <id>scm-publish</id>
+            <goals>
+              <goal>publish-scm</goal>
+            </goals>
+            <phase>site-deploy</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>


=====================================
src/main/java/org/codehaus/plexus/tools/cli/AbstractCli.java
=====================================
@@ -1,5 +1,27 @@
 package org.codehaus.plexus.tools.cli;
 
+/*
+ * Copyright 2006 The Codehaus 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.GnuParser;
@@ -15,20 +37,10 @@ import org.codehaus.plexus.PlexusContainerException;
 import org.codehaus.plexus.classworlds.ClassWorld;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
 /**
  * @author jason van zyl
- * @version $Id: AbstractCli.java 7021 2007-10-26 23:41:24Z jvanzyl $
- * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE
  */
-public abstract class AbstractCli
-    implements Cli
-{
+public abstract class AbstractCli implements Cli {
     // ----------------------------------------------------------------------------
     // These are standard options that we would want to use for all our projects.
     // ----------------------------------------------------------------------------
@@ -49,61 +61,51 @@ public abstract class AbstractCli
     // Abstract methods
     // ----------------------------------------------------------------------------
 
-    public abstract Options buildCliOptions( Options options );
+    public abstract Options buildCliOptions(Options options);
 
-    public abstract void invokePlexusComponent( CommandLine cli,
-                                                PlexusContainer container )
-        throws Exception;
+    public abstract void invokePlexusComponent(CommandLine cli, PlexusContainer container) throws Exception;
 
-    public String getPomPropertiesPath()
-    {
+    public String getPomPropertiesPath() {
         return null;
     }
 
-    public int execute( String[] args )
-    {
-        ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );
+    public int execute(String[] args) {
+        ClassWorld classWorld =
+                new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
 
-        return execute( args, classWorld );
+        return execute(args, classWorld);
     }
 
-    public int execute( String[] args,
-                        ClassWorld classWorld )
-    {
+    public int execute(String[] args, ClassWorld classWorld) {
         CommandLine cli;
 
-        try
-        {
-            cli = parse( args );
-        }
-        catch ( ParseException e )
-        {
-            System.err.println( "Unable to parse command line options: " + e.getMessage() );
+        try {
+            cli = parse(args);
+        } catch (ParseException e) {
+            System.err.println("Unable to parse command line options: " + e.getMessage());
 
             displayHelp();
 
             return 1;
         }
 
-        if ( System.getProperty( "java.class.version", "44.0" ).compareTo( "48.0" ) < 0 )
-        {
-            System.err.println( "Sorry, but JDK 1.4 or above is required to execute Maven" );
+        if (System.getProperty("java.class.version", "44.0").compareTo("48.0") < 0) {
+            System.err.println("Sorry, but JDK 1.4 or above is required to execute Maven");
 
             System.err.println(
-                "You appear to be using Java version: " + System.getProperty( "java.version", "<unknown>" ) );
+                    "You appear to be using Java version: " + System.getProperty("java.version", "<unknown>"));
 
             return 1;
         }
 
-        boolean debug = cli.hasOption( DEBUG );
+        boolean debug = cli.hasOption(DEBUG);
 
-        boolean quiet = !debug && cli.hasOption( QUIET );
+        boolean quiet = !debug && cli.hasOption(QUIET);
 
-        boolean showErrors = debug || cli.hasOption( ERRORS );
+        boolean showErrors = debug || cli.hasOption(ERRORS);
 
-        if ( showErrors )
-        {
-            System.out.println( "+ Error stacktraces are turned on." );
+        if (showErrors) {
+            System.out.println("+ Error stacktraces are turned on.");
         }
 
         // ----------------------------------------------------------------------------
@@ -112,16 +114,11 @@ public abstract class AbstractCli
 
         int loggingLevel;
 
-        if ( debug )
-        {
+        if (debug) {
             loggingLevel = 0;
-        }
-        else if ( quiet )
-        {
+        } else if (quiet) {
             loggingLevel = 0;
-        }
-        else
-        {
+        } else {
             loggingLevel = 0;
         }
 
@@ -129,21 +126,17 @@ public abstract class AbstractCli
         // Process particular command line options
         // ----------------------------------------------------------------------
 
-        if ( cli.hasOption( HELP ) )
-        {
+        if (cli.hasOption(HELP)) {
             displayHelp();
 
             return 0;
         }
 
-        if ( cli.hasOption( VERSION ) )
-        {
+        if (cli.hasOption(VERSION)) {
             showVersion();
 
             return 0;
-        }
-        else if ( debug )
-        {
+        } else if (debug) {
             showVersion();
         }
 
@@ -151,60 +144,46 @@ public abstract class AbstractCli
         // This is what we will generalize for the invocation of the command line.
         // ----------------------------------------------------------------------------
 
-        try
-        {
-            ContainerConfiguration configuration = new DefaultContainerConfiguration()
-                .setClassWorld( classWorld );
+        try {
+            ContainerConfiguration configuration = new DefaultContainerConfiguration().setClassWorld(classWorld);
 
-            PlexusContainer plexus = new DefaultPlexusContainer( configuration );
+            customizeContainerConfiguration(configuration, cli);
 
-            invokePlexusComponent( cli, plexus );
-        }
-        catch ( PlexusContainerException e )
-        {
-            showFatalError( "Cannot create Plexus container.", e, true );
-        }
-        catch ( ComponentLookupException e )
-        {
-            showError( "Cannot lookup application component.", e, true );
-        }
-        catch ( Exception e )
-        {
-            showError( "Problem executing command line.", e, true );
+            PlexusContainer plexus = new DefaultPlexusContainer(configuration);
+
+            invokePlexusComponent(cli, plexus);
+        } catch (PlexusContainerException e) {
+            showFatalError("Cannot create Plexus container.", e, true);
+        } catch (ComponentLookupException e) {
+            showError("Cannot lookup application component.", e, true);
+        } catch (Exception e) {
+            showError("Problem executing command line.", e, true);
         }
 
         return 0;
     }
 
-    protected int showFatalError( String message,
-                                  Exception e,
-                                  boolean show )
-    {
-        System.err.println( "FATAL ERROR: " + message );
+    protected void customizeContainerConfiguration(ContainerConfiguration configuration, CommandLine cli) {}
 
-        if ( show )
-        {
-            System.err.println( "Error stacktrace:" );
+    protected int showFatalError(String message, Exception e, boolean show) {
+        System.err.println("FATAL ERROR: " + message);
+
+        if (show) {
+            System.err.println("Error stacktrace:");
 
             e.printStackTrace();
-        }
-        else
-        {
-            System.err.println( "For more information, run with the -e flag" );
+        } else {
+            System.err.println("For more information, run with the -e flag");
         }
 
         return 1;
     }
 
-    protected void showError( String message,
-                              Exception e,
-                              boolean show )
-    {
-        System.err.println( message );
+    protected void showError(String message, Exception e, boolean show) {
+        System.err.println(message);
 
-        if ( show )
-        {
-            System.err.println( "Error stacktrace:" );
+        if (show) {
+            System.err.println("Error stacktrace:");
 
             e.printStackTrace();
         }
@@ -212,47 +191,38 @@ public abstract class AbstractCli
 
     // Need to get the versions of the application in a general way, so that I need a way to get the
     // specifics of the application so that I can do this in a general way.
-    private void showVersion()
-    {
+    private void showVersion() {
         InputStream is;
 
-        try
-        {
+        try {
             Properties properties = new Properties();
 
             String pomPropertiesPath = getPomPropertiesPath();
 
-            if ( pomPropertiesPath == null )
-            {
-                System.err.println( "Unable determine version from JAR file." );
+            if (pomPropertiesPath == null) {
+                System.err.println("Unable determine version from JAR file.");
 
                 return;
             }
 
-            is = AbstractCli.class.getClassLoader().getResourceAsStream( pomPropertiesPath );
+            is = AbstractCli.class.getClassLoader().getResourceAsStream(pomPropertiesPath);
 
-            if ( is == null )
-            {
-                System.err.println( "Unable determine version from JAR file." );
+            if (is == null) {
+                System.err.println("Unable determine version from JAR file.");
 
                 return;
             }
 
-            properties.load( is );
+            properties.load(is);
 
-            if ( properties.getProperty( "builtOn" ) != null )
-            {
-                System.out.println( "Version: " + properties.getProperty( "version", "unknown" ) + " built on " +
-                    properties.getProperty( "builtOn" ) );
+            if (properties.getProperty("builtOn") != null) {
+                System.out.println("Version: " + properties.getProperty("version", "unknown") + " built on "
+                        + properties.getProperty("builtOn"));
+            } else {
+                System.out.println("Version: " + properties.getProperty("version", "unknown"));
             }
-            else
-            {
-                System.out.println( "Version: " + properties.getProperty( "version", "unknown" ) );
-            }
-        }
-        catch ( IOException e )
-        {
-            System.err.println( "Unable determine version from JAR file: " + e.getMessage() );
+        } catch (IOException e) {
+            System.err.println("Unable determine version from JAR file: " + e.getMessage());
         }
     }
 
@@ -260,8 +230,7 @@ public abstract class AbstractCli
     // System properties handling
     // ----------------------------------------------------------------------
 
-    private Properties getExecutionProperties( CommandLine commandLine )
-    {
+    private Properties getExecutionProperties(CommandLine commandLine) {
         Properties executionProperties = new Properties();
 
         // ----------------------------------------------------------------------
@@ -270,142 +239,127 @@ public abstract class AbstractCli
         // are most dominant.
         // ----------------------------------------------------------------------
 
-        if ( commandLine.hasOption( SET_SYSTEM_PROPERTY ) )
-        {
-            String[] defStrs = commandLine.getOptionValues( SET_SYSTEM_PROPERTY );
+        if (commandLine.hasOption(SET_SYSTEM_PROPERTY)) {
+            String[] defStrs = commandLine.getOptionValues(SET_SYSTEM_PROPERTY);
 
-            for ( int i = 0; i < defStrs.length; ++i )
-            {
-                setCliProperty( defStrs[i], executionProperties );
+            for (int i = 0; i < defStrs.length; ++i) {
+                setCliProperty(defStrs[i], executionProperties);
             }
         }
 
-        executionProperties.putAll( System.getProperties() );
+        executionProperties.putAll(System.getProperties());
 
         return executionProperties;
     }
 
-    private void setCliProperty( String property,
-                                 Properties executionProperties )
-    {
+    private void setCliProperty(String property, Properties executionProperties) {
         String name;
 
         String value;
 
-        int i = property.indexOf( "=" );
+        int i = property.indexOf("=");
 
-        if ( i <= 0 )
-        {
+        if (i <= 0) {
             name = property.trim();
 
             value = "true";
-        }
-        else
-        {
-            name = property.substring( 0, i ).trim();
+        } else {
+            name = property.substring(0, i).trim();
 
-            value = property.substring( i + 1 ).trim();
+            value = property.substring(i + 1).trim();
         }
 
-        executionProperties.setProperty( name, value );
+        executionProperties.setProperty(name, value);
 
         // ----------------------------------------------------------------------
         // I'm leaving the setting of system properties here as not to break
         // the SystemPropertyProfileActivator. This won't harm embedding. jvz.
         // ----------------------------------------------------------------------
 
-        System.setProperty( name, value );
+        System.setProperty(name, value);
     }
 
     private Options options;
 
-    public Options buildDefaultCliOptions()
-    {
+    public Options buildDefaultCliOptions() {
         options = new Options();
 
-        options.addOption(
-            OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create(
-                SET_SYSTEM_PROPERTY ) );
-        options.addOption(
-            OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
-        options.addOption(
-            OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create( VERSION ) );
-        options.addOption(
-            OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) );
-        options.addOption(
-            OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) );
-        options.addOption(
-            OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create(
-                ERRORS ) );
-
-        return buildCliOptions( options );
+        options.addOption(OptionBuilder.withLongOpt("define")
+                .hasArg()
+                .withDescription("Define a system property")
+                .create(SET_SYSTEM_PROPERTY));
+        options.addOption(OptionBuilder.withLongOpt("help")
+                .withDescription("Display help information")
+                .create(HELP));
+        options.addOption(OptionBuilder.withLongOpt("version")
+                .withDescription("Display version information")
+                .create(VERSION));
+        options.addOption(OptionBuilder.withLongOpt("quiet")
+                .withDescription("Quiet output - only show errors")
+                .create(QUIET));
+        options.addOption(OptionBuilder.withLongOpt("debug")
+                .withDescription("Produce execution debug output")
+                .create(DEBUG));
+        options.addOption(OptionBuilder.withLongOpt("errors")
+                .withDescription("Produce execution error messages")
+                .create(ERRORS));
+
+        return buildCliOptions(options);
     }
 
-    public CommandLine parse( String[] args )
-        throws ParseException
-    {
+    public CommandLine parse(String[] args) throws ParseException {
         // We need to eat any quotes surrounding arguments...
-        String[] cleanArgs = cleanArgs( args );
+        String[] cleanArgs = cleanArgs(args);
 
         CommandLineParser parser = new GnuParser();
 
-        return parser.parse( buildDefaultCliOptions(), cleanArgs );
+        return parser.parse(buildDefaultCliOptions(), cleanArgs);
     }
 
-    private static String[] cleanArgs( String[] args )
-    {
+    private static String[] cleanArgs(String[] args) {
         List cleaned = new ArrayList();
 
         StringBuffer currentArg = null;
 
-        for ( int i = 0; i < args.length; i++ )
-        {
+        for (int i = 0; i < args.length; i++) {
             String arg = args[i];
 
             boolean addedToBuffer = false;
 
-            if ( arg.startsWith( "\"" ) )
-            {
+            if (arg.startsWith("\"")) {
                 // if we're in the process of building up another arg, push it and start over.
                 // this is for the case: "-Dfoo=bar "-Dfoo2=bar two" (note the first unterminated quote)
-                if ( currentArg != null )
-                {
-                    cleaned.add( currentArg.toString() );
+                if (currentArg != null) {
+                    cleaned.add(currentArg.toString());
                 }
 
                 // start building an argument here.
-                currentArg = new StringBuffer( arg.substring( 1 ) );
+                currentArg = new StringBuffer(arg.substring(1));
 
                 addedToBuffer = true;
             }
 
             // this has to be a separate "if" statement, to capture the case of: "-Dfoo=bar"
-            if ( arg.endsWith( "\"" ) )
-            {
-                String cleanArgPart = arg.substring( 0, arg.length() - 1 );
+            if (arg.endsWith("\"")) {
+                String cleanArgPart = arg.substring(0, arg.length() - 1);
 
                 // if we're building an argument, keep doing so.
-                if ( currentArg != null )
-                {
+                if (currentArg != null) {
                     // if this is the case of "-Dfoo=bar", then we need to adjust the buffer.
-                    if ( addedToBuffer )
-                    {
-                        currentArg.setLength( currentArg.length() - 1 );
+                    if (addedToBuffer) {
+                        currentArg.setLength(currentArg.length() - 1);
                     }
                     // otherwise, we trim the trailing " and append to the buffer.
-                    else
-                    {
+                    else {
                         // TODO: introducing a space here...not sure what else to do but collapse whitespace
-                        currentArg.append( ' ' ).append( cleanArgPart );
+                        currentArg.append(' ').append(cleanArgPart);
                     }
 
                     // we're done with this argument, so add it.
-                    cleaned.add( currentArg.toString() );
-                }
-                else
-                {
+                    cleaned.add(currentArg.toString());
+                } else {
                     // this is a simple argument...just add it.
-                    cleaned.add( cleanArgPart );
+                    cleaned.add(cleanArgPart);
                 }
 
                 // the currentArg MUST be finished when this completes.
@@ -418,49 +372,41 @@ public abstract class AbstractCli
             // buffer, then append it with a preceding space...again, not sure what else to
             // do other than collapse whitespace.
             // NOTE: The case of a trailing quote is handled by nullifying the arg buffer.
-            if ( !addedToBuffer )
-            {
+            if (!addedToBuffer) {
                 // append to the argument we're building, collapsing whitespace to a single space.
-                if ( currentArg != null )
-                {
-                    currentArg.append( ' ' ).append( arg );
+                if (currentArg != null) {
+                    currentArg.append(' ').append(arg);
                 }
                 // this is a loner, just add it directly.
-                else
-                {
-                    cleaned.add( arg );
+                else {
+                    cleaned.add(arg);
                 }
             }
         }
 
         // clean up.
-        if ( currentArg != null )
-        {
-            cleaned.add( currentArg.toString() );
+        if (currentArg != null) {
+            cleaned.add(currentArg.toString());
         }
 
         int cleanedSz = cleaned.size();
         String[] cleanArgs = null;
 
-        if ( cleanedSz == 0 )
-        {
+        if (cleanedSz == 0) {
             // if we didn't have any arguments to clean, simply pass the original array through
             cleanArgs = args;
-        }
-        else
-        {
-            cleanArgs = (String[]) cleaned.toArray( new String[cleanedSz] );
+        } else {
+            cleanArgs = (String[]) cleaned.toArray(new String[cleanedSz]);
         }
 
         return cleanArgs;
     }
 
-    public void displayHelp()
-    {
+    public void displayHelp() {
         System.out.println();
 
         HelpFormatter formatter = new HelpFormatter();
 
-        formatter.printHelp( "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", options, "\n" );
+        formatter.printHelp("mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", options, "\n");
     }
 }


=====================================
src/main/java/org/codehaus/plexus/tools/cli/Cli.java
=====================================
@@ -1,19 +1,32 @@
 package org.codehaus.plexus.tools.cli;
 
-import org.codehaus.plexus.PlexusContainer;
-import org.apache.commons.cli.Options;
+/*
+ * Copyright 2006 The Codehaus 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.
+ */
+
 import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.codehaus.plexus.PlexusContainer;
 
 /**
  * @author Jason van Zyl
  */
-public interface Cli
-{
-    Options buildCliOptions( Options options );
+public interface Cli {
+    Options buildCliOptions(Options options);
 
-    void invokePlexusComponent( CommandLine cli,
-                                PlexusContainer container )
-        throws Exception;
+    void invokePlexusComponent(CommandLine cli, PlexusContainer container) throws Exception;
 
     // this can be calculated
     String getPomPropertiesPath();


=====================================
src/site/site.xml
=====================================
@@ -0,0 +1,15 @@
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+  <body>
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+      <item name="JavaDocs" href="apidocs/index.html"/>
+      <item name="Source Xref" href="xref/index.html"/>
+      <!--item name="FAQ" href="faq.html"/-->
+    </menu>
+
+    <menu ref="parent"/>
+    <menu ref="reports"/>
+  </body>
+</project>


=====================================
src/test/java/org/codehaus/plexus/tools/cli/CliTest.java
=====================================
@@ -1,39 +1,53 @@
 package org.codehaus.plexus.tools.cli;
 
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
+/*
+ * Copyright 2006 The Codehaus 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.
+ */
 
+import java.io.File;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.Test;
+
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /**
  * @author Jason van Zyl
  */
-public class CliTest
-    extends PlexusTestCase
-{
-    public void testCli()
-        throws Exception
-    {
-        String[] args = new String[]{"-n", getBasedir()};
+class CliTest {
+    @Test
+    void cli() throws Exception {
+        String[] args = new String[] {"-n", getBasedir()};
 
         Class clazz = TestCli.class;
 
-        Method m = clazz.getMethod( "main", new Class[]{String[].class} );
+        Method m = clazz.getMethod("main", new Class[] {String[].class});
 
         int modifiers = m.getModifiers();
 
-        if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) )
-        {
-            if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE )
-            {
-                m.invoke( clazz, new Object[]{args} );
+        if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
+            if (m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE) {
+                m.invoke(clazz, new Object[] {args});
             }
         }
 
-        String s = FileUtils.fileRead( new File( getBasedir(), "target/cli.txt" ) );
+        String s = FileUtils.fileRead(new File(getBasedir(), "target/cli.txt"));
 
-        assertEquals( "NAME_OPTION_INVOKED", s );
+        assertEquals("NAME_OPTION_INVOKED", s);
     }
 }


=====================================
src/test/java/org/codehaus/plexus/tools/cli/TestCli.java
=====================================
@@ -1,44 +1,53 @@
 package org.codehaus.plexus.tools.cli;
 
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.util.FileUtils;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
+/*
+ * Copyright 2006 The Codehaus 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.
+ */
 
 import java.io.File;
 
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.util.FileUtils;
+
 /**
  * @author Jason van Zyl
  */
-public class TestCli
-    extends AbstractCli
-{
-    public static void main( String[] args )
-        throws Exception
-    {
-        new TestCli().execute( args );
+public class TestCli extends AbstractCli {
+    public static void main(String[] args) throws Exception {
+        new TestCli().execute(args);
     }
 
-    public Options buildCliOptions( Options options )
-    {
-        options.addOption(
-            OptionBuilder.withLongOpt( "name" ).withDescription( "Display name." ).hasArg().create( 'n' ) );
+    public Options buildCliOptions(Options options) {
+        options.addOption(OptionBuilder.withLongOpt("name")
+                .withDescription("Display name.")
+                .hasArg()
+                .create('n'));
 
         return options;
     }
 
-    public void invokePlexusComponent( CommandLine cli,
-                                       PlexusContainer container )
-        throws Exception
-    {
-        if ( cli.hasOption( 'n' ) )
-        {
-            String directory = cli.getOptionValue( 'n' );
+    public void invokePlexusComponent(CommandLine cli, PlexusContainer container) throws Exception {
+        if (cli.hasOption('n')) {
+            String directory = cli.getOptionValue('n');
 
-            FileUtils.mkdir( new File( directory, "target" ).getAbsolutePath() );
+            FileUtils.mkdir(new File(directory, "target").getAbsolutePath());
 
-            FileUtils.fileWrite( new File( directory, "target/cli.txt").getAbsolutePath() , "NAME_OPTION_INVOKED" );
+            FileUtils.fileWrite(new File(directory, "target/cli.txt").getAbsolutePath(), "NAME_OPTION_INVOKED");
         }
     }
 }



View it on GitLab: https://salsa.debian.org/java-team/plexus-cli/-/compare/2d2e13ff552d4a5e3a12991aab41e45310633559...8a7c2383acfe597bd81e26000d32b27749babf29

-- 
View it on GitLab: https://salsa.debian.org/java-team/plexus-cli/-/compare/2d2e13ff552d4a5e3a12991aab41e45310633559...8a7c2383acfe597bd81e26000d32b27749babf29
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20250223/71bbe542/attachment.htm>


More information about the pkg-java-commits mailing list