Skip to content

Commit

Permalink
feature: Integrate kuksa-java-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
wba2hi committed Jan 8, 2025
1 parent aca06f8 commit d7226d8
Show file tree
Hide file tree
Showing 21 changed files with 930 additions and 268 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Release SDK

concurrency: production

on:
push:
tags:
- 'release/v*'

jobs:
deployment:
if: github.repository == 'eclipse-kuksa/kuksa-java-sdk'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Project
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Set Release Version
run: ./gradlew setReleaseVersion # Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command

- name: Publish Library
env:
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
run: ./gradlew publishAllPublicationsToOSSRHReleaseRepository
40 changes: 40 additions & 0 deletions .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy Snapshot SDK

concurrency: snapshot

on:
push:
branches:
- main

jobs:
deployment:
if: github.repository == 'eclipse-velocitas/vehicle-app-java-sdk'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Project
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Update Version
run: npm run bump-release # Updates the semantic version depending on the last commits e.g. feature / bugfix

- name: Set Snapshot Version
run: ./gradlew setSnapshotVersion # Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command

- name: Publish Library
env:
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
run: ./gradlew publishAllPublicationsToOSSRHSnapshotRepository
3 changes: 3 additions & 0 deletions .github/workflows/localversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ jobs:
!.github
!.git
!.gitignore
!node_modules
!package.json
!package-lock.json
107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,67 @@ This project is in incubation status. Not all required functionality might be mi
## Overview

The Velocitas Vehicle App Java SDK provides functionality to ease the implementation of Automotive
Java Applications.
Java Applications.

## Databroker Interaction

build.gradle.kts
```kotlin
dependencies {
implementation("org.eclipse.kuksa:vss-core:<VERSION>")
implementation("org.eclipse.velocitas:vehicle-app-java-sdk:<VERSION>")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:<VERSION>")
}
```

Using protocol kuksa.val.v1:

```kotlin
val managedChannel = ManagedChannelBuilder.forAddress("localhost", 55555)
.usePlaintext()
.build()
val dataBrokerConnector = DataBrokerConnector(managedChannel)

coroutineScope {
launch {
val dataBrokerConnection = dataBrokerConnector.connect()

println("Using protocol kuksa.val.v1")
println("Setting Vehicle.Speed in Databroker to 80")
val vssPath = "Vehicle.Speed"

val dataPoint = Datapoint.newBuilder().setFloat(80.0F).build()
val updateRequest = UpdateRequest(vssPath, dataPoint)
dataBrokerConnection.update(updateRequest)

println("Reading Vehicle.Speed from Databroker")
val fetchRequest = FetchRequest(vssPath)
val response = dataBrokerConnection.fetch(fetchRequest)
println("GetResponse: " + response)

println("Observe Vehicle.Speed")
val subscribeRequest = SubscribeRequest("Vehicle.Speed")
dataBrokerConnection.subscribe(
subscribeRequest,
object : VssPathListener {
override fun onEntryChanged(entryUpdates: List<KuksaValV1.EntryUpdate>) {
entryUpdates.forEach { entryUpdate ->
val vehicleSpeedValue = entryUpdate.entry.value.float
// handle change
println("newSpeed(v1): $vehicleSpeedValue")
}
}

override fun onError(throwable: Throwable) {
// handle error
}
}
)
}
}
```

Using protocol kuksa.val.v2

## VSS Model Generation

Expand Down Expand Up @@ -88,3 +147,49 @@ data class VssSpeed @JvmOverloads constructor(
get() = VssVehicle::class
}
```

*Using the Vehicle Model to interact with the Databroker*

> [!IMPORTANT]
> The Vehicle Model only supports kuksa.val.v1 protocol
```kotlin
val managedChannel = ManagedChannelBuilder.forAddress("localhost", 55555)
.usePlaintext()
.build()
val dataBrokerConnector = DataBrokerConnector(managedChannel)

