Skip to content
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

V2 #26

Closed
wants to merge 29 commits into from
Closed

V2 #26

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/create-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Create docs

on:
push:
branches:
- main
- v2

jobs:
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
cache: gradle


- name: Setup SSH Keys and known_hosts to access submodules
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.GH_SSH_PRIVATE }}"

- name: Update submodules
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: git submodule update --init --recursive

- name: Create docs
run: ./gradlew :hmkit-fleet:dokkaJavadoc

- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH: gh-pages
FOLDER: hmkit-fleet/build/dokka/javadoc
6 changes: 4 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
pull_request:
branches:
- main
- v2

jobs:
test:
Expand All @@ -30,11 +31,12 @@ jobs:
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.GH_SSH_PRIVATE }}"

- name: create credentials.yaml file for the tests to read the keys
- name: create credentials.json files for the tests to read the keys
run: |
mkdir -p ~/.config/high-mobility/fleet-sdk/
# ' will not escape "" inside the yaml file
echo '${{ secrets.CREDENTIALS_YAML }}' > ~/.config/high-mobility/fleet-sdk/credentials.yaml
echo '${{ secrets.CREDENTIALS_JSON }}' > ~/.config/high-mobility/fleet-sdk/credentials.json
echo '${{ secrets.CREDENTIALS_JSON_PRIVATE_KEY }}' > ~/.config/high-mobility/fleet-sdk/credentialsPrivateKey.json

- name: Update submodules
env:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ obj

credentials
vehicleAccess.yaml
vehicleAccess.json
vehicleAccess.json
private-key.json
credentialsPrivateKey.json
credentialsOAuth.json
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "hmkit-fleet-consumer"]
path = hmkit-fleet-consumer
url = [email protected]:highmobility/hmkit-fleet-consumer.git
[submodule "hmkit-crypto-java"]
path = hmkit-crypto-java
url = [email protected]:highmobility/hmkit-crypto-java.git
23 changes: 14 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# Changelog

