2019-02-19 18:59:45 +00:00
## Building from source
2023-08-01 15:16:50 +00:00
Ensure you have JDK 17 (or newer) and Git installed
2019-02-19 18:59:45 +00:00
java -version
git --version
2021-09-06 08:11:39 +00:00
2022-12-09 15:44:22 +00:00
Instead of using a locally installed Maven, call the Maven wrapper script `mvnw` in the main folder of the project.
This will use the Maven version which is supported by this project.
2021-09-06 08:11:39 +00:00
---
2019-02-19 18:59:45 +00:00
First clone the Keycloak repository:
git clone https://github.com/keycloak/keycloak.git
cd keycloak
To build Keycloak run:
2022-12-09 15:44:22 +00:00
./mvnw clean install
2019-02-19 18:59:45 +00:00
This will build all modules and run the testsuite.
To build only the server run:
2023-08-01 15:16:50 +00:00
./mvnw -pl quarkus/dist -am -DskipTests clean install
2019-02-19 18:59:45 +00:00
2020-07-02 14:12:28 +00:00
---
**NOTE**
Classes from `org.keycloak.testsuite.*` packages aren't suitable to be used in production.
---
2019-02-19 18:59:45 +00:00
2022-12-09 15:44:22 +00:00
This project contains opt-in support for incremental Maven builds using the [Apache Maven Build Cache Extension ](https://github.com/apache/maven-build-cache-extension ) which is disabled by default.
To enable it for a single Maven command execution, enable it as follows:
./mvnw -D -Dmaven.build.cache.enabled=true ...
To enable it by default, add it to the `MAVEN_OPTS` environment variable:
export MAVEN_OPTS="-Dmaven.build.cache.enabled=true"
2021-08-04 15:04:26 +00:00
### Building Quarkus Distribution
Please, take a look at this [documentation ](../quarkus/README.md ).
2019-02-19 18:59:45 +00:00
## Starting Keycloak
To start Keycloak during development first build as specified above, then run:
2022-12-09 15:44:22 +00:00
./mvnw -f testsuite/utils/pom.xml exec:java -Pkeycloak-server
2019-02-19 18:59:45 +00:00
When running testsuite, by default an account with username `admin` and password `admin` will be created within the master realm at start.
To stop the server press `Ctrl + C` .
## Working with the codebase
We don't currently enforce a code style in Keycloak, but a good reference is the code style used by WildFly. This can be
2021-11-03 14:40:15 +00:00
retrieved from [Wildfly ide-configs ](https://github.com/wildfly/wildfly-core/tree/main/ide-configs ).To import formatting
2019-02-19 18:59:45 +00:00
rules, see following [instructions ](http://community.jboss.org/wiki/ImportFormattingRules ).
If your changes require updates to the database read [Updating Database Schema ](updating-database-schema.md ).
If your changes require introducing new dependencies or updating dependency versions please discuss this first on the
dev mailing list. We do not accept new dependencies to be added lightly, so try to use what is available.
2022-08-30 14:59:36 +00:00
### Building project from the IDE
Some parts of the project rely on generated code using Maven plugins. These steps might be skipped when building using
IDE resulting in compilation errors. To work around this make sure to build the project first using Maven. After the
initial build with Maven you should be able to build the project using the IDE as it will use the classes previously
generated by Maven plugins. Make sure you don't rebuild the whole project using the IDE as it would delete the generated
classes. E.g. in IntelliJ IDEA use `Build → Build Project` instead of `Build → Rebuild Project` .
---
**NOTE**
If you are building the Operator from your IDE, make sure to build the project with the `operator` profile enabled in Maven
as it's excluded by default:
2022-12-09 15:44:22 +00:00
./mvnw clean install -Poperator -DskipTests
2022-08-30 14:59:36 +00:00
2023-04-27 02:21:20 +00:00
---