A developer wrote us a provider. This provider enables us to log in users using their phone number plus an OTP.
For some reason, he did not support us anymore. Now we want to build it and use it.
The point is that we’re stuck at just building it. We installed JDK 17 on a machine based on what the docs say and used the ./mvnw at the root of the project. But we can’t build our provider.
We tried to get help from the Keycloak team:
opened 06:18AM - 06 Feb 24 UTC
kind/bug
area/dependencies
### Before reporting an issue
- [X] I have read and understood the above terms … for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
### Area
dependencies
### Describe the bug
I can't build from the Keycloak source. I want to build the `authenticator` provider in the examples directory, but I receive these warnings:
> [WARNING]
[WARNING] Some problems were encountered while building the effective model for org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT
[WARNING] 'profiles.profile[jboss-release].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-resources-plugin @ line 355, column 29
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.keycloak.testsuite:integration-arquillian-util:jar:999.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.scope' for org.jboss.arquillian:arquillian-bom:pom must be one of [provided, compile, runtime, test, system] but is 'import'. @ line 81, column 20
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
And these errors:
> [INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:27 min
[INFO] Finished at: 2024-02-06T09:38:10+03:30
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: pre-clean, clean, post-clean, validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
### Version
23.0.6
### Expected behavior
We should be able to build the examples in the source code out of the box
### Actual behavior
A simple build can not be done
### How to Reproduce?
1. Clone source
2. Install JDK 17 => [docs](https://github.com/keycloak/keycloak/blob/main/docs/building.md)
3. Go to the source, run `./mvnw`
### Anything else?
You are a busy team I understand that. But at least give us a hand in using the tool you have written. We do not have a Java developer, yet we are developers and we should be able to at least get a build. I have submitted many issues, questions, and discussions and none gets answered. What should I do?
opened 01:39PM - 27 Nov 23 UTC
closed 02:34PM - 29 Jan 24 UTC
kind/bug
area/docs
### Before reporting an issue
- [X] I have read and understood the above terms … for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
### Area
docs
### Describe the bug
Based on [Getting Started from Docs](https://www.keycloak.org/getting-started/getting-started-zip) I downloaded OpenJDK 17 and ran Keycloak on my local machine with success.
Then as we develop inside docker, I created this `Dockerfile`:
```
FROM amd64/debian:bookworm-slim
RUN apt update -qq > /dev/null \
&& apt upgrade -qq > /dev/null \
&& apt install openjdk-17-jdk -qq -y > /dev/null \
&& apt install openjdk-17-jre -qq -y > /dev/null \
&& java -version \
&& echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' >> /etc/bash.bashrc \
&& echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/bash.bashrc \
&& mkdir -p /Temp > /dev/null \
&& chmod 777 --preserve-root /Temp > /dev/null \
&& echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World from Java!"); } }' > /Temp/Hello.java \
&& java /Temp/Hello.java \
&& apt install wget -y > /dev/null \
&& wget https://github.com/keycloak/keycloak/releases/download/23.0.0/keycloak-23.0.0.zip --quiet -O /Temp/keycloak.zip > /dev/null \
&& apt install unzip -y > /dev/null \
&& cd /Temp \
&& unzip keycloak.zip -d /Keycloak > /dev/null \
&& rm -rf keycloak.zip \
&& cd /Keycloak > /dev/null \
&& mv keycloak-23.0.0/** . > /dev/null \
&& rm -rf keycloak-23.0.0 > /dev/null \
&& ls -lah \
&& wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.zip --quiet -O /Temp/maven.zip > /dev/null \
&& cd /Temp \
&& unzip maven.zip -d /usr/share > /dev/null \
&& rm -rf maven.zip \
&& ln -s /usr/share/apache-maven-3.9.5/bin/mvn /usr/bin/mvn \
&& echo 'M2_HOME=/usr/share/apache-maven-3.9.5' >> /etc/bash.bashrc
WORKDIR /Keycloak
```
Basically I used a Debian as the base image, installed JDK and Maven and downloaded Keycloak inside a docker image.
Then I used this `docker-compose.yml` file to run that image:
```
version: "3.9"
services:
accounts:
image: holism/accounts-dev
container_name: AccountsDev
working_dir: /Keycloak
environment:
- KEYCLOAK_FRONTEND_URL=https://dev.accounts.local/
- PROXY_ADDRESS_FORWARDING=true
- KC_HOSTNAME=dev.accounts.local
- KEYCLOAK_ADMIN=some_user
- KEYCLOAK_ADMIN_PASSWORD=some_password
- KC_PROXY=edge
- KC_HTTP_ENABLED=true
- KC_HOSTNAME_STRICT=false
ports:
- 8080:8080
command: tail -f /dev/null
volumes:
- /Temp/keycloak:/KeycloakSource
```
Then I went into the container, and into the `/KeycloakSource/examples/providers/authenticator` and ran `mvn clean compile`.
I got this error:
```
root@777fb8f204b2:/KeycloakSource/examples/providers/authenticator# mvn clean compile
[INFO] Loading cache configuration from /KeycloakSource/.mvn/maven-build-cache-config.xml
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< org.keycloak:authenticator-required-action-example >---------
[INFO] Building Authenticator Example 999.0.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.keycloak:keycloak-server-spi:jar:999.0.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.keycloak:keycloak-server-spi-private:jar:999.0.0-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.241 s
[INFO] Finished at: 2023-11-27T13:33:39Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project authenticator-required-action-example: Could not resolve dependencies for project org.keycloak:authenticator-required-action-example:jar:999.0.0-SNAPSHOT: The following artifacts could not be resolved: org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-server-spi:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-server-spi-private:jar:999.0.0-SNAPSHOT (absent), org.keycloak:keycloak-services:jar:999.0.0-SNAPSHOT (absent): Could not find artifact org.keycloak:keycloak-core:jar:999.0.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
```
I'm stuck at this point and I can't solve it. I know it might be a stupid mistake. But I"m not a JAVA developer, I'm a node developer trying to create an OTP provider for Keycloak for my company.
What should I do? Am I on the right track?
### Version
23.0.0
### Expected behavior
`mvn clean compile` should work for a source code that is inside a java container.
### Actual behavior
It fails and I can't find good resources online.
### How to Reproduce?
- Build that `Dockerfile` above
- Rename the image in the `docker-compose.yml` accordingly
- Clone the source code to `/Temp` directory
- Run the `docker-compose.yml`
- Enter the container using `docker exec -it container_name bash`
- Go to `/KeycloakSource/examples/providers/authenticator`
- Run `mvn clean compile`
### Anything else?
I know Keycloak is written in Java and developers first need to know how to build Java.
But since it's a very widespread and valuable tech, and many companies use it without knowing Java, I think it's a good idea if you can create a simple doc on how to prepare Java and Maven and other stuff to develop for Keycloak.
Thank you.
But we got no answer.
So, we had an idea. We wanted to build the example provider that is authored by the Keycloak team:
We managed to create a Dockerfile that builds the entire source code:
FROM amd64/debian:bookworm-slim
RUN apt update -qq > /dev/null \
&& apt upgrade -qq > /dev/null \
&& apt install openjdk-17-jdk -qq -y > /dev/null \
&& apt install openjdk-17-jre -qq -y > /dev/null \
&& java -version \
&& echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' >> /etc/bash.bashrc \
&& echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/bash.bashrc \
&& mkdir -p /temp > /dev/null \
&& chmod 777 --preserve-root /temp > /dev/null \
&& echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World from Java!"); } }' > /temp/Hello.java \
&& java /temp/Hello.java \
&& apt install git -y > /dev/null \
&& cd /temp \
&& git clone https://github.com/keycloak/keycloak \
&& cd /temp/keycloak \
&& ./mvnw clean install -DskipTests
WORKDIR /temp/keycloak
But it took a long time, and we can’t find the artifacts to use that authenticator.
So, we’re stuck at this point. We want to build a provider source code and use the resulting artifact (or Java package) to extend our Keycloak instance’s capabilities. How can we do that? Any help is appreciated.
ThoreKr
February 12, 2024, 3:46pm
2
This is probably one of the most convoluted attempts to build something, which makes following your steps and bug reports very tedious.
Skipping all of the needless steps in the dockerfile and compose use, when you build keycloak the final jar is located in examples/providers/authenticator/target/authenticator-required-action-example.jar
Be aware that these probably won’t work with 23.0.x, as the main branch is already on its way to 24.0.0 and has a lot of incompatible changes.
Just compiling the individual module won’t work because it has in-tree dependencies and compile won’t produce a jar, it just compiles the code.
1 Like
dasniko
February 12, 2024, 3:50pm
3
This is a cross-post of this Slack thread:
ThoreKr
February 12, 2024, 4:10pm
4
Thank you for the warning