diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/codestart.yml b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/codestart.yml index ea3caa8044bc1..8e29627a8d10a 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/codestart.yml +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/buildtool/maven/codestart.yml @@ -15,6 +15,6 @@ language: package: package package-uber-jar: package -Dquarkus.package.type=uber-jar package-legacy-jar: package -Dquarkus.package.type=legacy-jar - package-native: package -Pnative - package-native-container: package -Pnative -Dquarkus.native.container-build=true + package-native: package -Dnative + package-native-container: package -Dnative -Dquarkus.native.container-build=true build-ci: verify -B diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/Dockerfile-layout.include.qute b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/Dockerfile-layout.include.qute index 666b5bcc45d08..d407dc64296f9 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/Dockerfile-layout.include.qute +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/Dockerfile-layout.include.qute @@ -90,3 +90,5 @@ ENV AB_JOLOKIA_OFF="" {/if} ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native index 5f84d15ec5541..dd2a17091aa4a 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native @@ -24,4 +24,4 @@ COPY --chown=1001:root {buildtool.build-dir}/*-runner /work/application EXPOSE 8080 USER 1001 -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native-micro b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native-micro index 1209d56d5c35c..fe30d4da1cf5d 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native-micro +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/tooling/dockerfiles/base/src/main/docker/Dockerfile.tpl.qute.native-micro @@ -27,4 +27,4 @@ COPY --chown=1001:root {buildtool.build-dir}/*-runner /work/application EXPOSE 8080 USER 1001 -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartGenerationTest.java b/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartGenerationTest.java index cc668750782cf..c900d70881334 100644 --- a/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartGenerationTest.java +++ b/independent-projects/tools/devtools-testing/src/test/java/io/quarkus/devtools/codestarts/quarkus/QuarkusCodestartGenerationTest.java @@ -6,7 +6,6 @@ import static io.quarkus.devtools.testing.FakeExtensionCatalog.FAKE_QUARKUS_CODESTART_CATALOG; import static io.quarkus.devtools.testing.SnapshotTesting.assertThatMatchSnapshot; import static io.quarkus.devtools.testing.SnapshotTesting.checkContains; -import static io.quarkus.devtools.testing.SnapshotTesting.checkNotContains; import static org.assertj.core.api.Assertions.assertThat; import java.nio.file.Path; @@ -210,6 +209,25 @@ void generateMavenDefaultJava(TestInfo testInfo) throws Throwable { assertThatMatchSnapshot(testInfo, projectDir, "src/test/java/org/acme/GreetingResourceIT.java"); } + @Test + void generateGradleDefaultJava(TestInfo testInfo) throws Throwable { + final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() + .buildTool(BuildTool.GRADLE) + .addData(getGenerationTestInputData()) + .build(); + final Path projectDir = testDirPath.resolve("gradle-default-java"); + getCatalog().createProject(input).generate(projectDir); + + checkGradle(projectDir); + checkReadme(projectDir); + checkDockerfiles(projectDir, BuildTool.GRADLE); + checkConfigProperties(projectDir); + + assertThatMatchSnapshot(testInfo, projectDir, "src/main/java/org/acme/GreetingResource.java"); + assertThatMatchSnapshot(testInfo, projectDir, "src/test/java/org/acme/GreetingResourceTest.java"); + assertThatMatchSnapshot(testInfo, projectDir, "src/native-test/java/org/acme/GreetingResourceIT.java"); + } + @Test void generateMavenResteasyJava(TestInfo testInfo) throws Throwable { final QuarkusCodestartProjectInput input = QuarkusCodestartProjectInput.builder() @@ -299,7 +317,7 @@ private void checkDockerfilesWithMaven(Path projectDir) { .satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm")) .satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))//TODO: make a test for java17 .satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\"")) - .satisfies(checkNotContains("ENTRYPOINT")); + .satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.legacy-jar")).exists() .satisfies(checkContains("./mvnw package -Dquarkus.package.type=legacy-jar")) .satisfies(checkContains("docker build -f src/main/docker/Dockerfile.legacy-jar")) @@ -307,15 +325,15 @@ private void checkDockerfilesWithMaven(Path projectDir) { .satisfies(checkContains("EXPOSE 8080")) .satisfies(checkContains("USER 185")) .satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\"")) - .satisfies(checkNotContains("ENTRYPOINT")); + .satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.native-micro")).exists() - .satisfies(checkContains("./mvnw package -Pnative")) + .satisfies(checkContains("./mvnw package -Dnative")) .satisfies(checkContains("quay.io/quarkus/quarkus-micro-image:2.0")) - .satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); + .satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists() - .satisfies(checkContains("./mvnw package -Pnative")) + .satisfies(checkContains("./mvnw package -Dnative")) .satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal")) - .satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); + .satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); } private void checkDockerfilesWithGradle(Path projectDir) { @@ -323,23 +341,25 @@ private void checkDockerfilesWithGradle(Path projectDir) { assertThat(projectDir.resolve("src/main/docker/Dockerfile.jvm")).exists() .satisfies(checkContains("./gradlew build")) .satisfies(checkContains("docker build -f src/main/docker/Dockerfile.jvm")) - .satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.8")) - .satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless")) - .satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]")); + .satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16"))//TODO: make a test for java17 + .satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\"")) + .satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.legacy-jar")).exists() .satisfies(checkContains("./gradlew build -Dquarkus.package.type=legacy-jar")) .satisfies(checkContains("docker build -f src/main/docker/Dockerfile.legacy-jar")) - .satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal:8.8")) - .satisfies(checkContains("ARG JAVA_PACKAGE=java-11-openjdk-headless")) - .satisfies(checkContains("ENTRYPOINT [ \"/deployments/run-java.sh\" ]")); + .satisfies(checkContains("registry.access.redhat.com/ubi8/openjdk-11:1.16")) + .satisfies(checkContains("EXPOSE 8080")) + .satisfies(checkContains("USER 185")) + .satisfies(checkContains("ENV JAVA_APP_JAR=\"/deployments/quarkus-run.jar\"")) + .satisfies(checkContains("ENTRYPOINT [ \"/opt/jboss/container/java/run/run-java.sh\" ]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.native-micro")).exists() .satisfies(checkContains("./gradlew build -Dquarkus.package.type=native")) .satisfies(checkContains("quay.io/quarkus/quarkus-micro-image:2.0")) - .satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); + .satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); assertThat(projectDir.resolve("src/main/docker/Dockerfile.native")).exists() .satisfies(checkContains("./gradlew build -Dquarkus.package.type=native")) .satisfies(checkContains("registry.access.redhat.com/ubi8/ubi-minimal")) - .satisfies(checkContains("CMD [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); + .satisfies(checkContains("ENTRYPOINT [\"./application\", \"-Dquarkus.http.host=0.0.0.0\"]")); } private void checkConfigProperties(Path projectDir) { diff --git a/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateDefault/README.md b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateDefault/README.md index e088c8db5b9c5..46cfc840738fa 100644 --- a/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateDefault/README.md +++ b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateDefault/README.md @@ -35,12 +35,12 @@ The application, packaged as an _über-jar_, is now runnable using `java -jar ta You can create a native executable using: ```shell script -mvn package -Pnative +mvn package -Dnative ``` Or, if you don't have GraalVM installed, you can run the native executable build in a container using: ```shell script -mvn package -Pnative -Dquarkus.native.container-build=true +mvn package -Dnative -Dquarkus.native.container-build=true ``` You can then execute your native executable with: `./target/test-codestart-1.0.0-codestart-runner` diff --git a/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_main_java_org_acme_GreetingResource.java b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_main_java_org_acme_GreetingResource.java new file mode 100644 index 0000000000000..2a175fd5de8df --- /dev/null +++ b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_main_java_org_acme_GreetingResource.java @@ -0,0 +1,16 @@ +package org.acme; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class GreetingResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "Hello from RESTEasy Reactive"; + } +} \ No newline at end of file diff --git a/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_native-test_java_org_acme_GreetingResourceIT.java b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_native-test_java_org_acme_GreetingResourceIT.java new file mode 100644 index 0000000000000..9e18707971142 --- /dev/null +++ b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_native-test_java_org_acme_GreetingResourceIT.java @@ -0,0 +1,9 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class GreetingResourceIT extends GreetingResourceTest { + + // Execute the same tests but in native mode. +} diff --git a/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_test_java_org_acme_GreetingResourceTest.java b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_test_java_org_acme_GreetingResourceTest.java new file mode 100644 index 0000000000000..3a0d47d75f33e --- /dev/null +++ b/independent-projects/tools/devtools-testing/src/test/resources/__snapshots__/QuarkusCodestartGenerationTest/generateGradleDefaultJava/src_test_java_org_acme_GreetingResourceTest.java @@ -0,0 +1,21 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +public class GreetingResourceTest { + + @Test + public void testHelloEndpoint() { + given() + .when().get("/hello") + .then() + .statusCode(200) + .body(is("Hello from RESTEasy Reactive")); + } + +} \ No newline at end of file diff --git a/integration-tests/elasticsearch-rest-client/README.md b/integration-tests/elasticsearch-rest-client/README.md index be6118104536f..44dc7926105f7 100644 --- a/integration-tests/elasticsearch-rest-client/README.md +++ b/integration-tests/elasticsearch-rest-client/README.md @@ -21,9 +21,9 @@ The application is now runnable using `java -jar target/quarkus-integration-test ## Creating a native executable -You can create a native executable using: `./mvnw package -Pnative`. +You can create a native executable using: `./mvnw package -Dnative`. -Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Dnative -Dquarkus.native.container-build=true`. You can then execute your native executable with: `./target/quarkus-integration-test-elasticsearch-rest-client-1.0-SNAPSHOT-runner` diff --git a/integration-tests/elasticsearch-rest-high-level-client/README.md b/integration-tests/elasticsearch-rest-high-level-client/README.md index 36badb910e1a7..db869a7f3aebf 100644 --- a/integration-tests/elasticsearch-rest-high-level-client/README.md +++ b/integration-tests/elasticsearch-rest-high-level-client/README.md @@ -21,9 +21,9 @@ The application is now runnable using `java -jar target/quarkus-integration-test ## Creating a native executable -You can create a native executable using: `./mvnw package -Pnative`. +You can create a native executable using: `./mvnw package -Dnative`. -Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Dnative -Dquarkus.native.container-build=true`. You can then execute your native executable with: `./target/quarkus-integration-test-elasticsearch-rest-high-level-client-1.0-SNAPSHOT-runner` diff --git a/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java b/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java index fae54a7e9e36c..6515d475fdb24 100644 --- a/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java +++ b/integration-tests/maven/src/test/java/io/quarkus/maven/it/NativeImageIT.java @@ -35,8 +35,8 @@ public void testJavaLibraryPathAtRuntime() throws Exception { final File testDir = initProject("projects/native-image-app", "projects/native-image-app-output"); final RunningInvoker running = new RunningInvoker(testDir, false); - // trigger mvn package -Pnative -Dquarkus.ssl.native=true - final String[] mvnArgs = new String[] { "package", "-DskipTests", "-Pnative", "-Dquarkus.ssl.native=true" }; + // trigger mvn package -Dnative -Dquarkus.ssl.native=true + final String[] mvnArgs = new String[] { "package", "-DskipTests", "-Dnative", "-Dquarkus.ssl.native=true" }; final MavenProcessInvocationResult result = running.execute(Arrays.asList(mvnArgs), Collections.emptyMap()); await().atMost(10, TimeUnit.MINUTES).until(() -> result.getProcess() != null && !result.getProcess().isAlive()); final String processLog = running.log(); diff --git a/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native b/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native index 1adf4168f242d..3e3e2fa098b96 100644 --- a/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native +++ b/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native @@ -3,7 +3,7 @@ # # Before building the container image run: # -# ./mvnw package -Pnative +# ./mvnw package -Dnative # # Then, build the image with: # diff --git a/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native-micro b/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native-micro index 40afb1a22a0dd..f2380078856e4 100644 --- a/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native-micro +++ b/integration-tests/maven/src/test/resources-filtered/projects/codegen-config-factory/app/src/main/docker/Dockerfile.native-micro @@ -6,7 +6,7 @@ # # Before building the container image run: # -# ./mvnw package -Pnative +# ./mvnw package -Dnative # # Then, build the image with: # diff --git a/integration-tests/maven/src/test/resources-filtered/projects/native-image-app/pom.xml b/integration-tests/maven/src/test/resources-filtered/projects/native-image-app/pom.xml index f098cc9edf751..c0de7ebee4af0 100644 --- a/integration-tests/maven/src/test/resources-filtered/projects/native-image-app/pom.xml +++ b/integration-tests/maven/src/test/resources-filtered/projects/native-image-app/pom.xml @@ -51,6 +51,11 @@ native + + + native + + native