Skip to content

Commit

Permalink
Support using commas to add 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 extensions.

Fixes quarkusio#37564
  • Loading branch information
gsmet committed Dec 7, 2023
1 parent abe537f commit 00cc1ad
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 1 deletion.
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
@@ -0,0 +1,111 @@
package io.quarkus.cli;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.quarkus.devtools.testing.RegistryClientTestHelper;
import picocli.CommandLine;

public class CliProjectExtensionsAddTest {

static final Path testProjectRoot = Paths.get(System.getProperty("user.dir")).toAbsolutePath()
.resolve("target/test-project/");
static final Path workspaceRoot = testProjectRoot.resolve("CliProjectExtensionsAddTest");
Path project;

@BeforeAll
public static void setupTestRegistry() {
RegistryClientTestHelper.enableRegistryClientTestConfig();
}

@AfterAll
public static void cleanupTestRegistry() {
RegistryClientTestHelper.disableRegistryClientTestConfig();
}

@BeforeEach
public void setupTestDirectories() throws Exception {
CliDriver.deleteDir(workspaceRoot);
}

@Test
public void testAddExtensionsCommas() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "-e", "-B", "--verbose",
"org.acme:quarkus-add-extensions-commas");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result);
Assertions.assertTrue(result.stdout.contains("SUCCESS"),
"Expected confirmation that the project has been created." + result);

Path project = workspaceRoot.resolve("quarkus-add-extensions-commas");
Path projectPom = project.resolve("pom.xml");
Assertions.assertTrue(Files.exists(projectPom), "pom.xml should exist");

String pomContent = Files.readString(projectPom);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent);

// Check the extensions are not there yet
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"),
"pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent);
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"),
"pom.xml should not contain quarkus-resteasy-reactive-jsonb:\n" + pomContent);

// Add the extensions
result = CliDriver.execute(project, "extension", "add",
"quarkus-resteasy-reactive-jackson,quarkus-resteasy-reactive-jsonb");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result);
Assertions.assertTrue(result.stdout.contains("SUCCESS"),
"Expected confirmation that the project has been created." + result);

// Check that they have been added
pomContent = Files.readString(projectPom);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive-jsonb:\n" + pomContent);
}

@Test
public void testAddExtensionsSpaces() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "-e", "-B", "--verbose",
"org.acme:quarkus-add-extensions-spaces");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result);
Assertions.assertTrue(result.stdout.contains("SUCCESS"),
"Expected confirmation that the project has been created." + result);

Path project = workspaceRoot.resolve("quarkus-add-extensions-spaces");
Path projectPom = project.resolve("pom.xml");
Assertions.assertTrue(Files.exists(projectPom), "pom.xml should exist");

String pomContent = Files.readString(projectPom);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent);

// Check the extensions are not there yet
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"),
"pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent);
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"),
"pom.xml should not contain quarkus-resteasy-reactive-jsonb:\n" + pomContent);

// Add the extensions
result = CliDriver.execute(project, "extension", "add", "quarkus-resteasy-reactive-jackson",
"quarkus-resteasy-reactive-jsonb");
Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result);
Assertions.assertTrue(result.stdout.contains("SUCCESS"),
"Expected confirmation that the project has been created." + result);

// Check that they have been added
pomContent = Files.readString(projectPom);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent);
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"),
"pom.xml should contain quarkus-resteasy-reactive-jsonb:\n" + pomContent);
}
}
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:3.6.1"
},
"minimum-java-version" : "11",
"status" : "stable",
"config" : [ "quarkus.resteasy-reactive.", "quarkus.jackson." ],
"built-with-quarkus-core" : "3.6.1",
"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:3.6.1"
},
"minimum-java-version" : "11",
"status" : "stable",
"config" : [ "quarkus.resteasy-reactive." ],
"built-with-quarkus-core" : "3.6.1",
"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 00cc1ad

Please sign in to comment.