Skip to content

Commit

Permalink
Merge pull request #11243 from patriot1burke/cloud-codestarts
Browse files Browse the repository at this point in the history
cloud codestarts
  • Loading branch information
patriot1burke authored Aug 17, 2020
2 parents 3bd79a0 + 5e7d40d commit 7e10261
Show file tree
Hide file tree
Showing 53 changed files with 606 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
<groupId>{quarkus.plugin.group-id}</groupId>
<artifactId>{quarkus.plugin.artifact-id}</artifactId>
<version>$\{quarkus-plugin.version}</version>
{#if uberjar}
<configuration>
<uberJar>true</uberJar>
</configuration>
{/if}
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -96,7 +101,7 @@
</plugin>
</plugins>
</build>

{#if supports.native}
<profiles>
<!-- Use this profile to build a native executable using GraalVM -->
<profile>
Expand Down Expand Up @@ -136,5 +141,5 @@
</build>
</profile>
</profiles>

{/if}
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Amazon Lambda Integration

Guide: https://quarkus.io/guides/amazon-lambda
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Bill"
}
Original file line number Diff line number Diff line change
@@ -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<Person, String> {

@Override
public String handleRequest(Person input, Context context) {
return "Hello " + input.getName();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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.
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
quarkus.lambda.enable-polling-jvm-mode: true


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Azure Functions Integration

Guide: https://quarkus.io/guides/azure-functions-http
Original file line number Diff line number Diff line change
@@ -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"
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "java"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<azure.functions.maven.plugin.version>1.3.2</azure.functions.maven.plugin.version>
<resources-plugin.version>3.1.0</resources-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<functionAppName>$\{artifactId}-{gen-info.time}</functionAppName>
<functionAppRegion>{app-region}</functionAppRegion>
<functionResourceGroup>{resource-group}</functionResourceGroup>
<function>{function}</function>
<stagingDirectory>$\{project.build.directory}/azure-functions/$\{functionAppName}</stagingDirectory>
</properties>
<build>
<plugins>
<!-- we only use azure plugin to deploy to Azure.
The directory structure is set up through various plugins in this pom -->
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>$\{azure.functions.maven.plugin.version}</version>
<configuration>
<resourceGroup>$\{functionResourceGroup}</resourceGroup>
<appName>$\{functionAppName}</appName>
<region>$\{functionAppRegion}</region>
<appSettings>
<!-- Run Azure Function from package file by default -->
<property>
<name>WEBSITE_RUN_FROM_PACKAGE</name>
<value>1</value>
</property>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~2</value>
</property>
<property>
<name>FUNCTIONS_WORKER_RUNTIME</name>
<value>java</value>
</property>
</appSettings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>$\{resources-plugin.version}</version>
<executions>
<!-- add azure required json files
to Azure staging directory -->
<execution>
<id>copy-base-azure-config</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>$\{stagingDirectory}</outputDirectory>
<resources>
<resource>
<directory>$\{project.basedir}/azure-config</directory>
<includes>
<include>host.json</include>
<include>local.settings.json</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<!-- copy unpacked function.json into Azure staging directory -->
<execution>
<id>copy-function-json</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>$\{stagingDirectory}/$\{function}</outputDirectory>
<resources>
<resource>
<directory>$\{project.basedir}/azure-config</directory>
<filtering>true</filtering>
<includes>
<include>function.json</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<!-- copy the uber-jar into Azure staging directory -->
<execution>
<id>copy-uberjar</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>$\{stagingDirectory}</outputDirectory>
<resources>
<resource>
<directory>$\{project.build.directory}</directory>
<includes>
<include>$\{project.artifactId}-$\{project.version}-runner.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quarkus.http.root-path: {root-context-path}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Funqy Amazon Lambda Binding

Guide: https://quarkus.io/guides/funqy-amazon-lambda
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "name" : "Bill" }
Original file line number Diff line number Diff line change
@@ -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();
}
}
Loading

0 comments on commit 7e10261

Please sign in to comment.