Skip to content

Commit

Permalink
Support using commas to add and remove extensions with CLI
Browse files Browse the repository at this point in the history
Actually, it was already supported when creating projects, just not when
adding/removing extensions.

Fixes quarkusio#37564
  • Loading branch information
gsmet committed Dec 7, 2023
1 parent abe537f commit 09d2c52
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ProjectExtensionsAdd extends BaseBuildCommand implements Callable<I
@CommandLine.Mixin
RunModeOption runMode;

@CommandLine.Parameters(arity = "1", paramLabel = "EXTENSION", description = "extensions to add to this project")
@CommandLine.Parameters(arity = "1", paramLabel = "EXTENSION", description = "extensions to add to this project", split = ",")
Set<String> extensions;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ProjectExtensionsRemove extends BaseBuildCommand implements Callabl
@CommandLine.Mixin
RunModeOption runMode;

@CommandLine.Parameters(arity = "1", paramLabel = "EXTENSION", description = "Extension(s) to remove from this project.")
@CommandLine.Parameters(arity = "1", paramLabel = "EXTENSION", description = "Extension(s) to remove from this project.", split = ",")
Set<String> extensions;

@Override
Expand Down
50 changes: 48 additions & 2 deletions devtools/cli/src/test/java/io/quarkus/cli/CliDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public static Result invokeExtensionRemoveQute(Path projectRoot, Path file) thro
}

public static Result invokeExtensionAddMultiple(Path projectRoot, Path file) throws Exception {
// add the qute extension
// add amazon-lambda-http and jackson extensions
Result result = execute(projectRoot, "extension", "add", "amazon-lambda-http", "jackson", "-e", "-B", "--verbose");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode,
"Expected OK return code. Result:\n" + result);
Expand All @@ -345,7 +345,7 @@ public static Result invokeExtensionAddMultiple(Path projectRoot, Path file) thr
}

public static Result invokeExtensionRemoveMultiple(Path projectRoot, Path file) throws Exception {
// add the qute extension
// remove amazon-lambda-http and jackson extensions
Result result = execute(projectRoot, "extension", "remove", "amazon-lambda-http", "jackson", "-e", "-B", "--verbose");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode,
"Expected OK return code. Result:\n" + result);
Expand All @@ -370,6 +370,52 @@ public static Result invokeExtensionRemoveMultiple(Path projectRoot, Path file)
return result;
}

public static Result invokeExtensionAddMultipleCommas(Path projectRoot, Path file) throws Exception {
Result result = execute(projectRoot, "extension", "add",
"quarkus-resteasy-reactive-jsonb,quarkus-resteasy-reactive-jackson", "-e", "-B", "--verbose");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode,
"Expected OK return code. Result:\n" + result);

result = invokeValidateExtensionList(projectRoot);
Assertions.assertTrue(result.stdout.contains("quarkus-qute"),
"Expected quarkus-qute to be in the list of extensions. Result:\n" + result);
Assertions.assertTrue(result.stdout.contains("quarkus-resteasy-reactive-jsonb"),
"Expected quarkus-resteasy-reactive-jsonb to be in the list of extensions. Result:\n" + result);
Assertions.assertTrue(result.stdout.contains("quarkus-resteasy-reactive-jackson"),
"Expected quarkus-resteasy-reactive-jackson to be in the list of extensions. Result:\n" + result);

String content = CliDriver.readFileAsString(file);
Assertions.assertTrue(content.contains("quarkus-qute"),
"quarkus-qute should still be listed as a dependency. Result:\n" + content);
Assertions.assertTrue(content.contains("quarkus-resteasy-reactive-jsonb"),
"quarkus-resteasy-reactive-jsonb should be listed as a dependency. Result:\n" + content);
Assertions.assertTrue(content.contains("quarkus-resteasy-reactive-jackson"),
"quarkus-resteasy-reactive-jackson should be listed as a dependency. Result:\n" + content);

return result;
}

public static Result invokeExtensionRemoveMultipleCommas(Path projectRoot, Path file) throws Exception {
Result result = execute(projectRoot, "extension", "remove",
"quarkus-resteasy-reactive-jsonb,quarkus-resteasy-reactive-jackson", "-e", "-B", "--verbose");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode,
"Expected OK return code. Result:\n" + result);

result = invokeValidateExtensionList(projectRoot);
Assertions.assertFalse(result.stdout.contains("quarkus-resteasy-reactive-jsonb"),
"quarkus-resteasy-reactive-jsonb should not be in the list of extensions. Result:\n" + result);
Assertions.assertFalse(result.stdout.contains("quarkus-resteasy-reactive-jackson"),
"quarkus-resteasy-reactive-jackson should not be in the list of extensions. Result:\n" + result);

