You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/09/11 13:20:28 UTC

(camel) branch main updated: chore: fix misleading javadoc and document camel.extra.repos (#26328)

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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 55e7363ca55d chore: fix misleading javadoc and document camel.extra.repos (#26328)
55e7363ca55d is described below

commit 55e7363ca55d5bc236687daf67add8243ca6744e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Sep 11 15:20:09 2026 +0200

    chore: fix misleading javadoc and document camel.extra.repos (#26328)
    
    The javadoc on MavenDownloaderImpl.loadExtraDefaultRepositories described a
    classpath properties file mechanism that was never implemented, announced "two
    complementary mechanisms" while listing only one, claimed both were "additive
    and merged" when the second property is in fact only a fallback, and used a
    malformed {@value} tag referencing two fields at once.
    
    Also document camel.extra.repos in the Camel CLI running guide: the id=url value
    format, why that form matters for settings.xml server authentication, and the
    camel.default.extra.repos.default.value fallback intended for custom
    distributions.
    
    No functional change.
    
    Co-authored-by: Claude Opus 5 (1M context) <no...@anthropic.com>
    Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
 .../modules/ROOT/pages/camel-jbang-running.adoc    | 12 +++++++++-
 .../camel/tooling/maven/MavenDownloaderImpl.java   | 28 ++++++++++++++--------
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
index de2016494d1e..cefdef8abcff 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
@@ -201,13 +201,23 @@ You can also configure repositories in `application.properties`:
 camel.jbang.repos=https://packages.atlassian.com/maven-external
 ----
 
-Or set a global default via environment variable:
+Or set a global default with the `camel.extra.repos` JVM system property, which applies to every
+Camel CLI command without having to repeat `--repos`:
 
 [source,bash]
 ----
 export JAVA_TOOL_OPTIONS="-Dcamel.extra.repos=repo1=https://repo1.example.com/maven2,repo2=https://repo2.example.com/releases"
 ----
 
+The value is a comma-separated list of repositories, where each entry is either a plain URL or an
+`id=url` pair. Prefer the `id=url` form when the repository requires authentication, as the id is
+what Camel matches against the `<server>` entries in `~/.m2/settings.xml`.
+
+NOTE: A custom Camel distribution can provide a baseline for this via the
+`camel.default.extra.repos.default.value` system property. It is only consulted when
+`camel.extra.repos` is not set, so setting `camel.extra.repos` replaces that baseline rather than
+adding to it. Apache Camel itself sets neither property.
+
 == Downloading JARs over the internet
 
 Camel CLI automatically resolves and downloads dependencies in this order:
diff --git a/tooling/camel-tooling-maven/src/main/java/org/apache/camel/tooling/maven/MavenDownloaderImpl.java b/tooling/camel-tooling-maven/src/main/java/org/apache/camel/tooling/maven/MavenDownloaderImpl.java
index 76831878cb76..5f731482c9a1 100644
--- a/tooling/camel-tooling-maven/src/main/java/org/apache/camel/tooling/maven/MavenDownloaderImpl.java
+++ b/tooling/camel-tooling-maven/src/main/java/org/apache/camel/tooling/maven/MavenDownloaderImpl.java
@@ -85,8 +85,10 @@ public class MavenDownloaderImpl extends ServiceSupport implements MavenDownload
     public static final String MAVEN_CENTRAL_REPO = "https://repo1.maven.org/maven2";
     public static final String APACHE_SNAPSHOT_REPO = "https://repository.apache.org/snapshots";
 
-    private static final String EXTRA_DEFAULT_REPOS_DEFAULT_VALUE = "camel.default.extra.repos.default.value";
+    // extra default Maven repositories, as a comma-separated list of id=url pairs
     private static final String EXTRA_DEFAULT_REPOS_PROPERTY = "camel.extra.repos";
+    // fallback for the above, consulted only when camel.extra.repos is not set
+    private static final String EXTRA_DEFAULT_REPOS_DEFAULT_VALUE = "camel.default.extra.repos.default.value";
 
     private static final RepositoryPolicy POLICY_DEFAULT = new RepositoryPolicy(
             true, RepositoryPolicy.UPDATE_POLICY_NEVER, RepositoryPolicy.CHECKSUM_POLICY_WARN);
@@ -503,18 +505,24 @@ public class MavenDownloaderImpl extends ServiceSupport implements MavenDownload
     }
 
     /**
-     * Loads extra default Maven repositories from classpath properties files and system property.
+     * Loads extra default Maven repositories from a system property, so they are used in addition to Maven Central and
+     * the repositories from {@code settings.xml} without having to pass {@code --repos} on every command.
+     * <p>
+     * The value is a comma-separated list of repositories, where each entry is either a plain URL or an {@code id=url}
+     * pair, for example {@code repo1=https://repo1.example.com/maven2,repo2=https://repo2.example.com/releases}. See
+     * {@link #configureRepositories(List, Set)} for why the {@code id=url} form is preferable.
      * <p>
-     * Two complementary mechanisms:
-     * <ul>
-     * <li>System property: {@value #EXTRA_DEFAULT_REPOS_PROPERTY or EXTRA_DEFAULT_REPOS_DEFAULT_VALUE} (comma-separated
-     * id=url pairs)</li>
-     * </ul>
-     * Both are additive and merged. Upstream ships no properties file (no-op). Product builds can add the file or use
-     * the system property.
+     * Two system properties are consulted, in order:
+     * <ol>
+     * <li>{@value #EXTRA_DEFAULT_REPOS_PROPERTY} &ndash; intended for end users</li>
+     * <li>{@value #EXTRA_DEFAULT_REPOS_DEFAULT_VALUE} &ndash; a fallback used only when the former is not set, so that
+     * a custom Camel distribution can bake in a baseline that end users are still able to override</li>
+     * </ol>
+     * They are not merged: the first one that is set wins. Apache Camel does not set either of them, so this is a no-op
+     * unless configured.
      */
     private void loadExtraDefaultRepositories(List<RemoteRepository> repositories) {
-        // Load from system property (comma-separated id=url pairs)
+        // user-provided value first, then any baseline a custom distribution provided
         String sysProp
                 = System.getProperty(EXTRA_DEFAULT_REPOS_PROPERTY, System.getProperty(EXTRA_DEFAULT_REPOS_DEFAULT_VALUE));
         if (sysProp != null && !sysProp.isBlank()) {