Skip to content

Commit

Permalink
Quarkus and Spring Boot template (#206)
Browse files Browse the repository at this point in the history
* Add quarkus template

* Add spring boot template

* READMEs massaging

* Add the new templates to the examples release/test pipelines
  • Loading branch information
slinkydeveloper authored Oct 29, 2024
1 parent 8d4ab89 commit 7257197
Show file tree
Hide file tree
Showing 34 changed files with 1,858 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
files: |
java-hello-world-gradle.zip
java-hello-world-maven.zip
java-hello-world-maven-quarkus.zip
java-hello-world-maven-spring-boot.zip
kotlin-hello-world-gradle.zip
typescript-hello-world.zip
typescript-hello-world-lambda-cdk.zip
Expand Down
2 changes: 2 additions & 0 deletions .tools/prepare_release_zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ create_release_zip() {

create_release_zip templates/java-gradle java-hello-world-gradle
create_release_zip templates/java-maven java-hello-world-maven
create_release_zip templates/java-maven-spring-boot java-hello-world-maven-spring-boot
create_release_zip templates/java-maven-quarkus java-hello-world-maven-quarkus
create_release_zip templates/kotlin-gradle kotlin-hello-world-gradle
create_release_zip templates/typescript typescript-hello-world
create_release_zip templates/bun typescript-bun-hello-world
Expand Down
2 changes: 2 additions & 0 deletions .tools/run_jvm_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PROJECT_ROOT="$(dirname "$SELF_PATH")/.."

pushd $PROJECT_ROOT/templates/java-gradle && ./gradlew --console=plain check && popd
pushd $PROJECT_ROOT/templates/java-maven && mvn verify && popd
pushd $PROJECT_ROOT/templates/java-maven-quarkus && mvn verify && popd
pushd $PROJECT_ROOT/templates/java-maven-spring-boot && mvn verify && popd
pushd $PROJECT_ROOT/templates/kotlin-gradle && ./gradlew --console=plain check && popd
pushd $PROJECT_ROOT/templates/kotlin-gradle-lambda-cdk/lambda && ./gradlew --console=plain check && popd

Expand Down
2 changes: 2 additions & 0 deletions .tools/update_jvm_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function search_and_replace_version_maven() {

search_and_replace_version_gradle $PROJECT_ROOT/templates/java-gradle
search_and_replace_version_maven $PROJECT_ROOT/templates/java-maven
search_and_replace_version_maven $PROJECT_ROOT/templates/java-maven-quarkus
search_and_replace_version_maven $PROJECT_ROOT/templates/java-maven-spring-boot
search_and_replace_version_gradle $PROJECT_ROOT/templates/kotlin-gradle
search_and_replace_version_gradle $PROJECT_ROOT/templates/kotlin-gradle-lambda-cdk/lambda

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ challenges.

| Type | Name / Link |
|------------|------------------------------------------------------------------------------------------------|
| Templates | [Maven Template](templates/java-maven) |
| Templates | [Maven - Spring Boot Template](templates/java-maven-spring-boot) |
| Templates | [Maven - Quarkus Template](templates/java-maven-quarkus) |
| Templates | [Gradle Template](templates/java-gradle) |
| Basics | [Durable Execution, Event-processing, Virtual Objects](basics/basics-java) |
| Use Cases | [Sagas](patterns-use-cases/sagas/sagas-java) |
| Use Cases | [Payment Service](patterns-use-cases/payment-state-machine/payment-state-machine-java/) |
| Use Cases | [Payment Service](patterns-use-cases/payment-state-machine/payment-state-machine-java/) |
| Use Cases | [Async Tasks - Payments](patterns-use-cases/async-signals-payment/async-signals-payment-java/) |
| Patterns | [Spring & Spring JPA](patterns-use-cases/integrations/java-spring)
| Patterns | [Spring & Spring JPA](patterns-use-cases/integrations/java-spring) |
| End-to-End | [Food Ordering App](end-to-end-applications/java/food-ordering) |
| Tutorial | [Tour of Restate](tutorials/tour-of-restate-java/) |
| Templates | [Gradle Template](templates/java-gradle) |
| Templates | [Maven Template](templates/java-maven) |

### Kotlin

Expand Down
5 changes: 5 additions & 0 deletions templates/java-maven-quarkus/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
45 changes: 45 additions & 0 deletions templates/java-maven-quarkus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env

# Plugin directory
/.quarkus/cli/plugins/
# TLS Certificates
.certs/
1 change: 1 addition & 0 deletions templates/java-maven-quarkus/.mvn/wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven-wrapper.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.concurrent.ThreadLocalRandom;

public final class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "3.3.2";

private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE"));

public static void main(String[] args) {
log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION);

if (args.length != 2) {
System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing");
System.exit(1);
}

try {
log(" - Downloader started");
final URL wrapperUrl = URI.create(args[0]).toURL();
final String jarPath = args[1].replace("..", ""); // Sanitize path
final Path wrapperJarPath = Paths.get(jarPath).toAbsolutePath().normalize();
downloadFileFromURL(wrapperUrl, wrapperJarPath);
log("Done");
} catch (IOException e) {
System.err.println("- Error downloading: " + e.getMessage());
if (VERBOSE) {
e.printStackTrace();
}
System.exit(1);
}
}

private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath)
throws IOException {
log(" - Downloading to: " + wrapperJarPath);
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
final String username = System.getenv("MVNW_USERNAME");
final char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
Path temp = wrapperJarPath
.getParent()
.resolve(wrapperJarPath.getFileName() + "."
+ Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp");
try (InputStream inStream = wrapperUrl.openStream()) {
Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING);
Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING);
} finally {
Files.deleteIfExists(temp);
}
log(" - Downloader complete");
}

private static void log(String msg) {
if (VERBOSE) {
System.out.println(msg);
}
}

}
20 changes: 20 additions & 0 deletions templates/java-maven-quarkus/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
wrapperVersion=3.3.2
distributionType=source
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
15 changes: 15 additions & 0 deletions templates/java-maven-quarkus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Hello world - Quarkus example

Sample project configuration of a Restate service using the Java SDK and Quarkus.

Have a look at the [Java Quickstart guide](https://docs.restate.dev/get_started/quickstart?sdk=java) for more information on how to use this project.

## Starting the service

Check out https://quarkus.io/get-started/ to install quarkus.

To start the service, simply run:

```shell
$ quarkus dev
```
Loading

0 comments on commit 7257197

Please sign in to comment.