This is the changelog for v1 releases. See v0 changelog in the [v0 branch](https://github.com/highmobility/hmkit-fleet/tree/v0).
This is the changelog for v2 releases. See v0/v1 releases in appropriate branches.

## [1.0.0] - 2023-05-22
## [2.0.0] - 2023-16-11

### Added
- new `HMKitFleet` constructor with OAuth/OAuth private key credentials

- Initialize HMKitFleet with the `new` keyword. [PR](https://github.com/highmobility/hmkit-fleet/pull/19)
```java
HMKitFleet hmkit = new HMKitFleet(
apiConfiguration,
HMKitFleet.Environment.SANDBOX
HMKitCredentials credentials = new HMKitOAuthCredentials(
"client_id",
"client_secret"
);
```

### Removed
HMKitConfiguration configuration = new HMKitConfiguration.Builder()
.credentials(credentials)
.environment(HMKitFleet.Environment.SANDBOX)
.build();

HMKitFleet hmkit = new HMKitFleet(configuration);
```

- Remove the singleton variant of HMKitFleet
- Tesla brand
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is the HMKitFleet v1 branch. See the [v0 branch](https://github.com/highmobility/hmkit-fleet/tree/v0) for the previous version.
This is the HMKitFleet v2 branch. See the [v1 branch](https://github.com/highmobility/hmkit-fleet/tree/v1) for the previous version.

# HMKit Fleet

Expand Down Expand Up @@ -33,16 +33,19 @@ dependencies {
**General**: HMKit Fleet is a Kotlin library that combines 3 different API-s into a single fleet
owner package.

* hmkit-fleet: Uses [OkHttp](https://github.com/square/okhttp) to communicate with High-Mobility
and [HMKit crypto](https://github.com/highmobility/hmkit-crypto-java/tree/telematics)
to encrypt messages.
* hmkit-fleet: Uses [OkHttp](https://github.com/square/okhttp)

### Setup

* `git submodule update --init --recursive`
* import the Gradle project
* run the tests `./gradlew test`


### Run the sample app
* Check out the hmkit-fleet-consumer/README.md about how to setup the sample app
* Run the sample app with `./gradlew :hmkit-fleet-consumer:run`

### Release/Deployment

check `./gradle/deploy-process.md`
Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id 'net.researchgate.release' version '3.0.2'
id "net.researchgate.release" version "3.0.2"
}

nexusPublishing {
Expand All @@ -23,11 +23,12 @@ subprojects {
}

ext {
kotlin_version = "1.9.20"

depLocation = 0
coroutinesVersion = '1.6.4'
koinVersion = '3.2.0'
coroutinesVersion = '1.7.3'
koinVersion = '3.5.0'
ver = [
"hmkit-fleet" : "0.7.0",
"hmkit-crypto-telematics": "0.1",
"hmkit-auto-api" : "13.1.1",
]
Expand Down
6 changes: 6 additions & 0 deletions detekt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
naming:
InvalidPackageDeclaration:
active: false
formatting:
Indentation:
indentSize: 2
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.0.1
version=2.0.0
kotlin.code.style=official
10 changes: 5 additions & 5 deletions gradle/deploy-process.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Public release

Release is done via a merged pull request to main/v0 and then creating a release in GitHub UI.
Release is done via a merged pull request to main/v0/v1 and then creating a release in GitHub UI.

## Steps for v1
## Steps for v2
- update CHANGELOG.md
- next version is with minor +1, or the manually updated version
- merge a pull request to main. This creates a new tag with minor +=1.
Expand All @@ -17,7 +17,7 @@ Release is done via a merged pull request to main/v0 and then creating a release
- Update version in `$projectRoot/gradle.properties` and call `./gradlew -Prelease :hmkit-fleet:publishToSonatype`.
- Don't merge test version names to main

## Steps for v0
## Steps for v0 and v1

- Same steps as in v1, but merge the PR to the `v0` branch.
- Release the v0 first if releasing both. This way it shows up in the changelog before v1.
- Same steps as in v2, but merge the PR to the `v0`/`v1` branch.
- Release the v0 and v1 first if releasing all. This way the v2 is the latest in the Releases changelog.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion hmkit-crypto-java
Submodule hmkit-crypto-java deleted from d2fb6d
49 changes: 26 additions & 23 deletions hmkit-fleet/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version "1.7.20"
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20'
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"

// CI
id "org.barfuin.gradle.jacocolog" version "3.1.0"
id "io.gitlab.arturbosch.detekt" version "1.23.0"
id "org.jetbrains.dokka" version "1.8.20"
}

kotlin {
Expand All @@ -21,38 +25,37 @@ apply from: "https://raw.githubusercontent.com/tonisives/tools/master/scripts/ju

dependencies {
// kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion"
implementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0')

implementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0')

if (!project.hasProperty('depLocation') || project.depLocation > 0) {
api deps.crypto
} else {
api project(":hmkit-crypto-telematics")
}
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'

// web
implementation('com.squareup.okhttp3:okhttp:4.10.0')
api('com.squareup.okhttp3:okhttp:4.12.0')

// Koin
implementation "io.insert-koin:koin-core:$koinVersion"

// logging
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'org.slf4j:slf4j-api:2.0.9'

// test
testImplementation deps.autoApi
testImplementation "io.insert-koin:koin-test:$koinVersion"

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.1'

testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"

testImplementation 'org.slf4j:slf4j-simple:1.7.36'
testImplementation 'io.mockk:mockk:1.12.5'
testImplementation 'com.charleskorn.kaml:kaml:0.47.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
testImplementation 'org.slf4j:slf4j-simple:2.0.9'
testImplementation 'io.mockk:mockk:1.13.7'
testImplementation 'com.charleskorn.kaml:kaml:0.55.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'

detektPlugins('io.gitlab.arturbosch.detekt:detekt-formatting:1.23.0')
}

detekt {
config = files("$rootDir/detekt.yaml")
buildUponDefaultConfig = true
}
36 changes: 36 additions & 0 deletions hmkit-fleet/src/main/kotlin/HMKitConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.highmobility.hmkitfleet

import okhttp3.OkHttpClient

class HMKitConfiguration private constructor(builder: Builder) {
val credentials = builder.credentials ?: throw IllegalArgumentException("credentials must be set")
val client = builder.client ?: OkHttpClient()
val environment = builder.environment

class Builder {
var credentials: HMKitCredentials? = null
private set
var environment: HMKitFleet.Environment = HMKitFleet.Environment.PRODUCTION
private set
var client: OkHttpClient? = null
private set

/**
* Set the credentials to be used for the SDK. Choose from either [HMKitOAuthCredentials] or
* [HMKitPrivateKeyCredentials]. This is a mandatory field.
*/
fun credentials(credentials: HMKitCredentials) = apply { this.credentials = credentials }

/**
* Set the SDK environment. Default is Production.
*/
fun environment(environment: HMKitFleet.Environment) = apply { this.environment = environment }

/**
* Optionally, set the OkHttpClient to be used for network requests.
*/
fun client(client: OkHttpClient) = apply { this.client = client }

fun build() = HMKitConfiguration(this)
}
}
Loading
Loading