4

I'm in a project that willing to extends keycloak functionalities with new ones. We use SPI in order to do this, and we have more than one jar file for hot deploying into Wildfly's keycloak server. We have major issues with dependency between jars. We need to package all functionalities as EAR but I don't find the right configuration to do this. My example was a post-Keycloak - Custom SPI does not appear in list that explains how to packaging jar into EAR in order to deploy on Jboss, and is not clear where should we put the jar dependencies.

Details about mavem project's structure:

KeycloakProject (packaging pom)
|
+ - keycloak-entities-providers (packaging pom)
| |
| +- keycloak-first-entity-provider (packaging jar)
| |          |
| |          +- META-INF
| |             |
| |             +- services
| |                |
| |                +- org.keycloak.authentication.AuthenticatorFactory
| |                +- org.keycloak.connections.jpa.entityprovider.JpaEntityProviderFactory
| |                |  ...
| |                +- jboss-deployment-structure.xml
| +- keycloak-second-entity-provider (packagind jar)
|            |
|            +- META-INF
|               |
|               +- services
|               |  |
|               |  +- org.keycloak.services.resource.RealmResourceProviderFactory
|               |   ...
|               +- jboss-deployment-structure.xml
+- keycloak-identity-providers (packaging pom)
  |
  +- keycloak-first-identity-provider (packaging jar)
  |          |
  |          +- META-INF
  |             |
  |             +- services
  |                |
  |                +- org.keycloak.authentication.AuthenticatorFactory
  |                +- org.keycloak.connections.jpa.entityprovider.JpaEntityProviderFactory
  |                |  ...
  |                +- jboss-deployment-structure.xml
  +- keycloak-second-identity-provider (packagind jar)
             |
             +- META-INF
                |
                +- services
                |  |
                |  +- org.keycloak.services.resource.RealmResourceProviderFactory
                |   ...
                +- jboss-deployment-structure.xml

I need to know if there is a single jboss-deployment-structure.xml on EAR package, and in this case what must contain. Every jar file has its own dependencies and there is a need to depend on one of another (like keycloak-second-entity-provider depends on the keycloak-first-entity-provider).

Thank you !

1 Answers1

3

Yes, you should create only one jboss-deployment-structure.xml descriptor for whole EAR package. It should be defined in EAR artifact sources. services, persistence.xml and other stuff should stay with their corresponding jars. Because you have separate artifact for every SPI you probably will have to declare each jar as separate <sub-deployment name=".."> in jboss-deployment-structure.xml. Then you will also have to make every sub-deployment available for other (Wildfly and Jboss docs are your friends now, you could also check deployment scanner implementation in Keycloak Wildfly subsystem sources).

Honestly i don't see real profit from dividing each SPI implementation in separate artifacts, so far you don't create your own custom SPI. I also went through this ending with only one artifact.

solveMe
  • 1,866
  • 1
  • 18
  • 20