p2-inc / keycloak-orgs

Single realm, multi-tenancy for SaaS apps
https://phasetwo.io
Other
401 stars 68 forks source link

How to build this? Maybe add build instructions to the README? #7

Closed awoimbee closed 2 years ago

awoimbee commented 2 years ago

Sorry to open this issue, but at this point I really need help. I can read Java (found a bug in Keycloak once), but I know absolutely nothing about the ecosystem (and maven isn't very user friendly...).

So, I'm trying to build this project and my issue is the missing keycloak-testsuite-utils. Here are the steps I'm taking (I'm using docker to get standard, reusable build commands):

git clone git@github.com:p2-inc/keycloak-orgs.git
git clone --recursive git@github.com:keycloak/keycloak.git
git -C keycloak checkout 18.0.0

docker run -it --rm -v $(pwd)/keycloak-orgs:/orgs -v $(pwd)/keycloak:/kc maven:3.7-eclipse-temurin-11 bash
# The following commands are ran in the container

cd /kc
# Here I only build what I need, because just `mvn package` fails at "Keycloak Themes": "sh: 1: npm: Permission denied" 
# I have not found a way to do something like `mvn install -pl :keycloak-testsuite-utils`
mvn package -pl :integration-arquillian-testsuite-providers-deployment -pl :integration-arquillian-testsuite-providers -pl :keycloak-testsuite-utils -DskipTests
mvn install:install-file -Dfile=/kc/testsuite/utils/target/keycloak-testsuite-utils-18.0.0-sources.jar -DpomFile=/kc/testsuite/utils/pom.xml
# tried this but seems like it does nothing?
rm ~/.m2/repository/org/keycloak/keycloak-testsuite-utils/18.0.0/_remote.repositories

cd /orgs
mvn package
#  Failed to collect dependencies at org.keycloak:keycloak-testsuite-utils:jar:18.0.0
# Could not find artifact org.keycloak:keycloak-testsuite-pom:pom:18.0.0 in central
# 🤬

# btw 
ls ~/.m2/repository/org/keycloak/keycloak-testsuite-utils/18.0.0/
# keycloak-testsuite-utils-18.0.0.jar
# keycloak-testsuite-utils-18.0.0.jar.lastUpdated
# keycloak-testsuite-utils-18.0.0.pom
# keycloak-testsuite-utils-18.0.0.pom.lastUpdated

Does anyone have suggestions ? Or a different build system, that works ? Maybe the resulting build commands should be added to the readme?

xgp commented 2 years ago

The build uses keycloak-testsuite-utils. You'll need to install Keycloak from source locally, as the test utility that never gets published to maven central. To build Keycloak from source you must check out the tag of the keycloak version you are using and then build (do this in a separate directory):

  KC_VERSION=18.0.0
  git clone https://github.com/keycloak/keycloak
  git fetch origin --tags
  git checkout $KC_VERSION
  mvn clean install -DskipTests

Then, checkout this project and run mvn package

xgp commented 2 years ago

Added to README. Thanks for the suggestion @awoimbee https://github.com/p2-inc/keycloak-orgs/blob/main/README.md#building