[keycloak-dev] Hacking Tips

Stan Silvert ssilvert at redhat.com
Tue Oct 6 14:47:09 EDT 2015


In talking with Marko, I shared some of my hacking tips to aid with 
i18n/l10n development.  But they are generally handy for easing all 
Keycloak development.  Others might have other ways to improve on this 
stuff and make our lives easier?

Here are mine:

*Build server-dist without artifacts
*I think Bill gets the credit for making this possible in WildFly.  You 
can build it such that jars are not copied to the server.  Instead, they 
are retrieved from your local maven repo. For Keycloak, you go to 
/distribution/server-dist/server-provisioning.xml and set 
copy-module-artifacts="false".

Now when you compile any of Keycloak's java modules you just restart the 
server and see your changes.

It would be nice if we could use a system property for this, but it 
looks like server-provisioning.xml doesn't support props for that 
attribute.  Some day I'll fix it and submit a patch.

Anyway, doing that and running mvn compile instead of mvn install brings 
the build time from 3 minutes to about 6 seconds.  Only 6 seconds to 
build the whole server!

I use Windows and Cygwin to do this automatically in a batch file:

cd c:\GitHub\keycloak\distribution\server-dist
call mvn clean
sed -i 's/copy-module-artifacts="true"/copy-module-artifacts="false"/' 
server-provisioning.xml
call mvn compile
sed -i 's/copy-module-artifacts="false"/copy-module-artifacts="true"/' 
server-provisioning.xml

*Let the the default theme point to your maven clone instead of 
/standalone/configuration/themes
*You can tell Keycloak to load the default theme from your development 
environment.  This is especially handy when you are working on HTML or 
JS files for Keycloak Admin Console.  To do this, edit 
keycloak-server.json.  Here is the batch file code I use to automate it:

cd 
c:\GitHub\keycloak\distribution\server-dist\target\keycloak*\standalone\configuration
sed -i 's,"dir": "${jboss.server.config.dir}/themes","dir": 
"/GitHub/keycloak/forms/common-themes/src/main/resources/theme",' 
keycloak-server.json

Note: I had to use a comma for my sed delimiter instead of forward slash /

*Turn off caching in your browser.
*You need to turn off caching to see your HTML and JS changes as soon as 
you edit them.  But it can be a pain to turn caching on and off.  I 
found a nifty FireFox extension called "Cache Disabler" that puts a 
little button in my toolbar to enable/disable all caching.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20151006/dfda8b48/attachment.html 


More information about the keycloak-dev mailing list