This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 529449d459b HDDS-15185. Create submodule ozone-cli-interactive (#10348)
529449d459b is described below

commit 529449d459b0e3e57da110f0e52337dd3a1bbcff
Author: Will Xiao <[email protected]>
AuthorDate: Mon May 25 21:29:59 2026 +0800

    HDDS-15185. Create submodule ozone-cli-interactive (#10348)
---
 hadoop-ozone/cli-interactive/pom.xml               | 59 ++++++++++++++++++++++
 .../hadoop/ozone/shell/OzoneInteractiveShell.java  | 35 ++++---------
 .../apache/hadoop/ozone/shell/package-info.java    | 21 ++++++++
 hadoop-ozone/dist/pom.xml                          |  5 ++
 hadoop-ozone/dist/src/main/license/jar-report.txt  |  1 +
 hadoop-ozone/dist/src/shell/ozone/ozone            |  8 +--
 hadoop-ozone/pom.xml                               |  1 +
 pom.xml                                            |  5 ++
 8 files changed, 103 insertions(+), 32 deletions(-)

diff --git a/hadoop-ozone/cli-interactive/pom.xml 
b/hadoop-ozone/cli-interactive/pom.xml
new file mode 100644
index 00000000000..c45392bf927
--- /dev/null
+++ b/hadoop-ozone/cli-interactive/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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. See accompanying LICENSE file.
+-->
+<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 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.ozone</groupId>
+    <artifactId>ozone</artifactId>
+    <version>2.2.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>ozone-cli-interactive</artifactId>
+  <version>2.2.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Apache Ozone CLI Interactive</name>
+  <description>Apache Ozone top-level interactive CLI</description>
+
+  <properties>
+    <classpath.skip>false</classpath.skip>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>info.picocli</groupId>
+      <artifactId>picocli</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>info.picocli</groupId>
+      <artifactId>picocli-shell-jline3</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ozone</groupId>
+      <artifactId>ozone-cli-admin</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ozone</groupId>
+      <artifactId>ozone-cli-debug</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ozone</groupId>
+      <artifactId>ozone-cli-shell</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-reload4j</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git 
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
 
b/hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
similarity index 58%
rename from 
hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
rename to 
hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
index 1f73df85a28..0bfd06835a9 100644
--- 
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
+++ 
b/hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/OzoneInteractiveShell.java
@@ -17,9 +17,10 @@
 
 package org.apache.hadoop.ozone.shell;
 
-import org.apache.hadoop.hdds.cli.GenericCli;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.hadoop.ozone.admin.OzoneAdmin;
+import org.apache.hadoop.ozone.debug.OzoneDebug;
+import org.apache.hadoop.ozone.shell.s3.S3Shell;
+import org.apache.hadoop.ozone.shell.tenant.TenantShell;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 import picocli.shell.jline3.PicocliCommands.PicocliCommandsFactory;
@@ -29,8 +30,6 @@
  */
 public final class OzoneInteractiveShell {
 
-  private static final Logger LOG = 
LoggerFactory.getLogger(OzoneInteractiveShell.class);
-
   private OzoneInteractiveShell() {
   }
 
@@ -38,15 +37,11 @@ public static void main(String[] argv) throws Exception {
     PicocliCommandsFactory factory = new PicocliCommandsFactory();
     CommandLine topCmd = new CommandLine(new TopCommand(), factory);
 
-    // Add known subcommands statically if they are in the same module.
     topCmd.addSubcommand("sh", new OzoneShell().getCmd());
-    topCmd.addSubcommand("tenant", new 
org.apache.hadoop.ozone.shell.tenant.TenantShell().getCmd());
-    topCmd.addSubcommand("s3", new 
org.apache.hadoop.ozone.shell.s3.S3Shell().getCmd());
-
-    // Dynamically add subcommands from other modules to avoid circular 
dependencies.
-    addDynamicSubcommand(topCmd, "admin", 
"org.apache.hadoop.ozone.admin.OzoneAdmin");
-    addDynamicSubcommand(topCmd, "debug", 
"org.apache.hadoop.ozone.debug.OzoneDebug");
-    addDynamicSubcommand(topCmd, "repair", 
"org.apache.hadoop.ozone.repair.OzoneRepair");
+    topCmd.addSubcommand("tenant", new TenantShell().getCmd());
+    topCmd.addSubcommand("s3", new S3Shell().getCmd());
+    topCmd.addSubcommand("admin", new OzoneAdmin().getCmd());
+    topCmd.addSubcommand("debug", new OzoneDebug().getCmd());
 
     Shell dummyShell = new Shell() {
       @Override
@@ -63,18 +58,8 @@ public String prompt() {
     new REPL(dummyShell, topCmd, factory, null);
   }
 
-  private static void addDynamicSubcommand(CommandLine topCmd, String name, 
String className) {
-    try {
-      Class<?> clazz = Class.forName(className);
-      GenericCli instance = (GenericCli) 
clazz.getDeclaredConstructor().newInstance();
-      topCmd.addSubcommand(name, instance.getCmd());
-    } catch (Exception e) {
-      LOG.debug("Subcommand {} not loaded: class {} not found or could not be 
instantiated", 
-          name, className, e);
-    }
-  }
-
-  @Command(name = "ozone", description = "Interactive Shell for all Ozone 
commands", mixinStandardHelpOptions = true)
+  @Command(name = "ozone", description = "Interactive Shell for all Ozone 
commands",
+      mixinStandardHelpOptions = true)
   private static class TopCommand implements Runnable {
     @Override
     public void run() {
diff --git 
a/hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/package-info.java
 
b/hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/package-info.java
new file mode 100644
index 00000000000..87bb3520877
--- /dev/null
+++ 
b/hadoop-ozone/cli-interactive/src/main/java/org/apache/hadoop/ozone/shell/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Top-level interactive CLI for Ozone.
+ */
+package org.apache.hadoop.ozone.shell;
diff --git a/hadoop-ozone/dist/pom.xml b/hadoop-ozone/dist/pom.xml
index 1545a5c1645..13dfc6a9e4c 100644
--- a/hadoop-ozone/dist/pom.xml
+++ b/hadoop-ozone/dist/pom.xml
@@ -80,6 +80,11 @@
       <artifactId>ozone-cli-debug</artifactId>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.ozone</groupId>
+      <artifactId>ozone-cli-interactive</artifactId>
+      <scope>runtime</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.ozone</groupId>
       <artifactId>ozone-cli-repair</artifactId>
diff --git a/hadoop-ozone/dist/src/main/license/jar-report.txt 
b/hadoop-ozone/dist/src/main/license/jar-report.txt
index 2daa3316986..84fbf92f989 100644
--- a/hadoop-ozone/dist/src/main/license/jar-report.txt
+++ b/hadoop-ozone/dist/src/main/license/jar-report.txt
@@ -218,6 +218,7 @@ share/ozone/lib/osgi-resource-locator.jar
 share/ozone/lib/ozone-client.jar
 share/ozone/lib/ozone-cli-admin.jar
 share/ozone/lib/ozone-cli-debug.jar
+share/ozone/lib/ozone-cli-interactive.jar
 share/ozone/lib/ozone-cli-repair.jar
 share/ozone/lib/ozone-cli-shell.jar
 share/ozone/lib/ozone-common.jar
diff --git a/hadoop-ozone/dist/src/shell/ozone/ozone 
b/hadoop-ozone/dist/src/shell/ozone/ozone
index e33e4648c9c..d969c8e3d02 100755
--- a/hadoop-ozone/dist/src/shell/ozone/ozone
+++ b/hadoop-ozone/dist/src/shell/ozone/ozone
@@ -224,14 +224,8 @@ function ozonecmd_case
     ;;
     interactive)
       OZONE_CLASSNAME=org.apache.hadoop.ozone.shell.OzoneInteractiveShell
-      OZONE_RUN_ARTIFACT_NAME="ozone-cli-shell"
+      OZONE_RUN_ARTIFACT_NAME="ozone-cli-interactive"
       OZONE_OPTS="${OZONE_OPTS} ${RATIS_OPTS} ${OZONE_MODULE_ACCESS_ARGS}"
-      # Add all CLI classpaths to support all subcommands dynamically
-      for cp_file in "ozone-cli-admin" "ozone-cli-debug" "ozone-cli-repair" 
"ozone-tools"; do
-        if [[ -f "${OZONE_HOME}/share/ozone/classpath/${cp_file}.classpath" 
]]; then
-          ozone_add_classpath_from_file 
"${OZONE_HOME}/share/ozone/classpath/${cp_file}.classpath"
-        fi
-      done
     ;;
     admin)
       OZONE_CLASSNAME=org.apache.hadoop.ozone.admin.OzoneAdmin
diff --git a/hadoop-ozone/pom.xml b/hadoop-ozone/pom.xml
index 5118acb5f9e..0e4b7e27a0f 100644
--- a/hadoop-ozone/pom.xml
+++ b/hadoop-ozone/pom.xml
@@ -27,6 +27,7 @@
   <modules>
     <module>cli-admin</module>
     <module>cli-debug</module>
+    <module>cli-interactive</module>
     <module>cli-repair</module>
     <module>cli-shell</module>
     <module>client</module>
diff --git a/pom.xml b/pom.xml
index 47ea7c85706..4f561e9d358 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1234,6 +1234,11 @@
         <artifactId>ozone-cli-debug</artifactId>
         <version>${ozone.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.ozone</groupId>
+        <artifactId>ozone-cli-interactive</artifactId>
+        <version>${ozone.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.ozone</groupId>
         <artifactId>ozone-cli-repair</artifactId>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to