Skip to content

Commit 4d16f1c

Browse files
authored
feat(sdk): setup gradle project structure (#4)
relates to STACKITTPR-302
1 parent 80cab44 commit 4d16f1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+12753
-11337
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches: ["main"]
8+
9+
jobs:
10+
main:
11+
name: CI
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
version: [11, 17, 21]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Install java
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin'
24+
java-version: '${{ matrix.version }}'
25+
cache: 'gradle'
26+
27+
- name: Check code format
28+
run: ./gradlew spotlessCheck
29+
30+
- name: Test
31+
run: make test
32+
33+
- name: Build
34+
run: make build
35+
36+
- name: Publish to local maven repo
37+
run: make install
38+

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ gradle-app.setting
3838
# Eclipse Core
3939
.project
4040
# JDT-specific (Eclipse Java Development Tools)
41-
.classpath
41+
.classpath
42+
43+
*.iws
44+
*.iml
45+
*.ipr
46+
.idea

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build:
2+
@./gradlew build
3+
4+
fmt:
5+
@./gradlew spotlessApply
6+
7+
test:
8+
@./gradlew test
9+
10+
install:
11+
@./gradlew publishToMavenLocal

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ This repository contains the STACKIT SDKs for Java.
1515

1616
If you encounter any issues or have suggestions for improvements, please open an issue in the repository or create a ticket in the [STACKIT Help Center](https://support.stackit.cloud/).
1717

18+
## Development
19+
20+
Building the STACKIT Java SDK requires:
21+
1. Java SDK (version 11 to 21 should be supported) installed on your system
22+
23+
In case you want to open the project in your preferred IDE, run `./gradlew idea` or `./gradlew eclipse` beforehand.
24+
25+
## Installation
26+
27+
To install the API client library to your local Maven repository, simply execute:
28+
29+
```bash
30+
./gradlew publishToMavenLocal
31+
```
1832

1933
## Release creation
2034

2135
See the [release documentation](./RELEASE.md) for further information.
2236

2337
## License
2438

25-
Apache 2.0
39+
Apache 2.0

build.gradle

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
plugins {
2+
id 'java'
3+
id 'maven-publish'
4+
id 'idea'
5+
id 'eclipse'
6+
7+
id 'com.diffplug.spotless' version '6.21.0'
8+
}
9+
10+
11+
allprojects {
12+
apply plugin: 'com.diffplug.spotless'
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
javadoc {
19+
options.tags = [
20+
"http.response.details:a:Http Response Details"
21+
]
22+
}
23+
24+
sourceCompatibility = JavaVersion.VERSION_1_8
25+
targetCompatibility = JavaVersion.VERSION_1_8
26+
27+
tasks.withType(JavaCompile) {
28+
options.encoding = 'UTF-8'
29+
}
30+
31+
spotless {
32+
groovyGradle {
33+
greclipse()
34+
35+
trimTrailingWhitespace()
36+
indentWithTabs()
37+
endWithNewline()
38+
}
39+
format 'misc', {
40+
target '.gitattributes', '.gitignore'
41+
42+
trimTrailingWhitespace()
43+
indentWithTabs()
44+
endWithNewline()
45+
}
46+
java {
47+
googleJavaFormat().aosp()
48+
49+
removeUnusedImports()
50+
importOrder()
51+
formatAnnotations()
52+
trimTrailingWhitespace()
53+
indentWithTabs()
54+
endWithNewline()
55+
}
56+
}
57+
}
58+
59+
subprojects {
60+
apply plugin: 'java'
61+
apply plugin: 'maven-publish'
62+
apply plugin: 'idea'
63+
apply plugin: 'eclipse'
64+
65+
group = 'cloud.stackit'
66+
version = 'SNAPSHOT'
67+
68+
afterEvaluate { project ->
69+
// only apply to service sub-projects and core
70+
if (project.path.startsWith(':services:') || project.name == "core" ) {
71+
72+
// override the version of each service with the ones obtained from the VERSION files
73+
def versionFile = project.file("VERSION")
74+
if (versionFile.exists()) {
75+
try {
76+
version = versionFile.text.trim()
77+
} catch (IOException e) {
78+
logger.error("Could not read VERSION file for project '${project.name}': ${e.message}")
79+
}
80+
} else {
81+
logger.warn("VERSION file not found in project '${project.name}'. Skipping version setting.")
82+
}
83+
84+
85+
publishing {
86+
publications {
87+
maven(MavenPublication) {
88+
artifactId = "stackit-sdk-${project.name}"
89+
from components.java
90+
91+
pom {
92+
name.set(project.name)
93+
description.set("STACKIT Java SDK for the ${project.name} service")
94+
url.set("https://github.com/stackitcloud/stackit-sdk-java/tree/main/services/${rootProject.name}")
95+
licenses {
96+
license {
97+
name.set("Apache License, Version 2.0")
98+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
99+
}
100+
}
101+
developers {
102+
developer {
103+
id.set("stackitcloud") // TODO: not clear which value must be placed here, check this when setting up publishment to Maven Central
104+
name.set("STACKIT Developer Tools")
105+
email.set("[email protected]")
106+
}
107+
}
108+
scm {
109+
connection.set("scm:git:git://github.com/stackitcloud/${rootProject.name}.git")
110+
developerConnection.set("scm:git:ssh://github.com/stackitcloud/${rootProject.name}.git")
111+
url.set("https://github.com/stackitcloud/${rootProject.name}")
112+
}
113+
}
114+
}
115+
}
116+
repositories {
117+
mavenLocal()
118+
}
119+
}
120+
}
121+
}
122+
123+
tasks.withType(Test) {
124+
// Enable JUnit 5 (Gradle 4.6+).
125+
useJUnitPlatform()
126+
127+
// Always run tests, even when nothing changed.
128+
dependsOn 'cleanTest'
129+
130+
// Show test results.
131+
testLogging {
132+
events "passed", "skipped", "failed"
133+
}
134+
}
135+
136+
dependencies {
137+
if (project.path != ':core') {
138+
// prevent circular dependency
139+
implementation project(':core')
140+
}
141+
}
142+
}

core/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1-SNAPSHOT

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package cloud.stackit.sdk.core;
2+
3+
public class CoreDummy {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
implementation project (':services:resourcemanager')
3+
}

0 commit comments

Comments
 (0)