Skip to content

Commit 197f09b

Browse files
committed
feat: java example
1 parent 91959a1 commit 197f09b

12 files changed

Lines changed: 569 additions & 0 deletions

File tree

.github/workflows/java.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Java CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: [backend/java/**, .github/workflows/java.yaml]
7+
pull_request:
8+
branches: [main]
9+
paths: [backend/java/**, .github/workflows/java.yaml]
10+
11+
jobs:
12+
backend-java:
13+
name: Backend Java
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: backend/java
18+
steps:
19+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
20+
21+
- name: Set up Java
22+
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v4.4.0
23+
with:
24+
distribution: temurin
25+
java-version: '17'
26+
cache: gradle
27+
28+
- name: Lint
29+
run: ./gradlew --no-daemon spotlessCheck
30+
31+
- name: Build
32+
run: ./gradlew --no-daemon build

backend/java/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SUMUP_API_KEY=
2+
SUMUP_MERCHANT_CODE=
3+
PORT=3004

backend/java/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.gradle/
2+
build/
3+
4+
# IDEs
5+
.idea/
6+
*.iml
7+
*.ipr
8+
*.iws
9+
.vscode/
10+
.project
11+
.classpath
12+
.settings/
13+
nbproject/
14+
15+
# OS/editor noise
16+
.DS_Store
17+
*.swp
18+
*.swo
19+
*~
20+
21+
# Logs
22+
*.log
23+
24+
# Local env
25+
.env
26+
27+
# JVM output
28+
out/
29+
bin/

backend/java/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Java example
2+
3+
## Setup
4+
5+
```sh
6+
export SUMUP_API_KEY="your_api_key"
7+
export SUMUP_MERCHANT_CODE="your_merchant_code"
8+
```
9+
10+
## Run
11+
12+
```sh
13+
gradle run
14+
```
15+
16+
## Test
17+
18+
```sh
19+
curl -X POST http://localhost:8080/checkouts \
20+
-H "Content-Type: application/json" \
21+
-d '{"amount": 10.0}'
22+
```

backend/java/build.gradle

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
plugins {
2+
id 'application'
3+
id 'com.diffplug.spotless' version '6.25.0'
4+
}
5+
6+
group = 'com.sumup.examples'
7+
version = '1.0.0'
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
implementation 'com.sumup:sumup:0.0.5'
15+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
16+
}
17+
18+
application {
19+
mainClass = 'com.sumup.examples.Server'
20+
}
21+
22+
java {
23+
toolchain {
24+
languageVersion = JavaLanguageVersion.of(17)
25+
}
26+
}
27+
28+
spotless {
29+
java {
30+
target 'src/**/*.java'
31+
googleJavaFormat('1.24.0')
32+
}
33+
format 'misc', {
34+
target '*.gradle', '*.md'
35+
trimTrailingWhitespace()
36+
endWithNewline()
37+
}
38+
}

backend/java/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Force Gradle to use JDK 17 for tools like Spotless.
2+
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
44.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

backend/java/gradlew

Lines changed: 248 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)