-
Notifications
You must be signed in to change notification settings - Fork 0
feat(sdk): setup gradle project structure #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main"] | ||
|
||
jobs: | ||
main: | ||
name: CI | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [11, 17, 21] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '${{ matrix.version }}' | ||
cache: 'gradle' | ||
|
||
- name: Check code format | ||
run: ./gradlew spotlessCheck | ||
|
||
- name: Test | ||
run: make test | ||
|
||
- name: Build | ||
run: make build | ||
|
||
- name: Publish to local maven repo | ||
run: make install | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
build: | ||
@./gradlew build | ||
|
||
fmt: | ||
@./gradlew spotlessApply | ||
|
||
test: | ||
@./gradlew test | ||
|
||
install: | ||
@./gradlew publishToMavenLocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
plugins { | ||
id 'java' | ||
id 'maven-publish' | ||
id 'idea' | ||
id 'eclipse' | ||
|
||
id 'com.diffplug.spotless' version '6.21.0' | ||
} | ||
|
||
|
||
allprojects { | ||
apply plugin: 'com.diffplug.spotless' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
javadoc { | ||
options.tags = [ | ||
"http.response.details:a:Http Response Details" | ||
] | ||
} | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
tasks.withType(JavaCompile) { | ||
options.encoding = 'UTF-8' | ||
} | ||
|
||
spotless { | ||
groovyGradle { | ||
greclipse() | ||
|
||
trimTrailingWhitespace() | ||
indentWithTabs() | ||
endWithNewline() | ||
} | ||
format 'misc', { | ||
target '.gitattributes', '.gitignore' | ||
|
||
trimTrailingWhitespace() | ||
indentWithTabs() | ||
endWithNewline() | ||
} | ||
java { | ||
googleJavaFormat().aosp() | ||
|
||
removeUnusedImports() | ||
importOrder() | ||
formatAnnotations() | ||
trimTrailingWhitespace() | ||
indentWithTabs() | ||
endWithNewline() | ||
marceljk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
||
subprojects { | ||
apply plugin: 'java' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'idea' | ||
apply plugin: 'eclipse' | ||
|
||
group = 'cloud.stackit' | ||
version = 'SNAPSHOT' | ||
|
||
afterEvaluate { project -> | ||
// only apply to service sub-projects and core | ||
if (project.path.startsWith(':services:') || project.name == "core" ) { | ||
|
||
// override the version of each service with the ones obtained from the VERSION files | ||
def versionFile = project.file("VERSION") | ||
if (versionFile.exists()) { | ||
try { | ||
version = versionFile.text.trim() | ||
} catch (IOException e) { | ||
logger.error("Could not read VERSION file for project '${project.name}': ${e.message}") | ||
} | ||
} else { | ||
logger.warn("VERSION file not found in project '${project.name}'. Skipping version setting.") | ||
} | ||
|
||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
artifactId = "stackit-sdk-${project.name}" | ||
from components.java | ||
|
||
pom { | ||
name.set(project.name) | ||
description.set("STACKIT Java SDK for the ${project.name} service") | ||
url.set("https://github.com/stackitcloud/stackit-sdk-java/tree/main/services/${rootProject.name}") | ||
licenses { | ||
license { | ||
name.set("Apache License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("stackitcloud") // TODO: not clear which value must be placed here, check this when setting up publishment to Maven Central | ||
name.set("STACKIT Developer Tools") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:git://github.com/stackitcloud/${rootProject.name}.git") | ||
developerConnection.set("scm:git:ssh://github.com/stackitcloud/${rootProject.name}.git") | ||
url.set("https://github.com/stackitcloud/${rootProject.name}") | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenLocal() | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType(Test) { | ||
// Enable JUnit 5 (Gradle 4.6+). | ||
useJUnitPlatform() | ||
|
||
// Always run tests, even when nothing changed. | ||
dependsOn 'cleanTest' | ||
|
||
// Show test results. | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
} | ||
} | ||
|
||
dependencies { | ||
if (project.path != ':core') { | ||
// prevent circular dependency | ||
implementation project(':core') | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1-SNAPSHOT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package cloud.stackit.sdk.core; | ||
|
||
public class CoreDummy {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
implementation project (':services:resourcemanager') | ||
} |
39 changes: 39 additions & 0 deletions
39
...ager/src/main/java/cloud/stackit/sdk/resourcemanager/examples/ResourcemanagerExample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cloud.stackit.sdk.resourcemanager.examples; | ||
|
||
import cloud.stackit.sdk.resourcemanager.ApiClient; | ||
import cloud.stackit.sdk.resourcemanager.ApiException; | ||
import cloud.stackit.sdk.resourcemanager.api.DefaultApi; | ||
import cloud.stackit.sdk.resourcemanager.model.CreateFolderPayload; | ||
import cloud.stackit.sdk.resourcemanager.model.CreateProjectPayload; | ||
import cloud.stackit.sdk.resourcemanager.model.FolderResponse; | ||
import cloud.stackit.sdk.resourcemanager.model.Project; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
class ResourcemanagerExample { | ||
public static void main(String[] args) { | ||
ApiClient apiClient = new ApiClient(); | ||
DefaultApi resourceManagerApi = new DefaultApi(apiClient); | ||
|
||
// replace this with something useful for real use | ||
UUID containerParentId = UUID.randomUUID(); | ||
|
||
try { | ||
/* create a project */ | ||
Project project = | ||
resourceManagerApi.createProject( | ||
new CreateProjectPayload() | ||
.containerParentId(containerParentId.toString()) | ||
.labels(Map.ofEntries(Map.entry("foo", "bar")))); | ||
|
||
/* create a folder */ | ||
FolderResponse folder = | ||
resourceManagerApi.createFolder( | ||
new CreateFolderPayload() | ||
.containerParentId(containerParentId.toString()) | ||
.labels(Map.ofEntries(Map.entry("foo", "bar")))); | ||
} catch (ApiException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1-SNAPSHOT |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.