adutra commented on code in PR #3340:
URL: https://github.com/apache/polaris/pull/3340#discussion_r2674088028


##########
runtime/server/build.gradle.kts:
##########
@@ -40,6 +40,17 @@ val distributionElements by
 dependencies {
   implementation(project(":polaris-runtime-service"))
 
+  // Additional dependencies for CLI mode
+  implementation("io.quarkus:quarkus-picocli")
+  implementation(project(":polaris-version"))
+
+  // These are already provided transitively by polaris-runtime-service
+  // but we need them at compile time for CLI code
+  compileOnly(project(":polaris-core"))

Review Comment:
   Agree with @dimas-b these should be `implementation` for most of them. I 
would reorder them as below:
   
   ```kotlin
       implementation(project(":polaris-core"))
       implementation(project(":polaris-version"))
       implementation(project(":polaris-api-management-service"))
       implementation(project(":polaris-api-iceberg-service"))
       implementation(project(":polaris-runtime-service"))
   
       compileOnly("com.fasterxml.jackson.core:jackson-annotations")
   
       implementation("io.quarkus:quarkus-picocli")
   ```



##########
runtime/distribution/bin/admin:
##########
@@ -21,12 +21,16 @@ set -euo pipefail
 
 # Get the directory
 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-cd "$SCRIPT_DIR/../admin"
+cd "$SCRIPT_DIR/../server"
 
 # Get the Java command
 JAVA_CMD="${JAVA_HOME:+${JAVA_HOME%/}/bin/java}"
 JAVA_CMD="${JAVA_CMD:-$(command -v java)}"
 [ -x "$JAVA_CMD" ] || { echo "Java not found – set JAVA_HOME or add java to 
PATH." >&2; exit 1; }
 
-# Launch Quarkus
-exec "$JAVA_CMD" ${POLARIS_JAVA_OPTS:-} -jar quarkus-run.jar "$@"
+# Show the usage when no argument is provided
+if [ "$#" -eq 0 ]; then

Review Comment:
   Nice 👍 



##########
runtime/server/src/main/java/org/apache/polaris/PolarisApplication.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+package org.apache.polaris;
+
+import io.quarkus.picocli.runtime.PicocliRunner;
+import io.quarkus.runtime.Quarkus;
+import io.quarkus.runtime.QuarkusApplication;
+import io.quarkus.runtime.annotations.QuarkusMain;
+
+/**
+ * Main entry point for Polaris application. Supports both HTTP server mode 
and CLI admin mode: - No
+ * arguments: Start HTTP server - With arguments: Run CLI commands (bootstrap, 
purge, etc.)
+ */
+@QuarkusMain
+public class PolarisApplication implements QuarkusApplication {
+  /**
+   * Main method that detects CLI mode and activates the appropriate Quarkus 
profile.
+   *
+   * <p>Profile Activation: When CLI arguments are present, the "cli" profile 
is activated using
+   * System.setProperty before Quarkus initialization. This must be done via 
system property (not
+   * ConfigUtils.getProfiles().add()) because Quarkus reads the active profile 
during early
+   * bootstrap, before ConfigUtils can affect the configuration.
+   *
+   * <p>Configuration Priority Order: Quarkus loads configuration from 
multiple sources (highest to
+   * lowest priority):
+   *
+   * <ol>
+   *   <li>(400) System properties: -D flags at JVM startup
+   *   <li>(300) Environment variables
+   *   <li>(260) External config/application-cli.properties: Profile-specific 
external config

Review Comment:
   As I mentioned on the ML, I'm unsure whether we should mention the 
possibility of adding this profile-aware external config file, as it has very 
little added value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to