coroutineScope {
launch {
val dataBrokerConnection = dataBrokerConnector.connect()

println("Using protocol kuksa.val.v1 with VehicleModel")
println("Setting Vehicle.Speed in Databroker to 100")
val vssSpeedWithValue = VssVehicle.VssSpeed(100.0F)
val updateRequest = VssNodeUpdateRequest(vssSpeedWithValue)
dataBrokerConnection.update(updateRequest)

println("Reading Vehicle.Speed from Databroker")
val vssSpeed = VssVehicle.VssSpeed()
val fetchRequest = VssNodeFetchRequest(vssSpeed)
val response = dataBrokerConnection.fetch(fetchRequest)
println("VssSpeed: " + response)

println("Observe Vehicle.Speed")
val subscribeRequest = VssNodeSubscribeRequest(vssSpeed)
dataBrokerConnection.subscribe(
subscribeRequest,
object : VssNodeListener<VssVehicle.VssSpeed> {
override fun onError(throwable: Throwable) {
// handle error
}

override fun onNodeChanged(vssNode: VssVehicle.VssSpeed) {
// handle VssSpeed change
println("newSpeed(VehicleModel): $vssNode")
}
}
)
}
}
```
36 changes: 36 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Releasing a version

Releasing a version is mostly automated. However since the CHANGELOG.md + version information are part of the git
history and need to be committed, some manual steps are still needed. These steps are also there to check for errors
which may have been made in the git history via
the [Conventionalcommits standard](https://www.conventionalcommits.org/en/v1.0.0/) format.

The NPM package [Commit-And-Tag](https://github.com/absolute-version/commit-and-tag-version) is used to streamline the
release process.

### Preparing a release

The following convenience NPM scripts are available for use here:

```
"scripts": {
"tag-release": "npx commit-and-tag-version --packageFiles version.txt -t release/v --skip.commit=true --skip.changelog=true --skip.bump=true",
"commit-release": "npx commit-and-tag-version --packageFiles version.txt --bumpFiles version.txt --skip.tag=true",
"bump-release": "npx commit-and-tag-version --packageFiles version.txt --bumpFiles version.txt --skip.tag=true --skip.commit=true",
"generate-changelog": "npx commit-and-tag-version --skip.bump=true --skip.commit=true --skip.tag=true"
}
```

1) Execute `npm run commit-release` to prepare the release. This will automatically bump the version to the next correct
semantic version, create a CHANGELOG.md file and make a commit.
2) Check the CHANGELOG.md for wrong entries which may have been committed in the history - We are human after all! :)
3) Push the commit, create a PR and wait for the merge.

### Deploying a release

1) Execute `npm run tag-release` on the main branch after the above merge.
2) Push the tag via 'git push origin feature-x'. "Origin" may differ if working with forks. The command should be shown
in the terminal after step 1. A push of a release tag with the correct format will automatically trigger an official
release GitHub workflow.
3) Check if the artifacts were uploaded successfully to the Nexus repository.
4) Close the uploaded staging repository and check the activity tab if all steps were successful.
50 changes: 0 additions & 50 deletions docs/sdk-architecture-grpc.puml

This file was deleted.

20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "vehicle-app-java-sdk",
"main": "index.js",
"repository": "https://github.com/eclipse-velocitas/vehicle-app-java-sdk.git",
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"commit-and-tag-version": "^11.3.0",
"husky": "^8.0.3"
},
"scripts": {
"postinstall": "husky install",
"tag-release": "npx commit-and-tag-version --packageFiles version.txt -t release/v --skip.commit=true --skip.changelog=true --skip.bump=true",
"commit-release": "npx commit-and-tag-version --packageFiles version.txt -t release/v --bumpFiles version.txt --skip.tag=true",
"bump-release": "npx commit-and-tag-version --packageFiles version.txt -t release/v --bumpFiles version.txt --skip.tag=true --skip.commit=true",
"generate-changelog": "npx commit-and-tag-version --skip.bump=true -t release/v --skip.commit=true --skip.tag=true"
}
}
4 changes: 1 addition & 3 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ dependencies {

implementation(project(":sdk"))

implementation("org.eclipse.kuksa:vss-core:0.3.1-SNAPSHOT") {
isChanging = true
}
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
}

vssProcessor {
Expand Down
71 changes: 71 additions & 0 deletions samples/gradle.lockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.google.android:annotations:4.1.1.4=runtimeClasspath
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,runtimeClasspath
com.google.code.gson:gson:2.10.1=kspKotlinProcessorClasspath,runtimeClasspath
com.google.devtools.ksp:symbol-processing-api:1.9.22-1.0.17=kspKotlinProcessorClasspath
com.google.devtools.ksp:symbol-processing-api:2.0.0-1.0.24=kotlinCompilerPluginClasspathMain,kspPluginClasspath
com.google.devtools.ksp:symbol-processing:2.0.0-1.0.24=kotlinCompilerPluginClasspathMain,kspPluginClasspath
com.google.errorprone:error_prone_annotations:2.23.0=compileClasspath,runtimeClasspath
com.google.guava:failureaccess:1.0.1=runtimeClasspath
com.google.guava:guava:32.1.3-android=runtimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=runtimeClasspath
com.google.protobuf:protobuf-javalite:3.25.1=compileClasspath
com.google.protobuf:protobuf-javalite:3.25.3=runtimeClasspath
com.google.protobuf:protobuf-kotlin-lite:3.25.3=runtimeClasspath
com.squareup.okio:okio-jvm:3.4.0=runtimeClasspath
com.squareup.okio:okio:3.4.0=runtimeClasspath
com.squareup:kotlinpoet-jvm:1.16.0=kspKotlinProcessorClasspath
com.squareup:kotlinpoet-ksp:1.16.0=kspKotlinProcessorClasspath
com.squareup:kotlinpoet:1.16.0=kspKotlinProcessorClasspath
io.grpc:grpc-api:1.65.1=compileClasspath,runtimeClasspath
io.grpc:grpc-context:1.65.1=runtimeClasspath
io.grpc:grpc-core:1.65.1=runtimeClasspath
io.grpc:grpc-kotlin-stub:1.4.1=runtimeClasspath
io.grpc:grpc-okhttp:1.65.1=runtimeClasspath
io.grpc:grpc-protobuf-lite:1.65.1=compileClasspath,runtimeClasspath
io.grpc:grpc-stub:1.65.1=runtimeClasspath
io.grpc:grpc-util:1.65.1=runtimeClasspath
io.perfmark:perfmark-api:0.26.0=runtimeClasspath
javax.annotation:javax.annotation-api:1.3.2=runtimeClasspath
org.apache.tomcat:annotations-api:6.0.53=runtimeClasspath
org.checkerframework:checker-qual:3.37.0=runtimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.23=runtimeClasspath
org.eclipse.kuksa:kuksa-java-sdk:0.3.1-SNAPSHOT=compileClasspath,runtimeClasspath
org.eclipse.kuksa:vss-core:0.2.1=kspKotlinProcessorClasspath
org.eclipse.kuksa:vss-core:0.3.1-SNAPSHOT=compileClasspath,runtimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath
org.jetbrains.kotlin:kotlin-build-common:2.0.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-api:2.0.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-impl:2.0.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath
org.jetbrains.kotlin:kotlin-compiler-runner:2.0.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-client:2.0.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath
org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath
org.jetbrains.kotlin:kotlin-reflect:1.9.22=runtimeClasspath
org.jetbrains.kotlin:kotlin-reflect:2.0.0=kspKotlinProcessorClasspath
org.jetbrains.kotlin:kotlin-script-runtime:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain
org.jetbrains.kotlin:kotlin-scripting-common:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain
org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain
org.jetbrains.kotlin:kotlin-scripting-jvm:2.0.0=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0=kotlinCompilerPluginClasspathMain,kspPluginClasspath,runtimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0=runtimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0=kspKotlinProcessorClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0=runtimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0=kspKotlinProcessorClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.0.0=compileClasspath,kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kspKotlinProcessorClasspath,kspPluginClasspath,runtimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1=compileClasspath,runtimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=kotlinBuildToolsApiClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.1=compileClasspath,runtimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1=compileClasspath,runtimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.3=kotlinCompilerPluginClasspathMain,kspPluginClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.3=kotlinCompilerPluginClasspathMain,kspPluginClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3=kotlinCompilerPluginClasspathMain,kspPluginClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.3=kotlinCompilerPluginClasspathMain,kspPluginClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3=kotlinCompilerPluginClasspathMain,kspPluginClasspath
org.jetbrains:annotations:13.0=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kspKotlinProcessorClasspath,kspPluginClasspath
org.jetbrains:annotations:23.0.0=compileClasspath,runtimeClasspath
empty=kotlinScriptDefExtensions,testKotlinScriptDefExtensions
Loading

0 comments on commit d7226d8

Please sign in to comment.