diff --git a/examples/quickstarts/helidon-quickstart-mp/build.gradle b/examples/quickstarts/helidon-quickstart-mp/build.gradle index bfe18663..075d063e 100644 --- a/examples/quickstarts/helidon-quickstart-mp/build.gradle +++ b/examples/quickstarts/helidon-quickstart-mp/build.gradle @@ -18,6 +18,7 @@ plugins { id 'java' id 'org.kordamp.gradle.jandex' version '2.0.0' id 'application' + id("org.graalvm.buildtools.native") version "0.11.0" } group = 'io.helidon.examples' @@ -53,12 +54,16 @@ dependencies { runtimeOnly 'io.smallrye:jandex' runtimeOnly 'jakarta.activation:jakarta.activation-api' + runtimeOnly 'io.helidon.logging:helidon-logging-jul' testImplementation 'io.helidon.microprofile.testing:helidon-microprofile-testing-junit5' testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.hamcrest:hamcrest-all' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + nativeImageClasspath "io.helidon.integrations.graal:helidon-graal-native-image-extension" + nativeImageClasspath "io.helidon.integrations.graal:helidon-mp-graal-native-image-extension" } test { diff --git a/examples/quickstarts/helidon-quickstart-se/build.gradle b/examples/quickstarts/helidon-quickstart-se/build.gradle index 57e4db27..00b53202 100644 --- a/examples/quickstarts/helidon-quickstart-se/build.gradle +++ b/examples/quickstarts/helidon-quickstart-se/build.gradle @@ -17,6 +17,7 @@ plugins { id 'java' id 'application' + id("org.graalvm.buildtools.native") version "0.11.0" } group = 'io.helidon.examples' @@ -56,6 +57,7 @@ dependencies { implementation 'io.helidon.webserver.observe:helidon-webserver-observe-metrics' implementation 'io.helidon.config:helidon-config-yaml' implementation 'io.helidon.health:helidon-health-checks' + runtimeOnly 'io.helidon.logging:helidon-logging-jul' testImplementation 'io.helidon.webserver.testing.junit5:helidon-webserver-testing-junit5' testImplementation 'org.junit.jupiter:junit-jupiter' @@ -64,6 +66,7 @@ dependencies { testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + nativeImageClasspath "io.helidon.integrations.graal:helidon-graal-native-image-extension" } // define a custom task to copy all dependencies in the runtime classpath diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/build.gradle b/examples/quickstarts/helidon-standalone-quickstart-mp/build.gradle new file mode 100644 index 00000000..da61672b --- /dev/null +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/build.gradle @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2018, 2025 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id 'java' + id 'org.kordamp.gradle.jandex' version '2.0.0' + id 'application' + id("org.graalvm.buildtools.native") version "0.11.0" +} + +group = 'io.helidon.examples' +version = '1.0-SNAPSHOT' + +description = """helidon-quickstart-mp""" + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +ext { + helidonversion = '4.2.6' + mainClass='io.helidon.microprofile.cdi.Main' +} + +repositories { + mavenCentral() + mavenLocal() + gradlePluginPortal() +} + +dependencies { + // import Helidon BOM + implementation enforcedPlatform("io.helidon:helidon-dependencies:${project.helidonversion}") + implementation 'io.helidon.microprofile.bundles:helidon-microprofile' + implementation 'org.glassfish.jersey.media:jersey-media-json-binding' + + runtimeOnly 'io.smallrye:jandex' + runtimeOnly 'jakarta.activation:jakarta.activation-api' + + testImplementation 'io.helidon.microprofile.testing:helidon-microprofile-testing-junit5' + testImplementation 'org.junit.jupiter:junit-jupiter' + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testImplementation 'org.hamcrest:hamcrest-all' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + nativeImageClasspath "io.helidon.integrations.graal:helidon-graal-native-image-extension" + nativeImageClasspath "io.helidon.integrations.graal:helidon-mp-graal-native-image-extension" +} + +test { + useJUnitPlatform() +} + +// define a custom task to copy all dependencies in the runtime classpath +// into build/libs/libs +// uses built-in Copy +task copyLibs(type: Copy) { + from configurations.runtimeClasspath + into 'build/libs/libs' +} + +// add it as a dependency of built-in task 'assemble' +copyLibs.dependsOn jar +assemble.dependsOn copyLibs + +// default jar configuration +// set the main classpath +// add each jar under build/libs/libs into the classpath +jar { + archiveFileName = "${project.name}.jar" + manifest { + attributes ('Main-Class': "${project.mainClass}" , + 'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ') + ) + } +} + +application { + mainClass = "${project.mainClass}" +} + +// This is a work-around for running unit tests. +// Gradle places resource files under ${buildDir}/resources. In order for +// beans.xml to get picked up by CDI it must be co-located with the classes. +// So we move it before running tests. +// In either case it ends up AOK in the final jar artifact +task moveBeansXML { + doLast { + ant.move file: "${buildDir}/resources/main/META-INF/beans.xml", + todir: "${buildDir}/classes/java/main/META-INF" + } +} +compileTestJava.dependsOn "jandex" +jar.dependsOn "jandex" +test.dependsOn moveBeansXML +run.dependsOn moveBeansXML diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/settings.gradle b/examples/quickstarts/helidon-standalone-quickstart-mp/settings.gradle new file mode 100644 index 00000000..440cdc92 --- /dev/null +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/settings.gradle @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +rootProject.name = 'helidon-standalone-quickstart-mp' diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/build.gradle b/examples/quickstarts/helidon-standalone-quickstart-se/build.gradle new file mode 100644 index 00000000..00b53202 --- /dev/null +++ b/examples/quickstarts/helidon-standalone-quickstart-se/build.gradle @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018, 2025 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id 'java' + id 'application' + id("org.graalvm.buildtools.native") version "0.11.0" +} + +group = 'io.helidon.examples' +version = '1.0-SNAPSHOT' + +description = """helidon-quickstart-se""" + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +ext { + helidonversion = '4.2.6' + mainClass='io.helidon.examples.quickstart.se.Main' +} + +test { + useJUnitPlatform() +} + +repositories { + mavenCentral() + mavenLocal() +} + +dependencies { + // import Helidon BOM + implementation enforcedPlatform("io.helidon:helidon-dependencies:${project.helidonversion}") + implementation 'io.helidon.webserver:helidon-webserver' + implementation 'io.helidon.http.media:helidon-http-media-jsonp' + implementation 'io.helidon.webserver.observe:helidon-webserver-observe-health' + implementation 'io.helidon.webserver.observe:helidon-webserver-observe-metrics' + implementation 'io.helidon.config:helidon-config-yaml' + implementation 'io.helidon.health:helidon-health-checks' + runtimeOnly 'io.helidon.logging:helidon-logging-jul' + + testImplementation 'io.helidon.webserver.testing.junit5:helidon-webserver-testing-junit5' + testImplementation 'org.junit.jupiter:junit-jupiter' + testImplementation 'io.helidon.webclient:helidon-webclient' + testImplementation 'org.hamcrest:hamcrest-all' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + nativeImageClasspath "io.helidon.integrations.graal:helidon-graal-native-image-extension" +} + +// define a custom task to copy all dependencies in the runtime classpath +// into build/libs/libs +// uses built-in Copy +task copyLibs(type: Copy) { + from configurations.runtimeClasspath + into 'build/libs/libs' +} + +// add it as a dependency of built-in task 'assemble' +copyLibs.dependsOn jar +assemble.dependsOn copyLibs + +// default jar configuration +// set the main classpath +// add each jar under build/libs/libs into the classpath +jar { + archiveFileName = "${project.name}.jar" + manifest { + attributes ('Main-Class': "${project.mainClass}", + 'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ') + ) + } +} + +application { + mainClass = "${project.mainClass}" +} + diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/settings.gradle b/examples/quickstarts/helidon-standalone-quickstart-se/settings.gradle new file mode 100644 index 00000000..48bf4d35 --- /dev/null +++ b/examples/quickstarts/helidon-standalone-quickstart-se/settings.gradle @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +rootProject.name = 'helidon-standalone-quickstart-se'