Skip to content

Commit

Permalink
[KEYCLOAK-14255] - Changes to maven definition and initial support fo…
Browse files Browse the repository at this point in the history
…r dev mode
  • Loading branch information
pedroigor committed Jul 17, 2020
1 parent 4cd5ace commit 967449f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 57 deletions.
47 changes: 43 additions & 4 deletions quarkus/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,56 @@
# Keycloak Quarkus Distribution
# Keycloak on Quarkus

Keycloak on Quarkus is a work in progress.
The module holds the codebase to run Keycloak on top of [Quarkus](https://quarkus.io/):

├── deployment
│   ├── Build-time codebase with all the necessary steps to build and configure the server
├── runtime
│   ├── Runtime codebase with all the runtime code
└── server
├── The server itself, only responsible for generating the server artifacts


## Activating the Module

The module isn't enabled by default. To enable it please activate the `quarkus` profile.

## Building

To build the module and produce the artifacts to run a server:

mvn -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests -Pquarkus

### Building the Distribution

To build the module as well as the distribution packages:

mvn -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests -Pquarkus,distribution

The distribution packages (ZIP and TAR) should be available at [../distribution/server-x](../distribution/server-x/target).

## Running

java -jar server/target/keycloak-runner.jar
java -jar server/target/lib/quarkus-run.jar

## Running in dev mode
## Contributing

### Development Mode

To run the server in development mode:

cd server
mvn compile quarkus:dev

You should be able to attach your debugger to port `5005`.

Changes to files such as `server/src/main/resources` or `server/src/main/resources/META-INF/keycloak.properties` should
be recognized automatically when running in development mode.

However, considering that there is no real code in the `server` module (but from `runtime` and its dependencies), changes you make to
dependencies (e.g: services, model, etc) won't be reflected into the running server. However, you can still leverage the
hot reload capabilities from your IDE to make changes at runtime.

NOTE: We need to improve DevX and figure out why changes to dependencies are not being recognized when running tests or running
Quarkus Dev Mode.
23 changes: 5 additions & 18 deletions quarkus/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,58 @@
<artifactId>keycloak-quarkus-server-deployment</artifactId>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-web-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-h2-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mariadb-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-web-deployment</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-core</artifactId>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<version>${quarkus.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -146,7 +134,6 @@
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.Map;
import java.util.Set;

import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
import io.quarkus.hibernate.orm.deployment.HibernateOrmConfig;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
Expand Down Expand Up @@ -80,6 +82,11 @@ void initializeRouter(BuildProducer<FilterBuildItem> routes) {
routes.produce(new FilterBuildItem(new QuarkusRequestFilter(), FilterBuildItem.AUTHORIZATION - 10));
}

@BuildStep(onlyIf = IsDevelopment.class)
void configureDevMode(BuildProducer<HotDeploymentWatchedFileBuildItem> hotFiles) {
hotFiles.produce(new HotDeploymentWatchedFileBuildItem("META-INF/keycloak.properties"));
}

private Map<Spi, Set<Class<? extends ProviderFactory>>> loadFactories() {
ProviderManager pm = new ProviderManager(
KeycloakDeploymentInfo.create().services(), new BuildClassLoader(),
Expand Down
16 changes: 2 additions & 14 deletions quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
<jackson.databind.version>${jackson.version}</jackson.databind.version>
<hibernate.version>5.4.18.Final</hibernate.version>
<snakeyaml.version>1.20</snakeyaml.version>

<surefire-plugin.version>2.22.0</surefire-plugin.version>

<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<wildfly.common.format.version>1.5.0.Final-format-001</wildfly.common.format.version>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -51,21 +49,11 @@
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom-deployment</artifactId>
<artifactId>quarkus-bom</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions quarkus/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@

<dependencies>
<!-- Quarkus -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-web</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
Expand Down
33 changes: 12 additions & 21 deletions quarkus/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,26 @@
<name>Keycloak Quarkus Server App</name>
<artifactId>keycloak-quarkus-server-app</artifactId>

<properties>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server</artifactId>
<version>${project.version}</version>
</dependency>

<!-- This dependency should not be here but due to the structure of the modules we need to make sure it is built
before this module -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-quarkus-server-deployment</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down

0 comments on commit 967449f

Please sign in to comment.