Do not run build when executing import and export commands (#13942)
Closes #13940
This commit is contained in:
parent
1c5a77ef19
commit
2b9a0bff51
5 changed files with 29 additions and 14 deletions
|
@ -52,6 +52,8 @@ import org.keycloak.config.MultiOption;
|
|||
import org.keycloak.config.OptionCategory;
|
||||
import org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand;
|
||||
import org.keycloak.quarkus.runtime.cli.command.Build;
|
||||
import org.keycloak.quarkus.runtime.cli.command.Export;
|
||||
import org.keycloak.quarkus.runtime.cli.command.Import;
|
||||
import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin;
|
||||
import org.keycloak.quarkus.runtime.cli.command.Main;
|
||||
import org.keycloak.quarkus.runtime.cli.command.Start;
|
||||
|
@ -102,24 +104,31 @@ public final class Picocli {
|
|||
private static int runReAugmentationIfNeeded(List<String> cliArgs, CommandLine cmd) {
|
||||
int exitCode = 0;
|
||||
|
||||
if (!isHelpCommand(cliArgs)) {
|
||||
if (cliArgs.contains(StartDev.NAME)) {
|
||||
String profile = Environment.getProfile();
|
||||
if (shouldSkipRebuild(cliArgs)) {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
if (profile == null) {
|
||||
// force the server image to be set with the dev profile
|
||||
Environment.forceDevProfile();
|
||||
}
|
||||
}
|
||||
if (requiresReAugmentation(cmd)) {
|
||||
exitCode = runReAugmentation(cliArgs, cmd);
|
||||
if (cliArgs.contains(StartDev.NAME)) {
|
||||
String profile = Environment.getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
// force the server image to be set with the dev profile
|
||||
Environment.forceDevProfile();
|
||||
}
|
||||
}
|
||||
if (requiresReAugmentation(cmd)) {
|
||||
exitCode = runReAugmentation(cliArgs, cmd);
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
private static boolean isHelpCommand(List<String> cliArgs) {
|
||||
return cliArgs.contains("--help") || cliArgs.contains("-h") || cliArgs.contains("--help-all");
|
||||
private static boolean shouldSkipRebuild(List<String> cliArgs) {
|
||||
return cliArgs.contains("--help")
|
||||
|| cliArgs.contains("-h")
|
||||
|| cliArgs.contains("--help-all")
|
||||
|| cliArgs.contains(Export.NAME)
|
||||
|| cliArgs.contains(Import.NAME);
|
||||
}
|
||||
|
||||
public static boolean requiresReAugmentation(CommandLine cmd) {
|
||||
|
|
|
@ -22,11 +22,13 @@ import static org.keycloak.exportimport.ExportImportConfig.ACTION_EXPORT;
|
|||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
|
||||
@Command(name = "export",
|
||||
@Command(name = Export.NAME,
|
||||
header = "Export data from realms to a file or directory.",
|
||||
description = "%nExport data from realms to a file or directory.")
|
||||
public final class Export extends AbstractExportImportCommand implements Runnable {
|
||||
|
||||
public static final String NAME = "export";
|
||||
|
||||
@Option(names = "--users",
|
||||
arity = "1",
|
||||
description = "Set how users should be exported. Possible values are: skip, realm_file, same_file, different_files.",
|
||||
|
|
|
@ -24,11 +24,13 @@ import static org.keycloak.exportimport.Strategy.OVERWRITE_EXISTING;
|
|||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
|
||||
@Command(name = "import",
|
||||
@Command(name = Import.NAME,
|
||||
header = "Import data from a directory or a file.",
|
||||
description = "%nImport data from a directory or a file.")
|
||||
public final class Import extends AbstractExportImportCommand implements Runnable {
|
||||
|
||||
public static final String NAME = "import";
|
||||
|
||||
@Option(names = "--override",
|
||||
arity = "1",
|
||||
description = "Set if existing data should be skipped or overridden.",
|
||||
|
|
|
@ -35,6 +35,7 @@ public class ExportDistTest {
|
|||
CLIResult cliResult = (CLIResult) result;
|
||||
cliResult.assertMessage("Export of realm 'master' requested.");
|
||||
cliResult.assertMessage("Export finished successfully");
|
||||
cliResult.assertNoMessage("Changes detected in configuration");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -49,5 +49,6 @@ public class ImportDistTest {
|
|||
CLIResult cliResult = (CLIResult) result;
|
||||
cliResult.assertMessage("Realm 'master' imported");
|
||||
cliResult.assertMessage("Import finished successfully");
|
||||
cliResult.assertNoMessage("Changes detected in configuration");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue