Skip to content

Commit

Permalink
Update Kotlin and gradle plugins (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX authored Mar 14, 2024
1 parent d53de4a commit a855747
Show file tree
Hide file tree
Showing 63 changed files with 742 additions and 877 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugins {
id("org.ajoberstar.grgit") version "5.2.0"
id("org.ajoberstar.grgit")
}
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ android.useAndroidX=true
android.nonTransitiveRClass=true
org.gradle.unsafe.configuration-cache=false

kotlinVersion=1.9.0-RC
spotlessVersion=6.12.0
kotlinVersion=1.9.23
spotlessVersion=6.25.0
shadowJarVersion=8.1.1
buildconfigVersion=3.1.0
buildconfigVersion=5.3.5
grgitVersion=5.2.2
48 changes: 17 additions & 31 deletions server/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,26 @@ dependencies {
implementation("com.github.mik3y:usb-serial-for-android:3.7.0")
}

/**
* The android block is where you configure all your Android-specific
* build options.
*/

// The android block is where you configure all your Android-specific build options.
extra.apply {
set("gitVersionCode", grgit.tag.list().size)
set("gitVersionName", grgit.describe(mapOf("tags" to true, "always" to true)))
}
android {
/**
* The app's namespace. Used primarily to access app resources.
*/
// The app's namespace. Used primarily to access app resources.

namespace = "dev.slimevr.android"

/**
* compileSdk specifies the Android API level Gradle should use to
* compile your app. This means your app can use the API features included in
* this API level and lower.
*/
/* compileSdk specifies the Android API level Gradle should use to
compile your app. This means your app can use the API features included in
this API level and lower. */

compileSdk = 33

/**
* The defaultConfig block encapsulates default settings and entries for all
* build variants and can override some attributes in main/AndroidManifest.xml
* dynamically from the build system. You can configure product flavors to override
* these values for different versions of your app.
*/
/* The defaultConfig block encapsulates default settings and entries for all
build variants and can override some attributes in main/AndroidManifest.xml
dynamically from the build system. You can configure product flavors to override
these values for different versions of your app. */

packaging {
resources.excludes.add("META-INF/*")
Expand All @@ -139,26 +129,22 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

/**
* The buildTypes block is where you can configure multiple build types.
* By default, the build system defines two build types: debug and release. The
* debug build type is not explicitly shown in the default build configuration,
* but it includes debugging tools and is signed with the debug key. The release
* build type applies ProGuard settings and is not signed by default.
*/
/* The buildTypes block is where you can configure multiple build types.
By default, the build system defines two build types: debug and release. The
debug build type is not explicitly shown in the default build configuration,
but it includes debugging tools and is signed with the debug key. The release
build type applies ProGuard settings and is not signed by default. */

buildTypes {

/**
* By default, Android Studio configures the release build type to enable code
* shrinking, using minifyEnabled, and specifies the default ProGuard rules file.
*/
/* By default, Android Studio configures the release build type to enable code
shrinking, using minifyEnabled, and specifies the default ProGuard rules file. */

getByName("release") {
isMinifyEnabled = true // Enables code shrinking for the release build type.
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/android/src/main/java/dev/slimevr/android/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun main(activity: AppCompatActivity) {
try {
vrServer = VRServer(
configPath = File(activity.filesDir, "vrconfig.yml").absolutePath,
serialHandlerProvider = { _ -> AndroidSerialHandler(activity) }
serialHandlerProvider = { _ -> AndroidSerialHandler(activity) },
)
vrServer.start()
Keybinding(vrServer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
startWatchingNewDevices()
}

private fun getPorts(): List<UsbSerialDriver> {
return UsbSerialProber.getDefaultProber().findAllDrivers(manager)
}
private fun getPorts(): List<UsbSerialDriver> = UsbSerialProber.getDefaultProber().findAllDrivers(manager)

private fun startWatchingNewDevices() {
if (watchingNewDevices) return
Expand All @@ -78,13 +76,13 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
} catch (t: Throwable) {
LogManager.severe(
"[SerialHandler] Error while watching for new devices, cancelling the \"getDevicesTimer\".",
t
t,
)
getDevicesTimer.cancel()
}
},
0,
3000
3000,
)
}

Expand Down Expand Up @@ -116,7 +114,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :

if (newPort == null) {
LogManager.info(
"[SerialHandler] No serial ports found to connect to (${lastKnownPorts.size}) total ports"
"[SerialHandler] No serial ports found to connect to (${lastKnownPorts.size}) total ports",
)
return false
}
Expand All @@ -126,7 +124,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
if (newPort != port) {
LogManager.info(
"[SerialHandler] Closing current serial port " +
port.descriptivePortName
port.descriptivePortName,
)
closeSerial()
} else {
Expand All @@ -138,7 +136,7 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :

LogManager.info(
"[SerialHandler] Trying to connect to new serial port " +
newPort.descriptivePortName
newPort.descriptivePortName,
)

if (!manager.hasPermission(newPort.port.device)) {
Expand All @@ -147,23 +145,23 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
activity,
0,
Intent(ACTION_USB_PERMISSION),
flags
flags,
)
if (requestingPermission != newPort.portLocation) {
println("Requesting permission for ${newPort.portLocation}")
manager.requestPermission(newPort.port.device, usbPermissionIntent)
requestingPermission = newPort.portLocation
}
LogManager.warning(
"[SerialHandler] Can't open serial port ${newPort.descriptivePortName}, invalid permissions"
"[SerialHandler] Can't open serial port ${newPort.descriptivePortName}, invalid permissions",
)
return false
}

val connection = manager.openDevice(newPort.port.device)
if (connection == null) {
LogManager.warning(
"[SerialHandler] Can't open serial port ${newPort.descriptivePortName}, connection failed"
"[SerialHandler] Can't open serial port ${newPort.descriptivePortName}, connection failed",

)
return false
Expand Down Expand Up @@ -215,15 +213,15 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
}
listeners.forEach { it.onSerialDisconnected() }
LogManager.info(
"[SerialHandler] Port ${currentPort?.descriptivePortName} closed okay"
"[SerialHandler] Port ${currentPort?.descriptivePortName} closed okay",
)
usbIoManager?.stop()
usbIoManager = null
currentPort = null
} catch (e: Exception) {
LogManager.warning(
"[SerialHandler] Error closing port ${currentPort?.descriptivePortName}",
e
e,
)
}
}
Expand Down
16 changes: 6 additions & 10 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,26 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
// indentWithSpaces(2) // YAML cannot contain tabs: https://yaml.org/faq.html
// }

// .editorconfig doesn't work so, manual override
// https://github.com/diffplug/spotless/issues/142
val editorConfig =
mapOf(
"indent_size" to 4,
"indent_style" to "tab",
// "max_line_length" to 88,
"max_line_length" to "off",
"ktlint_experimental" to "enabled",
"ktlint_standard_condition-wrapping" to "disabled",
"ktlint_standard_property-naming" to "disabled",
"ij_kotlin_packages_to_use_import_on_demand" to
"java.util.*,kotlin.math.*,dev.slimevr.autobone.errors.*,io.github.axisangles.ktmath.*,kotlinx.atomicfu.*",
"ij_kotlin_allow_trailing_comma" to true
"ij_kotlin_allow_trailing_comma" to true,
)
val ktlintVersion = "0.47.1"
val ktlintVersion = "1.2.1"
kotlinGradle {
target("**/*.gradle.kts") // default target for kotlinGradle
ktlint(ktlintVersion)
.setUseExperimental(true)
.editorConfigOverride(editorConfig)
}
kotlin {
target("**/*.kt")
targetExclude("**/build/**/**.kt")
targetExclude("**/build/**/**.kt", "bin/")
ktlint(ktlintVersion)
.setUseExperimental(true)
.editorConfigOverride(editorConfig)
}
java {
Expand Down
2 changes: 1 addition & 1 deletion server/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies {
implementation("com.illposed.osc:javaosc-core:0.8")
implementation("org.java-websocket:Java-WebSocket:1.+")
implementation("com.melloware:jintellitype:1.+")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
implementation("it.unimi.dsi:fastutil:8.5.12")

testImplementation(kotlin("test"))
Expand Down
12 changes: 5 additions & 7 deletions server/core/src/main/java/dev/slimevr/VRServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class VRServer @JvmOverloads constructor(
LogManager.info("Starting the tracker server on port $trackerPort...")
trackersServer = TrackersUDPServer(
trackerPort,
"Sensors UDP server"
"Sensors UDP server",
) { tracker: Tracker -> registerTracker(tracker) }

// Start bridges for SteamVR and Feeder
Expand All @@ -143,13 +143,13 @@ class VRServer @JvmOverloads constructor(
humanPoseManager,
driverBridge,
configManager.vrConfig.vrcOSC,
computedTrackers
computedTrackers,
)
vMCHandler = VMCHandler(
this,
humanPoseManager,
configManager.vrConfig.vmc,
computedTrackers
computedTrackers,
)

// Initialize OSC router
Expand Down Expand Up @@ -279,7 +279,7 @@ class VRServer @JvmOverloads constructor(
fun updateSkeletonModel() {
queueTask { humanPoseManager.updateSkeletonModelFromServer() }
vrcOSCHandler.setHeadTracker(
TrackerUtils.getTrackerForSkeleton(trackers, TrackerPosition.HEAD)
TrackerUtils.getTrackerForSkeleton(trackers, TrackerPosition.HEAD),
)
}

Expand Down Expand Up @@ -398,9 +398,7 @@ class VRServer @JvmOverloads constructor(
get() = ::instance.isInitialized

@JvmStatic
fun getNextLocalTrackerId(): Int {
return nextLocalTrackerId.incrementAndGet()
}
fun getNextLocalTrackerId(): Int = nextLocalTrackerId.incrementAndGet()

@JvmStatic
val currentLocalTrackerId: Int
Expand Down
Loading

0 comments on commit a855747

Please sign in to comment.