Skip to content

Commit

Permalink
Dependency bump (#9)
Browse files Browse the repository at this point in the history
* Upgrade dependencies and gradle wrapper, force trailing comma, migrate from javax to jakarta, set java version to 17

* Change CI java version to 17

* Remove unnecessary dependency and dependency version in build.gradle
  • Loading branch information
TrojanerHD authored Sep 20, 2023
1 parent ac3942d commit 33fcb32
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 81 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[{*.kt,*.kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 16 ]
java: [ 17 ]

steps:
- name: Checkout
Expand Down
32 changes: 16 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
buildscript {
ext {
javaVersion = JavaVersion.VERSION_1_8
gradleVersion = "7.4.2"

junitVersion = "5.8.2"
kotlinVersion = "1.6.21"
detektVersion = "1.20.0"
ktlintVersion = "10.2.1"
jacksonVersion = "2.13.2"
springBootVersion = "2.6.7"
javaVersion = JavaVersion.VERSION_17
gradleVersion = "8.3"

junitVersion = "5.10.0"
kotlinVersion = "1.9.10"
detektVersion = "1.23.1"
ktlintVersion = "11.5.1"
jacksonVersion = "2.15.2"
springBootVersion = "3.1.3"
awaitilityVersion = "4.2.0"
hivemqClientVersion = "1.3.0"
testcontainersVersion = "1.17.1"
kluentVersion = "1.68"
dokkaVersion = "1.6.21"
dependencyManagementVersion = "1.0.11.RELEASE"
gradleNexusVersion = "1.1.0"
gradleVersionsPluginVersion = "0.39.0"
hivemqClientVersion = "1.3.2"
testcontainersVersion = "1.19.0"
kluentVersion = "1.73"
dokkaVersion = "1.8.20"
dependencyManagementVersion = "1.1.3"
gradleNexusVersion = "1.3.0"
gradleVersionsPluginVersion = "0.47.0"
}

repositories {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 23 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand All @@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AnnotationCollector : BeanPostProcessor {
- the MqttTopic
- any type of deserialized JSON payload
- or both
""".trimMargin()
""".trimMargin(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import com.hivemq.client.mqtt.mqtt5.message.connect.connack.Mqtt5ConnAck
class BrokerConnectException(message: String, cause: Throwable? = null) : RuntimeException(message, cause) {
constructor(acknowledgement: Mqtt3ConnAck, cause: Throwable? = null) : this(
"Unable to connect to broker. Return Code: ${acknowledgement.returnCode.code}",
cause
cause,
)

constructor(acknowledgement: Mqtt5ConnAck, cause: Throwable? = null) : this(
"Unable to connect to broker. Return code: ${acknowledgement.reasonCode.code}",
cause
cause,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class MqttAutoConfiguration {
messageAdapter: MqttMessageAdapter,
collector: AnnotationCollector,
config: MqttProperties,
client: Mqtt3Client
client: Mqtt3Client,
): Mqtt3Router {
return Mqtt3Router(collector, messageAdapter, config, client)
}
Expand All @@ -122,7 +122,7 @@ class MqttAutoConfiguration {
messageAdapter: MqttMessageAdapter,
collector: AnnotationCollector,
config: MqttProperties,
client: Mqtt5Client
client: Mqtt5Client,
): Mqtt5Router {
return Mqtt5Router(collector, messageAdapter, config, client)
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/kotlin/de/smartsquare/starter/mqtt/MqttProperties.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package de.smartsquare.starter.mqtt

import jakarta.validation.constraints.Max
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotEmpty
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import org.springframework.validation.annotation.Validated
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotEmpty

/**
* Properties for connection to the mqtt broker.
*/
@Validated
@ConstructorBinding
@ConfigurationProperties(prefix = "mqtt")
data class MqttProperties(

Expand Down Expand Up @@ -62,5 +60,5 @@ data class MqttProperties(
* The mqtt protocol version to use.
*/
@get:MqttVersion
val version: Int = 3
val version: Int = 3,
)
4 changes: 2 additions & 2 deletions src/main/kotlin/de/smartsquare/starter/mqtt/MqttPublisher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Mqtt3Publisher(private val adapter: MqttMessageAdapter, client: Mqtt3Clien
.topic(topic)
.qos(qos)
.payload(adapter.adapt(payload))
.build()
.build(),
)
}
}
Expand All @@ -47,7 +47,7 @@ class Mqtt5Publisher(private val adapter: MqttMessageAdapter, client: Mqtt5Clien
.topic(topic)
.qos(qos)
.payload(adapter.adapt(payload))
.build()
.build(),
)
}
}
8 changes: 4 additions & 4 deletions src/main/kotlin/de/smartsquare/starter/mqtt/MqttRouter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.lang.reflect.Method
abstract class MqttRouter(
private val collector: AnnotationCollector,
private val adapter: MqttMessageAdapter,
private val config: MqttProperties
private val config: MqttProperties,
) : InitializingBean {

private val logger = LoggerFactory.getLogger(this::class.java)
Expand Down Expand Up @@ -54,7 +54,7 @@ abstract class MqttRouter(
} catch (e: JsonMappingException) {
logger.error(
"Error while delivering mqtt message on topic [$topic]: Failed to map payload to target class",
e
e,
)
} catch (e: JacksonException) {
logger.error("Error while delivering mqtt message on topic [$topic]: Failed to parse payload", e)
Expand All @@ -70,7 +70,7 @@ class Mqtt3Router(
collector: AnnotationCollector,
adapter: MqttMessageAdapter,
config: MqttProperties,
client: Mqtt3Client
client: Mqtt3Client,
) : MqttRouter(collector, adapter, config) {

private val asyncClient = client.toAsync()
Expand All @@ -92,7 +92,7 @@ class Mqtt5Router(
collector: AnnotationCollector,
adapter: MqttMessageAdapter,
config: MqttProperties,
client: Mqtt5Client
client: Mqtt5Client,
) : MqttRouter(collector, adapter, config) {

private val asyncClient = client.toAsync()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.smartsquare.starter.mqtt

import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import jakarta.validation.Constraint
import jakarta.validation.ConstraintValidator
import jakarta.validation.ConstraintValidatorContext
import kotlin.reflect.KClass

/**
Expand All @@ -14,7 +14,7 @@ import kotlin.reflect.KClass
annotation class MqttVersion(
val message: String = "Invalid mqtt version. Allowed are 3 and 5.",
val groups: Array<KClass<*>> = [],
val payload: Array<KClass<*>> = []
val payload: Array<KClass<*>> = [],
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.util.concurrent.TimeoutException
*/
class SpringAwareMqtt3Client(
private val delegate: Mqtt3Client,
private val connectOptions: Mqtt3Connect = Mqtt3Connect.builder().build()
private val connectOptions: Mqtt3Connect = Mqtt3Connect.builder().build(),
) : Mqtt3Client by delegate, InitializingBean, DisposableBean {

private val logger = LoggerFactory.getLogger(this::class.java)
Expand All @@ -42,7 +42,7 @@ class SpringAwareMqtt3Client(
} catch (error: TimeoutException) {
throw BrokerConnectException(
"Failed to connect: Broker $host:$port did not respond within 10 seconds.",
error
error,
)
}
}
Expand All @@ -61,7 +61,7 @@ class SpringAwareMqtt3Client(
*/
class SpringAwareMqtt5Client(
private val delegate: Mqtt5Client,
private val connectOptions: Mqtt5Connect = Mqtt5Connect.builder().build()
private val connectOptions: Mqtt5Connect = Mqtt5Connect.builder().build(),
) : Mqtt5Client by delegate, InitializingBean, DisposableBean {

private val logger = LoggerFactory.getLogger(this::class.java)
Expand All @@ -84,7 +84,7 @@ class SpringAwareMqtt5Client(
} catch (error: TimeoutException) {
throw BrokerConnectException(
"Failed to connect: Broker $host:$port did not respond within 10 seconds.",
error
error,
)
}
}
Expand Down
Loading

0 comments on commit 33fcb32

Please sign in to comment.