[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 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 ### Building the Distribution
To build the module as well as the distribution packages: To build the module as well as the distribution packages:

View file

@ -17,6 +17,7 @@
package org.keycloak.quarkus.runtime.cli.command; 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.error;
import static org.keycloak.quarkus.runtime.cli.Picocli.println; 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.QuarkusEntryPoint;
import io.quarkus.bootstrap.runner.RunnerClassLoader; import io.quarkus.bootstrap.runner.RunnerClassLoader;
import io.quarkus.runtime.configuration.ProfileManager;
import picocli.CommandLine.Command; import picocli.CommandLine.Command;
@Command(name = Build.NAME, @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"); println(spec.commandLine(), "\t" + Environment.getCommand() + " show-config\n");
} catch (Throwable throwable) { } catch (Throwable throwable) {
error(spec.commandLine(), "Failed to update server configuration.", 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} start --help\" for the available options when starting the server.",
"Use \"${COMMAND-NAME} <command> --help\" for more information about other commands.", "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", optionListHeading = "Options%n%n",
commandListHeading = "%nCommands%n%n", commandListHeading = "%nCommands%n%n",
abbreviateSynopsis = true, abbreviateSynopsis = true,
versionProvider = VersionProvider.class,
subcommands = { subcommands = {
Build.class, Build.class,
Start.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(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 @Override

View file

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