Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,14 @@ with the key `camel.jbang.repos` as shown:
camel.jbang.repos=https://packages.atlassian.com/maven-external
----

Alternatively, you can configure default Maven repositories globally via a system property.
This is useful for custom Camel distributions that require additional repositories without manual configuration on each command:

[source,bash]
----
export JAVA_TOOL_OPTIONS="-Dcamel.extra.repos=repo1=https://repo1.example.com/maven2,repo2=https://repo2.example.com/releases"
----

When running Camel you need to include the properties file to use:

[source,bash]
Expand Down Expand Up @@ -4065,6 +4073,9 @@ camel export --runtime=quarkus --gav=com.foo:acme:1.0-SNAPSHOT --directory=../my

TIP: See the possible options by running: `camel export --help` for more details.

NOTE: The Quarkus platform version is automatically resolved from the Quarkus platform registry based on the Camel version's compatible Quarkus stream.
If the registry is unavailable or downloads are disabled, the build-time default version is used.

NOTE: You cannot use `--profile` option when exporting to Camel Quarkus.

=== Exporting to Camel Main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ public Integer export() throws Exception {
appJar = "target" + File.separator + ids[1] + "-" + ids[2] + ".jar";
}
copyReadme(BUILD_DIR, appJar);
// resolve Quarkus platform version from registry (if available)
String resolved = QuarkusHelper.resolveQuarkusPlatformVersion(quarkusVersion);
if (resolved != null) {
quarkusVersion = resolved;
// resolve Quarkus platform version from registry (when download is true)
if (download) {
String resolved = QuarkusHelper.resolveQuarkusPlatformVersion(quarkusVersion);
if (resolved != null) {
quarkusVersion = resolved;
}
}
// gather dependencies
Set<String> deps = resolveDependencies(settings, profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Base64;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.camel.util.FileUtil;
Expand Down Expand Up @@ -623,4 +624,76 @@ void testAuthenticationAndMirrors() throws Exception {
LOG.info("Authentication and mirror test passed - artifact resolved through authenticated mirror");
}
}

@Test
void testExtraDefaultRepositoriesFromSystemProperty() throws Exception {
// This test verifies that MIMA correctly loads extra default repositories from system properties.

// Use the local test server that requires authentication
String testRepoUrl = "http://localhost:" + localServer.getLocalPort() + "/maven/repository";
String extraReposValue = "test-server=" + testRepoUrl;

File customLocalRepo = new File(tempDir, "extra-repos-test-m2");
Files.createDirectories(customLocalRepo.toPath());

String artifactCoords = "org.apache.camel:camel-test:9.99.9-non-exist";

// Callable that captures local variables and performs artifact resolution
Callable<List<MavenArtifact>> resolve = () -> {
try (MavenDownloaderImpl downloader = new MavenDownloaderImpl()) {
downloader.setMavenCentralEnabled(false);
downloader.setMavenApacheSnapshotEnabled(false);
downloader.build();

MavenDownloader customDownloader = downloader.customize(
customLocalRepo.getAbsolutePath(),
5000,
10000);

return customDownloader.resolveArtifacts(
List.of(artifactCoords),
null,
false,
false);
}
};

String originalValue = System.getProperty("camel.extra.repos");
try {
// NEGATIVE TEST: without the extra repo, the resolution fails because of no artifact can be resolved, definitely not authentication failure
System.clearProperty("camel.extra.repos");

try {
resolve.call();
fail("Should have failed without extra repos system property");
} catch (MavenResolutionException e) {
// Expected - no repositories configured
assertFalse(e.getMessage().contains("401") || e.getMessage().contains("Unauthorized")
|| e.getMessage().contains("status code"),
"Should fail due to no repositories, not authentication, got: " + e.getMessage());
}

// POSITIVE TEST: with the extra repo configured, we have to receive authentication failure
System.setProperty("camel.extra.repos", extraReposValue);

try {
resolve.call();
fail("Should have failed with 401 Unauthorized (proves repo was loaded from system property)");
} catch (MavenResolutionException e) {
// Expected - repository loaded but download fails due to no authentication
// The 401 error proves the repository from the system property was actually used
assertTrue(e.getMessage().contains("401") || e.getMessage().contains("Unauthorized")
|| e.getMessage().contains("status code"),
"Should fail with 401/authentication error (proves repository was used), got: " + e.getMessage());
}

} finally {
// Clean up system property
if (originalValue != null) {
System.setProperty("camel.extra.repos", originalValue);
} else {
System.clearProperty("camel.extra.repos");
}
}
}
}
Loading