Skip to content

Commit

Permalink
Direct kc.home.dir to Maven's target folder
Browse files Browse the repository at this point in the history
This prevents files created, for example, the store to end up in the user's home directory.

Closes #12850
  • Loading branch information
ahus1 authored and abstractj committed Jul 4, 2022
1 parent 007fa1f commit 2c0cebe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions quarkus/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
</dependency>
</dependencies>

<properties>
<!-- define this as a property, so it can still be overwritten on the CLI -->
<!-- direct the auto-created files to the target folder, so they are cleaned by "mvn clean" -->
<kc.home.dir>${project.build.directory}/kc</kc.home.dir>
</properties>

<build>
<finalName>keycloak</finalName>
<plugins>
Expand All @@ -39,6 +45,9 @@
<version>${quarkus.version}</version>
<configuration>
<finalName>keycloak</finalName>
<systemProperties>
<kc.home.dir>${kc.home.dir}</kc.home.dir>
</systemProperties>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.keycloak.quarkus._private;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -27,6 +30,13 @@ public class IDELauncher {
public static void main(String[] args) {
List<String> devArgs = new ArrayList<>();

if (System.getProperty("kc.home.dir") == null) {
// direct the auto-created files to the target folder, so they are cleaned by "mvn clean"
// users can still provide a different folder by setting the property when starting it from their IDE.
Path path = Paths.get(System.getProperty("user.dir"), "target", "kc");
System.setProperty("kc.home.dir", path.toAbsolutePath().toString());
}

devArgs.addAll(Arrays.asList(args));

if (devArgs.isEmpty()) {
Expand Down

0 comments on commit 2c0cebe

Please sign in to comment.