Closed simse07 closed 2 years ago
Hi @simse07, thanks for coming up with this, sounds like a good idea.
I don't know if it's a good idea to include several different classes
folders, but I will think about.
It may work in your usecase, but others might some classpath errors in some cases!?
What I could think of something like withExtensionLibsFrom(...)
, this would empower to include 3rd party libs together with an extension.
WDYT?
Thanks for the fast reply.
withExtensionLibsFrom(...)
sounds like a good extension to me.
I was thinking about this and probably I have expressed myself in a misleading way.
The extension lib should be added as module to the Keycloak. So I would rather name it like addCustomModule(...)
where you have to specify the name & package of the lib, path to the jar and to the module.xml:
addCustomModule("core", "my.package.core", "../core/target/core.jar", "../core/module.xml")
This will be deployed to /opt/jboss/keycloak/modules/my/package/core/main/core.jar
and /opt/jboss/modules/my/package/core/main/module.xml
.
What do you think?
Ah, seems that you reference to the v1.x version of this project and thus to Wildfly-based Keycloak. As the Wildfly distribution is now deprecated and the Quarkus-based distribution is the default, I also deprecated the v1.x version of this project. V2.x uses the Quarkus-based Keycloak. And there, you don't have modules. Unfortunately (? no, not really), I won't add new features to the v1.x branch, only 2.x is now supported.
However, I will add some feature like I mentioned for libs to one of the next releases.
I was hoping that you would not say that, but totally understandable.
For others who would like to add a module to v1.x:
public class ModuleDto {
String moduleName; // core
String modulePackage; // my.package.core, same as the name in the module.xml
String moduleJarPath; // ../core/target/core.jar
String modulePath; // ../core/module.xml
}
/* ----------------------------- */
public class KeycloakContainerModule extends KeycloakContainer {
private ModuleDto moduleDto;
public KeycloakContainerModule withModuleDeployment(ModuleDto moduleDto) {
this.moduleDto = moduleDto;
return (KeycloakContainerModule) self();
}
@Override
protected void configure() {
super.configure();
if (moduleDto != null) {
createKeycloakModuleDeployment(moduleDto);
}
}
public void createKeycloakModuleDeployment(ModuleDto moduleDto) {
String deploymentLocation = "/opt/jboss/keycloak/modules/" + moduleDto.modulePackage.replace(".", "/") + "/main/";
withCopyFileToContainer(MountableFile.forHostPath(Paths.get(moduleDto.moduleJarPath)), deploymentLocation + moduleDto.moduleName + ".jar");
withCopyFileToContainer(MountableFile.forHostPath(Paths.get(moduleDto.modulePath)), deploymentLocation + "module.xml");
}
}
Nice, thanks. 🙂
If you don't mind, I will convert this issue to a discussion thread, so it is saved for others.
I'll create another issue to add the withExtensionLibsFrom()
as discussed above.
Hi, thank you for the great project.
How can I include my local dependency together with the extension I want to test?
Example:
I want to test my
extension
, which has a dependency to mycore
package e.g. some exception or util classes. When I start the testcontainer test in theextension/src/test
while passingwithExtensionClassesFrom("target/classes")
I get an errororg.jboss.modules.ModuleNotFoundException: core.exception
.Maybe we can define multiple paths for
withExtensionClassesFrom
?