christophd commented on code in PR #29578:
URL: https://github.com/apache/camel/pull/29578#discussion_r4537898077
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/PluginHelper.java:
##########
@@ -86,6 +90,51 @@ private PluginHelper() {
// prevent instantiation of utility class
}
+ public static Path getCustomPluginConfigPath() {
+ return getCustomPluginConfigPath(null);
+ }
+
+ /**
+ * Resolves the path to the plugin configuration file. Checks, in order:
+ * <ol>
+ * <li>A path set programmatically via method argument</li>
+ * <li>The {@value #PLUGIN_CONFIG_ENV} environment variable</li>
+ * <li>The default {@value #PLUGIN_CONFIG} in the user home directory</li>
+ * </ol>
+ */
+ public static Path getCustomPluginConfigPath(Path configPath) {
+ return resolvePluginConfigPath(configPath,
System.getenv(PLUGIN_CONFIG_ENV));
+ }
+
+ static Path resolvePluginConfigPath(Path configPath, String envValue) {
+ Path pluginConfigPath;
+ if (configPath != null) {
+ pluginConfigPath = configPath;
+ } else {
+ if (envValue != null && !envValue.isBlank()) {
+ try {
+ pluginConfigPath = Path.of(envValue);
+ } catch (InvalidPathException e) {
+ throw new IllegalStateException(
+ "Invalid path in " + PLUGIN_CONFIG_ENV + "
environment variable: " + envValue, e);
+ }
+ } else {
+ return CommandLineHelper.getHomeDir().resolve(PLUGIN_CONFIG);
+ }
+ }
+
+ if (Files.isDirectory(pluginConfigPath)) {
+ return pluginConfigPath.resolve(PLUGIN_CONFIG);
+ }
+ Path fileName = pluginConfigPath.getFileName();
+ if (Files.isRegularFile(pluginConfigPath)
+ || fileName != null &&
fileName.toString().toLowerCase(Locale.ROOT).endsWith(".json")) {
Review Comment:
_Claude Code on behalf of christophd_
Done in f78fbc4.
--
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]