From 5e7d40d4dc153ccdcc62adf306fcb6912131bae7 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Tue, 4 Aug 2020 16:13:19 -0400 Subject: [PATCH] lambda codestart lambda finish fix amazon-lambda-http archetype azure functions codestart funqy codestarts codestart supports flags codestart doc codestart finished? SmartPomMergeCodestartFileStrategyHandler ignores non-maven comment smart revert SmartPomMergeCodestart add Andys suggestions fix codestarts --- .../buildtool/maven/base/pom.tpl.qute.xml | 9 +- .../buildtool/maven/codestart.yml | 3 + .../project/quarkus/base/README.tpl.qute.md | 12 ++ .../project/quarkus/codestart.yml | 5 + .../amazon-lambda-example/base/README.md | 3 + .../amazon-lambda-example/codestart.yml | 13 ++ .../amazon-lambda-example/java/payload.json | 3 + .../java/org/acme/lambda/GreetingLambda.java | 12 ++ .../src/main/java/org/acme/lambda/Person.java | 15 +++ .../org/acme/lambda/LambdaHandlerTestIT.java | 9 ++ .../org/acme/lambda/LambdaHandlerTest.java | 20 +++ .../java/src/test/resources/application.yml | 3 + .../base/README.md | 3 + .../base/azure-config/function.tpl.qute.json | 17 +++ .../base/azure-config/host.json | 3 + .../base/azure-config/local.settings.json | 7 ++ .../base/pom.tpl.qute.xml | 115 ++++++++++++++++++ .../main/resources/application.tpl.qute.yml | 1 + .../codestart.yml | 21 ++++ .../base/README.md | 3 + .../funqy-amazon-lambda-example/codestart.yml | 13 ++ .../java/payload.json | 1 + .../java/org/acme/funqy/GreetingFunction.java | 11 ++ .../src/main/java/org/acme/funqy/Person.java | 19 +++ .../java/org/acme/funqy/FunqyIT.java | 10 ++ .../java/resources/application.properties | 3 + .../test/java/org/acme/funqy/FunqyTest.java | 16 +++ .../java/src/test/resources/application.yml | 3 + .../funqy-http-example/base/README.md | 3 + .../funqy-http-example/codestart.yml | 10 ++ .../java/org/acme/funqy/GreetingFunction.java | 11 ++ .../src/main/java/org/acme/funqy/Person.java | 19 +++ .../java/org/acme/funqy/FunqyIT.java | 10 ++ .../test/java/org/acme/funqy/FunqyTest.java | 23 ++++ .../base/README.md | 9 ++ .../codestart.yml | 13 ++ .../funqy/cloudevent/CloudEventGreeting.java | 13 ++ .../org/acme/funqy/cloudevent/Person.java | 19 +++ .../src/main/k8s/funqy-service.tpl.qute.yaml | 13 ++ .../src/main/k8s/funqy-trigger.tpl.qute.yaml | 13 ++ .../org/acme/funqy/cloudevent/FunqyIT.java | 10 ++ .../org/acme/funqy/cloudevent/FunqyTest.java | 27 ++++ .../resources/archetype-resources/pom.xml | 22 ---- .../archetype-resources/src/assembly/zip.xml | 17 --- .../resources/META-INF/quarkus-extension.yaml | 1 + .../resources/META-INF/quarkus-extension.yaml | 1 + .../bindings/FunqyLambdaBuildStep.java | 6 + .../resources/META-INF/quarkus-extension.yaml | 1 + .../resources/META-INF/quarkus-extension.yaml | 1 + .../resources/META-INF/quarkus-extension.yaml | 15 +-- .../tools/codestarts/codestarts.adoc | 9 ++ .../codestarts/CodestartProcessor.java | 7 ++ .../codestarts/CodestartProjectRunTest.java | 31 ++++- 53 files changed, 606 insertions(+), 51 deletions(-) create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/base/README.md create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/codestart.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/payload.json create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/resources/application.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/README.md create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/function.tpl.qute.json create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/host.json create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/local.settings.json create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/pom.tpl.qute.xml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/codestart.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/base/README.md create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/codestart.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/payload.json create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/resources/application.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/base/README.md create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/codestart.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/GreetingFunction.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/Person.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/test/java/org/acme/funqy/FunqyTest.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/base/README.md create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/codestart.yml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java create mode 100644 devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java delete mode 100644 extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/src/assembly/zip.xml rename extensions/funqy/funqy-knative-events/runtime/src/{ => main}/resources/META-INF/quarkus-extension.yaml (50%) diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml index d5e9ca352e4fd..520907e9c6158 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/base/pom.tpl.qute.xml @@ -68,6 +68,11 @@ {quarkus.plugin.group-id} {quarkus.plugin.artifact-id} $\{quarkus-plugin.version} + {#if uberjar} + + true + + {/if} @@ -96,7 +101,7 @@ - +{#if supports.native} @@ -136,5 +141,5 @@ - +{/if} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml index 4abbd35982b87..ae576d6afef19 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/buildtool/maven/codestart.yml @@ -21,6 +21,9 @@ language: maven-surefire-plugin: version: 2.22.1 shared-data: + uberjar: false + supports: + native: true buildtool: build-dir: target guide: https://quarkus.io/guides/maven-tooling.html diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/base/README.tpl.qute.md b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/base/README.tpl.qute.md index 30df131a7ba8a..dc1223cd29009 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/base/README.tpl.qute.md +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/base/README.tpl.qute.md @@ -4,12 +4,18 @@ This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . +{#if supports.dev-mode} ## Running the application in dev mode You can run your application in dev mode that enables live coding using: ```shell script {buildtool.cmd.dev} ``` +{#else} +## Quarkus Dev Mode + +Quarkus dev mode is not supported for your extension combination. +{/if} ## Packaging and running the application @@ -26,6 +32,7 @@ If you want to build an _über-jar_, just add the `--uber-jar` option to the com The application is now runnable using `java -jar {buildtool.build-dir}/{project.artifact-id}-{project.version}-runner.jar`. +{#if supports.native} ## Creating a native executable You can create a native executable using: @@ -41,3 +48,8 @@ Or, if you don't have GraalVM installed, you can run the native executable build You can then execute your native executable with: `./{buildtool.build-dir}/{project.artifact-id}-{project.version}-runner` If you want to learn more about building native executables, please consult {buildtool.guide}. +{#else} +## Native Executable Support + +Your extension combination does not support native executable generation. +{/if} diff --git a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/codestart.yml index 3a46ae737c43f..95462524e44f0 100644 --- a/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/codestart.yml +++ b/devtools/platform-descriptor-json/src/main/resources/bundled-codestarts/project/quarkus/codestart.yml @@ -11,10 +11,15 @@ output-strategy: ".gitignore": append "src/main/resources/application.yml": smart-config-merge "src/main/resources/application.properties": forbidden + "src/test/resources/application.yml": smart-config-merge + "src/test/resources/application.properties": forbidden "*": fail-on-duplicate language: base: shared-data: + supports: + dev-mode: true + native: true project: group-id: org.acme artifact-id: quarkus-project diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/base/README.md new file mode 100644 index 0000000000000..39b893642bf0f --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/base/README.md @@ -0,0 +1,3 @@ +# Amazon Lambda Integration + +Guide: https://quarkus.io/guides/amazon-lambda diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/codestart.yml new file mode 100644 index 0000000000000..f5c43e276f501 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/codestart.yml @@ -0,0 +1,13 @@ +--- +name: amazon-lambda-example +ref: amazon-lambda +type: example +language: + base: + shared-data: + supports: + dev-mode: false + dependencies: + - io.quarkus:quarkus-amazon-lambda + test-dependencies: + - io.quarkus:quarkus-test-amazon-lambda diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/payload.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/payload.json new file mode 100644 index 0000000000000..decf49104ca4a --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/payload.json @@ -0,0 +1,3 @@ +{ + "name": "Bill" +} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java new file mode 100644 index 0000000000000..54397ca107a8a --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/GreetingLambda.java @@ -0,0 +1,12 @@ +package org.acme.lambda; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +public class GreetingLambda implements RequestHandler { + + @Override + public String handleRequest(Person input, Context context) { + return "Hello " + input.getName(); + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java new file mode 100644 index 0000000000000..6052788936db0 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/main/java/org/acme/lambda/Person.java @@ -0,0 +1,15 @@ +package org.acme.lambda; + +public class Person { + + private String name; + + public String getName() { + return name; + } + + public Person setName(String name) { + this.name = name; + return this; + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java new file mode 100644 index 0000000000000..477313b413ebd --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/native-test/java/org/acme/lambda/LambdaHandlerTestIT.java @@ -0,0 +1,9 @@ +package org.acme.lambda; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class LambdaHandlerTestIT extends LambdaHandlerTest { + + // Execute the same tests but in native mode. +} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java new file mode 100644 index 0000000000000..3ba4687dd2d6f --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/java/org/acme/lambda/LambdaHandlerTest.java @@ -0,0 +1,20 @@ +package org.acme.lambda; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import io.quarkus.amazon.lambda.test.LambdaClient; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class LambdaHandlerTest { + + @Test + public void testSimpleLambdaSuccess() throws Exception { + Person in = new Person(); + in.setName("Stu"); + String out = LambdaClient.invoke(String.class, in); + Assertions.assertEquals("Hello Stu", out); + } + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/resources/application.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/resources/application.yml new file mode 100644 index 0000000000000..6f64d4a18d957 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/amazon-lambda-example/java/src/test/resources/application.yml @@ -0,0 +1,3 @@ +quarkus.lambda.enable-polling-jvm-mode: true + + diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/README.md new file mode 100644 index 0000000000000..8c387b0d97cf4 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/README.md @@ -0,0 +1,3 @@ +# Azure Functions Integration + +Guide: https://quarkus.io/guides/azure-functions-http diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/function.tpl.qute.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/function.tpl.qute.json new file mode 100644 index 0000000000000..7e54800d07216 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/function.tpl.qute.json @@ -0,0 +1,17 @@ +{ + "scriptFile" : "../{project.artifact-id}-{project.version}-runner.jar", + "entryPoint" : "io.quarkus.azure.functions.resteasy.runtime.Function.run", + "bindings" : [ { + "type" : "httpTrigger", + "direction" : "in", + "name" : "req", + "route" : "{*path}", + "methods" : [ "GET", "POST", "HEAD", "PUT", "OPTIONS", "DELETE" ], + "dataType" : "binary", + "authLevel" : "ANONYMOUS" + }, { + "type" : "http", + "direction" : "out", + "name" : "$return" + } ] +} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/host.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/host.json new file mode 100644 index 0000000000000..a8fe8c4c8e513 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/host.json @@ -0,0 +1,3 @@ +{ + "version": "2.0" +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/local.settings.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/local.settings.json new file mode 100644 index 0000000000000..8804ca029cf22 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/azure-config/local.settings.json @@ -0,0 +1,7 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "", + "FUNCTIONS_WORKER_RUNTIME": "java" + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/pom.tpl.qute.xml b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/pom.tpl.qute.xml new file mode 100644 index 0000000000000..de7cb3cf2ff6b --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/pom.tpl.qute.xml @@ -0,0 +1,115 @@ + + + 1.3.2 + 3.1.0 + 1.8 + 1.8 + $\{artifactId}-{gen-info.time} + {app-region} + {resource-group} + {function} + $\{project.build.directory}/azure-functions/$\{functionAppName} + + + + + + com.microsoft.azure + azure-functions-maven-plugin + $\{azure.functions.maven.plugin.version} + + $\{functionResourceGroup} + $\{functionAppName} + $\{functionAppRegion} + + + + WEBSITE_RUN_FROM_PACKAGE + 1 + + + FUNCTIONS_EXTENSION_VERSION + ~2 + + + FUNCTIONS_WORKER_RUNTIME + java + + + + + + org.apache.maven.plugins + maven-resources-plugin + $\{resources-plugin.version} + + + + copy-base-azure-config + package + + copy-resources + + + true + $\{stagingDirectory} + + + $\{project.basedir}/azure-config + + host.json + local.settings.json + + + + + + + + copy-function-json + install + + copy-resources + + + true + $\{stagingDirectory}/$\{function} + + + $\{project.basedir}/azure-config + true + + function.json + + + + + + + + copy-uberjar + install + + copy-resources + + + true + $\{stagingDirectory} + + + $\{project.build.directory} + + $\{project.artifactId}-$\{project.version}-runner.jar + + + + + + + + + + diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml new file mode 100644 index 0000000000000..ab30f7b7aeed5 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/base/src/main/resources/application.tpl.qute.yml @@ -0,0 +1 @@ +quarkus.http.root-path: {root-context-path} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/codestart.yml new file mode 100644 index 0000000000000..723e95e028857 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/azure-functions-http-example/codestart.yml @@ -0,0 +1,21 @@ +--- +name: azure-functions-http-example +ref: azure-functions-http +type: example +language: + base: + shared-data: + uberjar: true + supports: + native: false + # /api is the default root context azure functions will prepend + root-context-path: "/api" + data: + app-region: + westus + resource-group: + java-functions-group + function: + greeting + dependencies: + - io.quarkus:quarkus-azure-functions-http diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/base/README.md new file mode 100644 index 0000000000000..308aac1714896 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/base/README.md @@ -0,0 +1,3 @@ +# Funqy Amazon Lambda Binding + +Guide: https://quarkus.io/guides/funqy-amazon-lambda diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/codestart.yml new file mode 100644 index 0000000000000..e7470dfa07674 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/codestart.yml @@ -0,0 +1,13 @@ +--- +name: funqy-amazon-lambda-example +ref: funqy-amazon-lambda +type: example +language: + base: + shared-data: + supports: + dev-mode: false + dependencies: + - io.quarkus:quarkus-funqy-amazon-lambda + test-dependencies: + - io.quarkus:quarkus-test-amazon-lambda diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/payload.json b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/payload.json new file mode 100644 index 0000000000000..af392298f6be0 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/payload.json @@ -0,0 +1 @@ +{ "name" : "Bill" } \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java new file mode 100644 index 0000000000000..e1d8a7f3a7bd4 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/GreetingFunction.java @@ -0,0 +1,11 @@ +package org.acme.funqy; + +import io.quarkus.funqy.Funq; + +public class GreetingFunction { + + @Funq + public String myFunqyGreeting(Person friend) { + return "Hello " + friend.getName(); + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java new file mode 100644 index 0000000000000..8c62c19a5c61a --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/main/java/org/acme/funqy/Person.java @@ -0,0 +1,19 @@ +package org.acme.funqy; + +public class Person { + private String name; + + public Person() {} + + public Person(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java new file mode 100644 index 0000000000000..cce22690603da --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java @@ -0,0 +1,10 @@ +package org.acme.funqy; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class FunqyIT extends FunqyTest { + + // Run the same tests + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties new file mode 100644 index 0000000000000..7d1a703249226 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/native-test/java/resources/application.properties @@ -0,0 +1,3 @@ +quarkus.lambda.enable-polling-jvm-mode=true + + diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java new file mode 100644 index 0000000000000..c689c8c74689a --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/java/org/acme/funqy/FunqyTest.java @@ -0,0 +1,16 @@ +package org.acme.funqy; + +import io.quarkus.amazon.lambda.test.LambdaClient; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@QuarkusTest +public class FunqyTest { + @Test + public void testSimpleLambdaSuccess() throws Exception { + Person friend = new Person("Bill"); + String out = LambdaClient.invoke(String.class, friend); + Assertions.assertEquals("Hello Bill", out); + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/resources/application.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/resources/application.yml new file mode 100644 index 0000000000000..6f64d4a18d957 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-amazon-lambda-example/java/src/test/resources/application.yml @@ -0,0 +1,3 @@ +quarkus.lambda.enable-polling-jvm-mode: true + + diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/base/README.md new file mode 100644 index 0000000000000..fa7bc9a7cb415 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/base/README.md @@ -0,0 +1,3 @@ +== Funqy HTTP Binding + +Guide: https://quarkus.io/guides/funqy-http diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/codestart.yml new file mode 100644 index 0000000000000..1528de53b86b0 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/codestart.yml @@ -0,0 +1,10 @@ +--- +name: funqy-http-example +ref: funqy-http +type: example +language: + base: + dependencies: + - io.quarkus:quarkus-funqy-http + test-dependencies: + - io.rest-assured:rest-assured diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/GreetingFunction.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/GreetingFunction.java new file mode 100644 index 0000000000000..e1d8a7f3a7bd4 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/GreetingFunction.java @@ -0,0 +1,11 @@ +package org.acme.funqy; + +import io.quarkus.funqy.Funq; + +public class GreetingFunction { + + @Funq + public String myFunqyGreeting(Person friend) { + return "Hello " + friend.getName(); + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/Person.java new file mode 100644 index 0000000000000..8c62c19a5c61a --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/main/java/org/acme/funqy/Person.java @@ -0,0 +1,19 @@ +package org.acme.funqy; + +public class Person { + private String name; + + public Person() {} + + public Person(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java new file mode 100644 index 0000000000000..cce22690603da --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/native-test/java/org/acme/funqy/FunqyIT.java @@ -0,0 +1,10 @@ +package org.acme.funqy; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class FunqyIT extends FunqyTest { + + // Run the same tests + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/test/java/org/acme/funqy/FunqyTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/test/java/org/acme/funqy/FunqyTest.java new file mode 100644 index 0000000000000..f25e65b60c715 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-http-example/java/src/test/java/org/acme/funqy/FunqyTest.java @@ -0,0 +1,23 @@ +package org.acme.funqy; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.equalTo; + +@QuarkusTest +public class FunqyTest { + + @Test + public void testGreeting() { + given() + .contentType("application/json") + .body("{\"name\": \"Bill\"}") + .post("/myFunqyGreeting") + .then() + .statusCode(200) + .body(equalTo("\"Hello Bill\"")); + } + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/base/README.md b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/base/README.md new file mode 100644 index 0000000000000..0ce44d4e9900f --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/base/README.md @@ -0,0 +1,9 @@ +# Funqy Knative Events Binding + +You'll need to read the guide to learn how to deploy and run this codestart within a full Knative Kubernetes or Openshift +environment. + +Guide: https://quarkus.io/guides/funqy-knative-events + +This codestart is incomplete until you specify your docker.io account name within `src/main/k8s/funqy-service.yaml`. + diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/codestart.yml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/codestart.yml new file mode 100644 index 0000000000000..06a85fe5213b5 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/codestart.yml @@ -0,0 +1,13 @@ +--- +name: funqy-knative-events-example +ref: funqy-knative-events +type: example +language: + base: + data: + k8s-service-name: funqy-knative-events-codestart + docker-io-account: yourAccountName + dependencies: + - io.quarkus:quarkus-funqy-knative-events + test-dependencies: + - io.rest-assured:rest-assured diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java new file mode 100644 index 0000000000000..7756cf108ad74 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/CloudEventGreeting.java @@ -0,0 +1,13 @@ +package org.acme.funqy.cloudevent; + +import io.quarkus.funqy.Funq; +import org.jboss.logging.Logger; + +public class CloudEventGreeting { + private static final Logger log = Logger.getLogger(CloudEventGreeting.class); + + @Funq + public void myCloudEventGreeting(Person input) { + log.info("Hello " + input.getName()); + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java new file mode 100644 index 0000000000000..bab8889318cff --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/java/org/acme/funqy/cloudevent/Person.java @@ -0,0 +1,19 @@ +package org.acme.funqy.cloudevent; + +public class Person { + private String name; + + public Person() {} + + public Person(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml new file mode 100644 index 0000000000000..e8aab28354388 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-service.tpl.qute.yaml @@ -0,0 +1,13 @@ +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: + name: {k8s-service-name} +spec: + template: + metadata: + name: {k8s-service-name}-v1 + annotations: + autoscaling.knative.dev/target: "1" + spec: + containers: + - image: docker.io/{docker-io-account}/{k8s-service-name} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml new file mode 100644 index 0000000000000..ec88843f0718e --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/main/k8s/funqy-trigger.tpl.qute.yaml @@ -0,0 +1,13 @@ +apiVersion: eventing.knative.dev/v1alpha1 +kind: Trigger +metadata: + name: myCloudEventGreeting +spec: + filter: + attributes: + type: myCloudEventGreeting + subscriber: + ref: + apiVersion: serving.knative.dev/v1 + kind: Service + name: {k8s-service-name} \ No newline at end of file diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java new file mode 100644 index 0000000000000..b80ffdb2372f7 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/native-test/java/org/acme/funqy/cloudevent/FunqyIT.java @@ -0,0 +1,10 @@ +package org.acme.funqy.cloudevent; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class FunqyIT extends FunqyTest { + + // Run the same tests + +} diff --git a/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java new file mode 100644 index 0000000000000..d8c0d6595ce38 --- /dev/null +++ b/devtools/platform-descriptor-json/src/main/resources/codestarts/funqy-knative-events-example/java/src/test/java/org/acme/funqy/cloudevent/FunqyTest.java @@ -0,0 +1,27 @@ +package org.acme.funqy.cloudevent; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +import java.util.UUID; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; + +@QuarkusTest +public class FunqyTest { + + @Test + public void testCloudEvent() { + RestAssured.given().contentType("application/json") + .header("ce-id", UUID.randomUUID().toString()) + .header("ce-type", "myCloudEventGreeting") + .header("ce-source", "test") + .body("{ \"name\": \"Bill\" }") + .post("/") + .then().statusCode(204); + } +} diff --git a/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/pom.xml b/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/pom.xml index 24ece3b6b497b..822c195a32cc1 100644 --- a/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/pom.xml +++ b/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/pom.xml @@ -125,28 +125,6 @@ - - org.apache.maven.plugins - maven-assembly-plugin - \${assembly-plugin.version} - - - zip-assembly - package - - single - - - function - - src${file.separator}assembly${file.separator}zip.xml - - false - false - - - - diff --git a/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/src/assembly/zip.xml b/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/src/assembly/zip.xml deleted file mode 100644 index 54d667c9b7dc9..0000000000000 --- a/extensions/amazon-lambda-http/maven-archetype/src/main/resources/archetype-resources/src/assembly/zip.xml +++ /dev/null @@ -1,17 +0,0 @@ - - lambda-package - - zip - - false - - - ${project.build.directory}${file.separator}${artifactId}-${version}-runner - / - bootstrap - 755 - - - diff --git a/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml index ee534812a3b46..8bbe9ad8ffbd1 100644 --- a/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -9,3 +9,4 @@ metadata: - "cloud" guide: "https://quarkus.io/guides/amazon-lambda" status: "preview" + codestart: "amazon-lambda" diff --git a/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 7bb126a9fd9e0..efa1b945a9e7c 100644 --- a/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/azure-functions-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -8,3 +8,4 @@ metadata: - "cloud" guide: "https://quarkus.io/guides/azure-functions-http" status: "preview" + codestart: "azure-functions-http" diff --git a/extensions/funqy/funqy-amazon-lambda/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/FunqyLambdaBuildStep.java b/extensions/funqy/funqy-amazon-lambda/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/FunqyLambdaBuildStep.java index 54a84d5360126..f6b374d81e519 100644 --- a/extensions/funqy/funqy-amazon-lambda/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/FunqyLambdaBuildStep.java +++ b/extensions/funqy/funqy-amazon-lambda/deployment/src/main/java/io/quarkus/funqy/deployment/bindings/FunqyLambdaBuildStep.java @@ -10,8 +10,10 @@ import io.quarkus.amazon.lambda.runtime.LambdaBuildTimeConfig; import io.quarkus.arc.deployment.BeanContainerBuildItem; import io.quarkus.builder.item.SimpleBuildItem; +import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.LaunchModeBuildItem; import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.builditem.ShutdownContextBuildItem; @@ -24,6 +26,8 @@ public class FunqyLambdaBuildStep { + public static final String FUNQY_AMAZON_LAMBDA = "funqy-amazon-lambda"; + public static final class RuntimeComplete extends SimpleBuildItem { } @@ -31,11 +35,13 @@ public static final class RuntimeComplete extends SimpleBuildItem { @Record(STATIC_INIT) public void init(List functions, FunqyLambdaBindingRecorder recorder, + BuildProducer feature, Optional hasFunctions, LambdaObjectMapperInitializedBuildItem mapperDependency, BeanContainerBuildItem beanContainer) throws Exception { if (!hasFunctions.isPresent() || hasFunctions.get() == null) return; + feature.produce(new FeatureBuildItem(FUNQY_AMAZON_LAMBDA)); recorder.init(beanContainer.getValue()); } diff --git a/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 01ada2300684a..8cd0a6f53524c 100644 --- a/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-amazon-lambda/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -11,3 +11,4 @@ metadata: categories: - "cloud" status: "experimental" + codestart: "funqy-amazon-lambda" diff --git a/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 70fc02bb1066c..0e9b705c0856b 100644 --- a/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-http/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -9,3 +9,4 @@ metadata: categories: - "cloud" status: "experimental" + codestart: "funqy-http" diff --git a/extensions/funqy/funqy-knative-events/runtime/src/resources/META-INF/quarkus-extension.yaml b/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 50% rename from extensions/funqy/funqy-knative-events/runtime/src/resources/META-INF/quarkus-extension.yaml rename to extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml index c274a89653a79..12945960016c7 100644 --- a/extensions/funqy/funqy-knative-events/runtime/src/resources/META-INF/quarkus-extension.yaml +++ b/extensions/funqy/funqy-knative-events/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -2,11 +2,12 @@ name: "Funqy Knative Events Binding" metadata: keywords: - - "knative" - - "function" - - "funqy" - - "cloud event" - categories: - - "cloud" + - "knative" + - "function" + - "funqy" + - "cloud event" guide: "https://quarkus.io/guides/funqy-knative-events" - status: "experimental" \ No newline at end of file + categories: + - "cloud" + status: "experimental" + codestart: "funqy-knative-events" \ No newline at end of file diff --git a/independent-projects/tools/codestarts/codestarts.adoc b/independent-projects/tools/codestarts/codestarts.adoc index a37e0b774e8bf..d0caef85605ca 100644 --- a/independent-projects/tools/codestarts/codestarts.adoc +++ b/independent-projects/tools/codestarts/codestarts.adoc @@ -88,6 +88,15 @@ spec: test-dependencies: a list of test dependencies to add when this is selected ---- +=== Common Shared and Built In Data + +There's a few built `shared-data` variables that you should know about +* `supports.native` can be toggled if your example does not support native. This will omit README and relevant build scripts +* `supports.dev-mode` can be toggled if your example does not support Quarkus devmode. This will omit README information +* `uberjar` can be toggled to switch on the uberjar flag in the pom.xml +* `gen-info.time` is hardcoded to current time milliseconds of when the codestart was generated. Useful if you need a random value in your codestart. + + === Naming Convention for files * `.tpl.qute` will be processed with Qute (`.tpl.qute` will be removed from the output file name). diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProcessor.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProcessor.java index a22b5cd30f590..6ff7d33c00460 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProcessor.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/CodestartProcessor.java @@ -14,6 +14,7 @@ import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -43,6 +44,7 @@ final class CodestartProcessor { } void process(final Codestart codestart) throws IOException { + addBuiltinData(); resourceLoader.loadResourceAsPath(codestart.getResourceDir(), p -> { final Path baseDir = p.resolve(BASE_LANGUAGE); final Path languageDir = p.resolve(languageName); @@ -54,6 +56,11 @@ void process(final Codestart codestart) throws IOException { }); } + void addBuiltinData() { + // needed for azure functions codestart + data.put("gen-info", Collections.singletonMap("time", System.currentTimeMillis())); + } + void processCodestartDir(final Path sourceDirectory, final Map finalData) { final Collection sources = findSources(sourceDirectory); for (Path sourcePath : sources) { diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java index 9fb35d1c75a00..c9dc0bf3611c0 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/CodestartProjectRunTest.java @@ -1,6 +1,7 @@ package io.quarkus.devtools.codestarts; import static io.quarkus.devtools.codestarts.QuarkusCodestarts.inputBuilder; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.nio.file.Path; @@ -8,15 +9,19 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import com.google.common.collect.Sets; + import io.quarkus.devtools.PlatformAwareTestBase; import io.quarkus.devtools.ProjectTestUtil; @@ -25,6 +30,13 @@ class CodestartProjectRunTest extends PlatformAwareTestBase { private static final Path testDirPath = Paths.get("target/codestarts-run-test"); + private static final Set RUN_MANUALLY_CODESTARTS = Sets.newHashSet( + "azure-functions-http-example"); + private static final Set RUN_ALONE_CODESTARTS = Sets.newHashSet( + "funqy-amazon-lambda-example", + "funqy-knative-events-example", + "amazon-lambda-example"); + @BeforeAll static void setUp() throws IOException { ProjectTestUtil.delete(testDirPath.toFile()); @@ -43,9 +55,15 @@ private Stream provideGenerateCombinations() throws IOException { .loadCodestartsFromExtensions(QuarkusCodestarts.resourceLoader(getPlatformDescriptor())).stream() .filter(c -> c.getSpec().isExample()) .map(Codestart::getName) + .filter(c -> !RUN_MANUALLY_CODESTARTS.contains(c)) + .collect(Collectors.toList()); + final List> runAlone = examples.stream().filter(RUN_ALONE_CODESTARTS::contains) + .map(Collections::singletonList).collect(Collectors.toList()); + final List runTogether = examples.stream().filter(o -> !RUN_ALONE_CODESTARTS.contains(o)) .collect(Collectors.toList()); return Stream.of("java", "kotlin", "scala") - .flatMap(l -> Stream.of(Collections.emptyList(), examples).map(c -> Arguments.of(l, c))); + .flatMap(l -> Stream.concat(Stream.of(runTogether, Collections.emptyList()), Stream.of(runAlone.toArray())) + .map(c -> Arguments.of(l, c))); } @ParameterizedTest @@ -60,6 +78,11 @@ public void generateGradleProjectRun(String language, List codestarts) t generateProjectRunTests("gradle", language, codestarts); } + @Test + public void generateAzureFunctionsHttpExampleProjectRun() throws Exception { + generateProjectRunTests("maven", "java", Collections.singletonList("azure-functions-http-example")); + } + private void generateProjectRunTests(String buildtool, String language, List codestarts) throws Exception { String name = "project-" + buildtool + "-" + language; if (codestarts.isEmpty()) { @@ -78,6 +101,8 @@ private void generateProjectRunTests(String buildtool, String language, List