diff --git a/devtools/cli/src/main/java/io/quarkus/cli/create/BaseCreateCommand.java b/devtools/cli/src/main/java/io/quarkus/cli/create/BaseCreateCommand.java index ef87e60871c70..3755ea6099f44 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/create/BaseCreateCommand.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/create/BaseCreateCommand.java @@ -183,6 +183,7 @@ public void setCodegenOptions(CodeGenerationGroup codeGeneration) { setValue(CreateProjectKey.NO_CODE, !codeGeneration.includeCode); setValue(CreateProjectKey.NO_BUILDTOOL_WRAPPER, !codeGeneration.includeWrapper); + setValue(CreateProjectKey.NO_DOCKERFILES, !codeGeneration.includeDockerfiles); } protected void setValue(String name, Object value) { diff --git a/devtools/cli/src/main/java/io/quarkus/cli/create/CodeGenerationGroup.java b/devtools/cli/src/main/java/io/quarkus/cli/create/CodeGenerationGroup.java index 488bcf9bdad34..dcdda2f1db4ed 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/create/CodeGenerationGroup.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/create/CodeGenerationGroup.java @@ -29,6 +29,10 @@ public String getPackageName() { "--no-code" }, description = "Include starter code provided by extensions or generate an empty project", negatable = true) public boolean includeCode = true; + @CommandLine.Option(names = { + "--no-dockerfiles" }, description = "Include standard dockerfiles", negatable = true) + public boolean includeDockerfiles = true; + @CommandLine.Option(names = { "-c", "--app-config" }, description = "Configuration attributes to be set in the application.properties/yml file. Specify as 'key1=value1,key2=value2'") void setAppConfig(String config) { @@ -46,6 +50,7 @@ public String toString() { return "CodeGenerationGroup [" + "includeCode=" + includeCode + ", includeWrapper=" + includeWrapper + + ", includeDockerfiles=" + includeDockerfiles + ", packageName=" + packageName + "]"; } diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java index 51ac69761cb79..0afd91e2f14d6 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java @@ -1,6 +1,7 @@ package io.quarkus.cli; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -106,6 +107,8 @@ public void testCreateAppDefaults() throws Exception { Assertions.assertTrue(project.resolve("gradlew").toFile().exists(), "Wrapper should exist by default"); + Assertions.assertTrue(Files.exists(project.resolve("src/main/docker")), + "Docker folder should exist by default"); String buildGradleContent = validateBasicGradleGroovyIdentifiers(project, CreateProjectHelper.DEFAULT_GROUP_ID, CreateProjectHelper.DEFAULT_ARTIFACT_ID, CreateProjectHelper.DEFAULT_VERSION); @@ -117,6 +120,17 @@ public void testCreateAppDefaults() throws Exception { CliDriver.invokeValidateBuild(project); } + @Test + public void testCreateAppWithoutDockerfiles() throws Exception { + CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "--no-dockerfiles", "-e", "-B", + "--verbose"); + 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); + Assertions.assertFalse(Files.exists(project.resolve("src/main/docker")), + "Docker folder should not exist"); + } + @Test public void testCreateAppDefaultsWithKotlinDSL() throws Exception { CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "--gradle-kotlin-dsl", "--verbose", "-e", diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectJBangTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectJBangTest.java index d085158c37492..5a48ea499205b 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectJBangTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectJBangTest.java @@ -51,7 +51,7 @@ public void testCreateAppDefaults() throws Exception { CreateProjectHelper.DEFAULT_ARTIFACT_ID, CreateProjectHelper.DEFAULT_VERSION); - Path javaMain = valdiateJBangSourcePackage(project, ""); // no package name + Path javaMain = validateJBangSourcePackage(project, ""); // no package name String source = CliDriver.readFileAsString(javaMain); Assertions.assertTrue(source.contains("quarkus-resteasy"), @@ -87,7 +87,7 @@ public void testCreateAppOverrides() throws Exception { "Wrapper should exist by default"); validateBasicIdentifiers(project, "silly", "my-project", "0.1.0"); - Path javaMain = valdiateJBangSourcePackage(project, ""); + Path javaMain = validateJBangSourcePackage(project, ""); String source = CliDriver.readFileAsString(javaMain); Assertions.assertTrue(source.contains("quarkus-reactive-routes"), @@ -112,7 +112,7 @@ public void testCreateCliDefaults() throws Exception { CreateProjectHelper.DEFAULT_ARTIFACT_ID, CreateProjectHelper.DEFAULT_VERSION); - Path javaMain = valdiateJBangSourcePackage(project, ""); // no package name + Path javaMain = validateJBangSourcePackage(project, ""); // no package name String source = CliDriver.readFileAsString(javaMain); Assertions.assertFalse(source.contains("quarkus-resteasy"), @@ -176,7 +176,7 @@ public void testCreateArgJava11() throws Exception { // We don't need to retest this, just need to make sure all the arguments were passed through Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); - Path javaMain = valdiateJBangSourcePackage(project, ""); // no package name + Path javaMain = validateJBangSourcePackage(project, ""); // no package name String source = CliDriver.readFileAsString(javaMain); Assertions.assertTrue(source.contains("//JAVA 11"), @@ -192,7 +192,7 @@ public void testCreateArgJava17() throws Exception { // We don't need to retest this, just need to make sure all the arguments were passed through Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); - Path javaMain = valdiateJBangSourcePackage(project, ""); // no package name + Path javaMain = validateJBangSourcePackage(project, ""); // no package name String source = CliDriver.readFileAsString(javaMain); Assertions.assertTrue(source.contains("//JAVA 17"), "Generated source should contain //JAVA 17. Found:\n" + source); @@ -206,7 +206,7 @@ void validateBasicIdentifiers(Path project, String group, String artifact, Strin // Should the version be stored in metadata anywhere? Is that useful for script management? } - Path valdiateJBangSourcePackage(Path project, String name) { + Path validateJBangSourcePackage(Path project, String name) { Path packagePath = project.resolve("src/" + name); Assertions.assertTrue(packagePath.toFile().exists(), "Package directory should exist: " + packagePath.toAbsolutePath().toString()); diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java index 4d74100b21eaa..ba57e5ff2a1d8 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java @@ -1,5 +1,6 @@ package io.quarkus.cli; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; @@ -48,6 +49,8 @@ public void testCreateAppDefaults() throws Exception { Assertions.assertTrue(project.resolve("mvnw").toFile().exists(), "Wrapper should exist by default"); + Assertions.assertTrue(Files.exists(project.resolve("src/main/docker")), + "Docker folder should exist by default"); String pomContent = validateBasicIdentifiers(CreateProjectHelper.DEFAULT_GROUP_ID, CreateProjectHelper.DEFAULT_ARTIFACT_ID, CreateProjectHelper.DEFAULT_VERSION); @@ -70,6 +73,17 @@ public void testCreateAppDefaults() throws Exception { "Response should reference --help:\n" + result); } + @Test + public void testCreateAppWithoutDockerfiles() throws Exception { + CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "--no-dockerfiles", "-e", "-B", + "--verbose"); + 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); + Assertions.assertFalse(Files.exists(project.resolve("src/main/docker")), + "Docker folder should not exist"); + } + @Test public void testCreateAppOverrides() throws Exception { Path nested = workspaceRoot.resolve("cli-nested");