Skip to content

Commit

Permalink
allow for multiple provider class locations (#129)
Browse files Browse the repository at this point in the history
resolves #128
  • Loading branch information
dasniko committed May 15, 2024
1 parent bc5a407 commit c129545
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -107,7 +108,7 @@ public abstract class ExtendableKeycloakContainer<SELF extends ExtendableKeycloa

private Duration startupTimeout = DEFAULT_STARTUP_TIMEOUT;

private String providerClassLocation;
private List<String> providerClassLocations;
private List<File> providerLibsLocations;
private List<String> customCommandParts;

Expand Down Expand Up @@ -181,8 +182,13 @@ protected void configure() {
}
setWaitStrategy(waitStrategy.withStartupTimeout(startupTimeout));

if (providerClassLocation != null) {
createKeycloakExtensionProvider(providerClassLocation);
if (providerClassLocations != null && !providerClassLocations.isEmpty()) {
AtomicInteger index = new AtomicInteger(0);
providerClassLocations.forEach(providerClassLocation -> createKeycloakExtensionDeployment(
DEFAULT_KEYCLOAK_PROVIDERS_LOCATION,
index.getAndIncrement() + "_" + DEFAULT_KEYCLOAK_PROVIDERS_NAME,
providerClassLocation
));
}

if (providerLibsLocations != null) {
Expand Down Expand Up @@ -334,12 +340,12 @@ public SELF withRamPercentage(int initialRamPercentage, int maxRamPercentage) {
}

/**
* Exposes the given classes location as an exploded providers.jar.
* Exposes the given classes locations as an exploded providers.jar.
*
* @param classesLocation a classes location relative to the current classpath root.
* @param classesLocations classes locations relative to the current classpath root.
*/
public SELF withProviderClassesFrom(String classesLocation) {
this.providerClassLocation = classesLocation;
public SELF withProviderClassesFrom(String... classesLocations) {
this.providerClassLocations = Arrays.asList(classesLocations);
return self();
}

Expand Down

0 comments on commit c129545

Please sign in to comment.