String content = CliDriver.readFileAsString(file);
Assertions.assertFalse(content.contains("quarkus-resteasy-reactive-jsonb"),
"quarkus-resteasy-reactive-jsonb should not be listed as a dependency. Result:\n" + content);
Assertions.assertFalse(content.contains("quarkus-resteasy-reactive-jackson"),
"quarkus-resteasy-reactive-jackson should not be listed as a dependency. Result:\n" + content);

return result;
}

public static Result invokeExtensionListInstallable(Path projectRoot) throws Exception {
Result result = CliDriver.execute(projectRoot, "extension", "list", "-e", "-B", "--verbose", "-i");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ public void testExtensionList() throws Exception {
CliDriver.invokeExtensionAddRedundantQute(project);
CliDriver.invokeExtensionListInstallable(project);
CliDriver.invokeExtensionAddMultiple(project, pom);
CliDriver.invokeExtensionAddMultipleCommas(project, pom);
CliDriver.invokeExtensionRemoveQute(project, pom);
CliDriver.invokeExtensionRemoveMultiple(project, pom);
CliDriver.invokeExtensionRemoveMultipleCommas(project, pom);

CliDriver.invokeExtensionListInstallableSearch(project);
CliDriver.invokeExtensionListFormatting(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,62 @@
"io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE"
]
},
{
"name" : "RESTEasy Reactive Jackson",
"description" : "Jackson serialization support for RESTEasy Reactive. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it",
"metadata" : {
"codestart" : {
"name" : "resteasy-reactive",
"kind" : "core",
"languages" : [ "java", "kotlin", "scala" ],
"artifact" : "io.quarkus:quarkus-project-core-extension-codestarts::jar:999-FAKE"
},
"minimum-java-version" : "11",
"status" : "stable",
"config" : [ "quarkus.resteasy-reactive.", "quarkus.jackson." ],
"built-with-quarkus-core" : "999-FAKE",
"scm-url" : "https://github.com/quarkus-release/release",
"short-name" : "resteasy-reactive-jackson",
"capabilities" : {
"provides" : [ "io.quarkus.rest.jackson", "io.quarkus.resteasy.reactive.json.jackson" ]
},
"categories" : [ "web", "reactive" ],
"extension-dependencies" : [ "io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-common", "io.quarkus:quarkus-mutiny", "io.quarkus:quarkus-smallrye-context-propagation", "io.quarkus:quarkus-vertx", "io.quarkus:quarkus-netty", "io.quarkus:quarkus-vertx-http", "io.quarkus:quarkus-core", "io.quarkus:quarkus-jsonp", "io.quarkus:quarkus-virtual-threads", "io.quarkus:quarkus-arc", "io.quarkus:quarkus-resteasy-reactive-jackson-common", "io.quarkus:quarkus-jackson" ],
"keywords" : [ "rest-jackson", "quarkus-resteasy-reactive-json", "jaxrs-json", "rest", "jaxrs", "json", "jackson", "jakarta-rest" ]
},
"artifact" : "io.quarkus:quarkus-resteasy-reactive-jackson::jar:999-FAKE",
"origins": [
"io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE"
]
},
{
"name" : "RESTEasy Reactive JSON-B",
"description" : "JSON-B serialization support for RESTEasy Reactive. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.",
"metadata" : {
"codestart" : {
"name" : "resteasy-reactive",
"kind" : "core",
"languages" : [ "java", "kotlin", "scala" ],
"artifact" : "io.quarkus:quarkus-project-core-extension-codestarts::jar:999-FAKE"
},
"minimum-java-version" : "11",
"status" : "stable",
"config" : [ "quarkus.resteasy-reactive." ],
"built-with-quarkus-core" : "999-FAKE",
"scm-url" : "https://github.com/quarkus-release/release",
"short-name" : "resteasy-reactive-jsonb",
"capabilities" : {
"provides" : [ "io.quarkus.rest.jsonb", "io.quarkus.resteasy.reactive.json.jsonb" ]
},
"categories" : [ "web", "reactive" ],
"extension-dependencies" : [ "io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-common", "io.quarkus:quarkus-mutiny", "io.quarkus:quarkus-smallrye-context-propagation", "io.quarkus:quarkus-vertx", "io.quarkus:quarkus-netty", "io.quarkus:quarkus-vertx-http", "io.quarkus:quarkus-core", "io.quarkus:quarkus-jsonp", "io.quarkus:quarkus-virtual-threads", "io.quarkus:quarkus-arc", "io.quarkus:quarkus-resteasy-reactive-jsonb-common", "io.quarkus:quarkus-jsonb" ],
"keywords" : [ "rest-jsonb", "resteasy-reactive-json", "jaxrs-json", "rest", "jaxrs", "json", "jsonb", "jakarta-rest" ]
},
"artifact" : "io.quarkus:quarkus-resteasy-reactive-jsonb::jar:999-FAKE",
"origins": [
"io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE"
]
},
{
"name": "YAML Configuration",
"description": "Use YAML to configure your Quarkus application",
Expand Down

0 comments on commit 09d2c52

Please sign in to comment.