[KEYCLOAK-19767] - Minor improvements to CLI

This commit is contained in:
Pedro Igor 2021-11-04 09:49:57 -03:00
parent 579c5462b2
commit 4606b85596
7 changed files with 25 additions and 21 deletions

View file

@ -25,10 +25,6 @@ To build the module and produce the artifacts to run a server:
mvn -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests
If you already built Keycloak artifacts using JDK 8, you should be able to skip the previous step and just build this module as follows:
mvn clean install
### Building the Distribution
To build the module as well as the distribution packages:
@ -69,4 +65,4 @@ blocks us to leverage all the capabilities from Quarkus dev mode. For instance,
NOTE: When developing custom providers, you should be able to benefit from live coding as long as you keep changes within the `server` module.
Alternatively, you can run the server in development mode from your IDE. For that, run the `org.keycloak.quarkus._private.IDELauncher` main class.
Alternatively, you can run the server in development mode from your IDE. For that, run the `org.keycloak.quarkus._private.IDELauncher` main class.

View file

@ -17,6 +17,7 @@
package org.keycloak.quarkus.runtime.cli.command;
import static org.keycloak.quarkus.runtime.Environment.getHomePath;
import static org.keycloak.quarkus.runtime.cli.Picocli.error;
import static org.keycloak.quarkus.runtime.cli.Picocli.println;
@ -25,6 +26,7 @@ import org.keycloak.quarkus.runtime.Environment;
import io.quarkus.bootstrap.runner.QuarkusEntryPoint;
import io.quarkus.bootstrap.runner.RunnerClassLoader;
import io.quarkus.runtime.configuration.ProfileManager;
import picocli.CommandLine.Command;
@Command(name = Build.NAME,
@ -72,6 +74,8 @@ public final class Build extends AbstractCommand implements Runnable {
println(spec.commandLine(), "\t" + Environment.getCommand() + " show-config\n");
} catch (Throwable throwable) {
error(spec.commandLine(), "Failed to update server configuration.", throwable);
} finally {
cleanTempResources();
}
}
@ -88,4 +92,11 @@ public final class Build extends AbstractCommand implements Runnable {
}
}
}
private void cleanTempResources() {
if (!ProfileManager.getLaunchMode().isDevOrTest()) {
// only needed for dev/testing purposes
getHomePath().resolve("quarkus-artifact.properties").toFile().delete();
}
}
}

View file

@ -44,10 +44,14 @@ import picocli.CommandLine.ScopeType;
"Use \"${COMMAND-NAME} start --help\" for the available options when starting the server.",
"Use \"${COMMAND-NAME} <command> --help\" for more information about other commands.",
},
version = {
"Keycloak ${sys:kc.version}",
"JVM: ${java.version} (${java.vendor} ${java.vm.name} ${java.vm.version})",
"OS: ${os.name} ${os.version} ${os.arch}"
},
optionListHeading = "Options%n%n",
commandListHeading = "%nCommands%n%n",
abbreviateSynopsis = true,
versionProvider = VersionProvider.class,
subcommands = {
Build.class,
Start.class,

View file

@ -1,13 +0,0 @@
package org.keycloak.quarkus.runtime.cli.command;
import picocli.CommandLine.IVersionProvider;
public class VersionProvider implements IVersionProvider {
@Override
public String[] getVersion() {
return new String[]{"Keycloak ${sys:kc.version}",
"JVM: ${java.version} (${java.vendor} ${java.vm.name} ${java.vm.version})",
"OS: ${os.name} ${os.version} ${os.arch}%n"
};
}
}

View file

@ -108,7 +108,11 @@ public class KeycloakConfigSourceProvider implements ConfigSourceProvider {
return Paths.get(System.getProperty("java.io.tmpdir"), PersistedConfigSource.KEYCLOAK_PROPERTIES);
}
return Paths.get(homeDir, "conf", PersistedConfigSource.KEYCLOAK_PROPERTIES);
Path generatedPath = Paths.get(homeDir, "data", "generated");
generatedPath.toFile().mkdirs();
return generatedPath.resolve(PersistedConfigSource.KEYCLOAK_PROPERTIES);
}
@Override

View file

@ -40,4 +40,4 @@ spi.theme.folder.dir=${kc.home.dir:}/themes
# Logging configuration. INFO is the default level for most of the categories
#quarkus.log.level = DEBUG
quarkus.log.category."org.jboss.resteasy.resteasy_jaxrs.i18n".level=WARN
quarkus.log.category."org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup".level=WARN
quarkus.log.category."org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup".level=WARN

View file

@ -23,3 +23,5 @@ quarkus.resteasy.ignore-application-classes=true
# Ignore split packages for Keycloak related packages
quarkus.arc.ignored-split-packages=org.keycloak.*
# No need to generate dependencies list
quarkus.package.include-dependency-list=false