diff --git a/.github/workflows/js-ci.yml b/.github/workflows/js-ci.yml index a5eca061ca..1a240d1acf 100644 --- a/.github/workflows/js-ci.yml +++ b/.github/workflows/js-ci.yml @@ -47,7 +47,7 @@ jobs: - name: Build Keycloak run: | - mvn clean install --batch-mode --errors -DskipTests -DskipTestsuite -DskipExamples -DskipAccount2 -DskipCommon -Pdistribution + ./mvnw clean install --batch-mode --errors -DskipTests -DskipTestsuite -DskipExamples -DskipAccount2 -DskipCommon -Pdistribution mv ./quarkus/dist/target/keycloak-999.0.0-SNAPSHOT.tar.gz ./keycloak-999.0.0-SNAPSHOT.tar.gz - name: Upload Keycloak dist diff --git a/.github/workflows/operator-ci.yml b/.github/workflows/operator-ci.yml index ed456c11eb..50345793ce 100644 --- a/.github/workflows/operator-ci.yml +++ b/.github/workflows/operator-ci.yml @@ -90,7 +90,7 @@ jobs: - name: Test operator running locally run: | - mvn install -Poperator -pl :keycloak-operator -am \ + ./mvnw install --batch-mode -Poperator -pl :keycloak-operator -am \ -Dquarkus.kubernetes.image-pull-policy=IfNotPresent \ -Doperator.keycloak.image=keycloak:${{ env.version_local }} \ -Dtest.operator.custom.image=custom-keycloak:${{ env.version_local }} \ @@ -138,7 +138,7 @@ jobs: - name: Test operator running in cluster run: | eval $(minikube -p minikube docker-env) - mvn install -Poperator -pl :keycloak-operator -am \ + ./mvnw install --batch-mode -Poperator -pl :keycloak-operator -am \ -Dquarkus.container-image.build=true \ -Dquarkus.kubernetes.image-pull-policy=IfNotPresent \ -Doperator.keycloak.image=keycloak:${{ env.version_remote }} \ diff --git a/.github/workflows/snyk-analysis.yml b/.github/workflows/snyk-analysis.yml index 19195ddb9f..5c4ed6216e 100644 --- a/.github/workflows/snyk-analysis.yml +++ b/.github/workflows/snyk-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Check for vulnerabilities in Operator run: | - mvn -Poperator -pl operator -am -DskipTests clean install + ./mvnw -Poperator -pl operator -am -DskipTests clean install --batch-mode snyk test --policy-path=${GITHUB_WORKSPACE}/.github/snyk/.snyk --all-projects --prune-repeated-subdependencies --exclude=tests --sarif-file-output=operator-report.sarif operator continue-on-error: true env: diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000000..4bd06e01bc --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,25 @@ + + + + + + org.apache.maven.extensions + maven-build-cache-extension + 1.0.1 + + \ No newline at end of file diff --git a/.mvn/maven-build-cache-config.xml b/.mvn/maven-build-cache-config.xml new file mode 100644 index 0000000000..9840b2446c --- /dev/null +++ b/.mvn/maven-build-cache-config.xml @@ -0,0 +1,67 @@ + + + + + + false + XX + + + + + {*} + + + + + + + + + + + + + + + + + + + + install + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 57bb584385..0d2696f797 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/adapters/oidc/js/pom.xml b/adapters/oidc/js/pom.xml index 40c114db2c..83f493c2c4 100644 --- a/adapters/oidc/js/pom.xml +++ b/adapters/oidc/js/pom.xml @@ -18,6 +18,10 @@ ../../../js ${js.projectDir}/libs/keycloak-js ${js.adapter.projectDir}/dist + + ${maven.multiModuleProjectDirectory}/js/libs/keycloak-js/node_modules + + ${maven.multiModuleProjectDirectory}/js/libs/keycloak-js/dist diff --git a/docs/building.md b/docs/building.md index a4506fde73..7af704755f 100644 --- a/docs/building.md +++ b/docs/building.md @@ -1,26 +1,12 @@ ## Building from source -Ensure you have JDK 11 (or newer), Maven 3.6.3 (or newer) and Git installed +Ensure you have JDK 11 (or newer) and Git installed java -version - mvn -version git --version -**NOTE** - -If you use Maven 3.8.1 or newer, please add the following mirror to your local -`~/.m2/settings.xml` to avoid build errors: -``` - - - jboss-public-repository-group-https - jboss-public-repository-group - Jboss public https - https://repository.jboss.org/nexus/content/groups/public/ - - -``` -See [KEYCLOAK-17812](https://issues.redhat.com/browse/KEYCLOAK-17812) for more details. +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. --- First clone the Keycloak repository: @@ -30,19 +16,19 @@ First clone the Keycloak repository: To build Keycloak run: - mvn clean install + ./mvnw clean install This will build all modules and run the testsuite. To build the ZIP distribution run: - mvn clean install -Pdistribution + ./mvnw clean install -Pdistribution Once completed you will find distribution archives in `distribution`. To build only the server run: - mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install + ./mvnw -Pdistribution -pl quarkus/dist -am -Dmaven.test.skip clean install --- **NOTE** @@ -51,6 +37,16 @@ Classes from `org.keycloak.testsuite.*` packages aren't suitable to be used in p --- +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" + ### Building Quarkus Distribution Please, take a look at this [documentation](../quarkus/README.md). @@ -59,19 +55,12 @@ Please, take a look at this [documentation](../quarkus/README.md). To start Keycloak during development first build as specified above, then run: - mvn -f testsuite/utils/pom.xml exec:java -Pkeycloak-server + ./mvnw -f testsuite/utils/pom.xml exec:java -Pkeycloak-server When running testsuite, by default an account with username `admin` and password `admin` will be created within the master realm at start. -To start Keycloak from the server distribution first build the distribution it as specified above, then run: - - tar xfz distribution/server-dist/target/keycloak-.tar.gz - cd keycloak- - bin/standalone.sh - 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 @@ -97,6 +86,6 @@ classes. E.g. in IntelliJ IDEA use `Build → Build Project` instead of `Build 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: - mvn clean install -Poperator -DskipTests + ./mvnw clean install -Poperator -DskipTests --- diff --git a/js/pom.xml b/js/pom.xml index fee3981bb0..00cf9efe3f 100644 --- a/js/pom.xml +++ b/js/pom.xml @@ -22,6 +22,13 @@ libs/keycloak-js + + + src + + ${project.basedir}/dist + + diff --git a/quarkus/README.md b/quarkus/README.md index fbf46c6e19..f9170e1c43 100644 --- a/quarkus/README.md +++ b/quarkus/README.md @@ -33,7 +33,7 @@ When a build from the project root directory is started, this module is only ena To build this module and produce the artifacts to run a server, you first need to build the main codebase once. This step will put required modules of keycloak into your local maven cache in package `org.keycloak`: - mvn -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests + ../mvnw -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests This build can take some time, usually around two to four minutes depending on your hardware, and even longer depending on the maven packages that need to be downloaded and installed to the cache. @@ -41,13 +41,13 @@ This build can take some time, usually around two to four minutes depending on y After the main codebase is built, you can build the quarkus distribution, including the zip and tar.gz files, by invoking the following command: - mvn clean install -DskipTests + ../mvnw clean install -DskipTests This command produces the distribution artifacts as ZIP and TAR file. The artifacts for the quarkus distribution will be available at the `/dist/target` subdirectory afterwards. As an alternative, you can build the distribution artifacts directly without a rebuild of the code by running the following command: - mvn -f dist/pom.xml clean install + ../mvnw -f dist/pom.xml clean install ## Running in Keycloak development mode When you start Keycloak in production mode, the HTTP port is disabled by default, and you need to provide the key material to configure HTTPS, a hostname and other configuration suitable for production. @@ -66,13 +66,13 @@ Please make sure to read our [Contribution Guidelines](../CONTRIBUTING.md) befor To run the server in Quarkus' development mode, invoke the following command: - mvn -f server/pom.xml compile quarkus:dev -Dquarkus.args="start-dev" + ../mvnw -f server/pom.xml compile quarkus:dev -Dquarkus.args="start-dev" You will be able to attach your debugger to port `5005`. For debugging the build steps right after start, you can suspend the JVM by running: - mvn -f server/pom.xml -Dsuspend=true compile quarkus:dev -Dquarkus.args="start-dev" + ../mvnw -f server/pom.xml -Dsuspend=true compile quarkus:dev -Dquarkus.args="start-dev" When running using `quarkus:dev` you are able to do live coding whenever you change / add code in the `server` module, for example when creating a new custom provider. @@ -102,10 +102,12 @@ There are also some container based tests to check if Keycloak starts using one These tests are disabled by default. They using Quarkus development mode predefined database containers by default and can be run in the `tests` subdirectory by using e.g. - mvn clean install -Dkc.test.storage.database=true -Dtest=MariaDBStartDatabaseTest + ../mvnw clean install -Dkc.test.storage.database=true -Dtest=MariaDBStartDatabaseTest to spin up a MariaDB container and start Keycloak with it. -To use a specific database container image, use the option -Dkc.db.postgresql.container.image to specify the image tag of the postgres image to use or -Dkc.db.mariadb.container.image= for mariadb. +To use a specific database container image, use the option `-Dkc.db.postgresql.container.image` to specify the image tag of the postgres image to use or `-Dkc.db.mariadb.container.image=` for mariadb. + Example: -mvn clean install -Dkc.test.storage.database=true -Dtest=PostgreSQLDistTest -Dkc.db.postgresql.container.image=postgres: + + ../mvnw clean install -Dkc.test.storage.database=true -Dtest=PostgreSQLDistTest -Dkc.db.postgresql.container.image=postgres:alpine diff --git a/themes/pom.xml b/themes/pom.xml index 7085e3f06d..d446073fff 100755 --- a/themes/pom.xml +++ b/themes/pom.xml @@ -16,6 +16,11 @@ src/main/resources/theme/keycloak/common/resources src/main/resources/theme/keycloak.v2/account/src ci --no-optional --ignore-scripts + + ${project.basedir}/src/main/resources/theme/keycloak/common/resources/node_modules + ${project.basedir}/src/main/resources/theme/keycloak/common/resources/web_modules + ${project.basedir}/src/main/resources/theme/keycloak.v2/account/src/node_modules + ${project.basedir}/src/main/resources/theme/keycloak.v2/account/src/web_modules