Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --no-dockerfiles command shortcut #34734

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -46,6 +50,7 @@ public String toString() {
return "CodeGenerationGroup ["
+ "includeCode=" + includeCode
+ ", includeWrapper=" + includeWrapper
+ ", includeDockerfiles=" + includeDockerfiles
+ ", packageName=" + packageName
+ "]";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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);
Expand All @@ -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());
Expand Down
14 changes: 14 additions & 0 deletions devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down
Loading