Skip to content

Commit

Permalink
Upgrade to JVM 22
Browse files Browse the repository at this point in the history
- Update Java to 22
- Update ktor 2.3.9
- Update compose to 1.6.1
- Update horologist to 0.6.4
- Update protobuf to 4.26.0
- Update coil to 3.0.0-alpha06
- Update mikbot-music to 3.5.15-SNAPSHOT
- Update logback to 1.5.3
- Update androidx.browser to 1.8.0
- Update buildconfig to 5.3.5
- Update windows to 0.54.0
- Update tokio to 1.36.0
- Update log to 0.4.21
  • Loading branch information
DRSchlaubi committed Mar 19, 2024
1 parent d22cf34 commit 77b0a28
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:

env:
JAVA_VERSION: 21
JAVA_VERSION: 22

permissions:
contents: write
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
if: matrix.os == 'windows-latest'
shell: powershell
run: |
Invoke-WebRequest https://download.java.net/java/early_access/jextract/21/1/openjdk-21-jextract+1-2_windows-x64_bin.tar.gz -OutFile jextract.tar.gz
Invoke-WebRequest https://download.java.net/java/early_access/jextract/22/3/openjdk-22-jextract+3-13_windows-x64_bin.tar.gz -OutFile jextract.tar.gz
tar xzvf jextract.tar.gz
- name: Setup MacOS signing
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
java-version: 22
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- run: ./gradlew publish
Expand Down
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM gradle:jdk21 as builder
FROM eclipse-temurin:22-jre-alpine as builder
WORKDIR /usr/app
COPY . .
RUN ./gradlew --no-daemon installBotArchive

FROM eclipse-temurin:21-jre-alpine
FROM eclipse-temurin:22-jre-alpine

WORKDIR /usr/app
COPY --from=builder /usr/app/bot/build/installBot .
Expand Down
13 changes: 6 additions & 7 deletions app/desktop/src/windowsMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ actual fun start(args: Array<String>) {
}

actual fun launchUri(uri: URI): Unit = Arena.ofConfined().use { arena ->
val url = arena.allocateUtf8String(uri.toString())
val url = arena.allocateFrom(uri.toString())
launch_uri(url)
}

actual fun setToken(token: String) = Arena.ofConfined().use { arena ->
val tokenStr = arena.allocateUtf8String(token)
val tokenStr = arena.allocateFrom(token)
store_token(tokenStr)
}

Expand All @@ -61,12 +61,11 @@ private fun getTempFolder(): String = invokeStringResultFunction(::get_temp_fold

private fun invokeStringResultFunction(
function: (SegmentAllocator) -> MemorySegment
) =
Arena.ofConfined().use { arena ->
) = Arena.ofConfined().use { arena ->
val result = function(arena)
val isError = StringResult.`is_error$get`(result)
val length = StringResult.`length$get`(result).coerceAtLeast(0)
val buffer = arena.allocateArray(uint16_t, length)
val isError = StringResult.is_error(result)
val length = StringResult.length(result).coerceAtLeast(0)
val buffer = arena.allocate(uint16_t, length)
copy_string_from_get_string_result_into_buffer(result, buffer)
val shortArray = buffer.toArray(uint16_t)
val charArray = CharArray(shortArray.size)
Expand Down
6 changes: 3 additions & 3 deletions app/desktop/uwp_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ build = "build.rs"
crate-type = ["cdylib"]

[dependencies.windows]
version = "0.51.1"
version = "0.54.0"
features = ["System", "Foundation", "Win32_Foundation", "Security_Credentials", "Services_Store", "Foundation_Collections", "Storage"]

[dependencies.tokio]
version = "1.32.0"
version = "1.36.0"
features = ["macros", "rt-multi-thread"]

[build-dependencies.cbindgen]
version = "0.26.0"
default-features = false

[dependencies]
log = "0.4.20"
log = "0.4.21"
3 changes: 1 addition & 2 deletions app/desktop/uwp_helper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tasks {
val libraryPath = if (System.getenv("GITHUB_REF") != null) {
"uwp_helper"
} else {
file("target/release/uwp_helper.dll").absolutePath
file("target/release/uwp_helper").absolutePath
}

commandLine(
Expand All @@ -49,7 +49,6 @@ tasks {
"--target-package", "dev.schlaubi.tonbrett.app.desktop.uwp_helper",
"--library", libraryPath,
"--output", jextractOutput.get().asFile.absolutePath,
"--source",
"--include-function", "launch_uri",
"--include-function", "get_token",
"--include-function", "store_token",
Expand Down
39 changes: 21 additions & 18 deletions app/desktop/uwp_helper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
use std::ffi::{c_char, CStr};

use windows::Services::Store::StoreContext;
use windows::Storage::ApplicationData;
use windows::{
core::h,
core::Result,
core::{Error, HSTRING},
core::{
Error,
HSTRING,
h,
Result
},
Foundation::Uri,
Security::Credentials::{PasswordCredential, PasswordVault},
System::Launcher,
Win32::Foundation::E_FAIL,
Services::Store::StoreContext,
Storage::ApplicationData
};

const RESOURCE: &HSTRING = h!("dev.schlaubi.tonbrett/api_token");
const USERNAME: &HSTRING = h!("_");

#[repr(C)]
pub struct StringResult {
is_error: bool,
length: usize,
string: HSTRING,
}

#[tokio::main]
#[no_mangle]
pub async extern "C" fn request_msstore_auto_update() -> bool {
Expand All @@ -35,13 +45,6 @@ pub async unsafe extern "C" fn launch_uri(uri: *const c_char) {
_launch_uri(uri_str).await.unwrap()
}

#[repr(C)]
pub struct StringResult {
is_error: bool,
length: usize,
string: HSTRING,
}

#[no_mangle]
pub unsafe extern "C" fn store_token(token: *const c_char) {
let token_str = CStr::from_ptr(token).to_str().unwrap();
Expand All @@ -50,7 +53,7 @@ pub unsafe extern "C" fn store_token(token: *const c_char) {

#[no_mangle]
pub extern "C" fn get_token() -> StringResult {
StringResult::from(_get_token())
_get_token().into()
}

#[no_mangle]
Expand All @@ -63,7 +66,7 @@ pub unsafe extern "C" fn copy_string_from_get_string_result_into_buffer(

#[no_mangle]
pub unsafe extern "C" fn get_temp_folder() -> StringResult {
StringResult::from(_get_temp_folder())
_get_temp_folder().into()
}

async fn _launch_uri(uri: &str) -> Result<()> {
Expand All @@ -85,9 +88,8 @@ fn _store_token(token: &str) -> Result<()> {
fn _get_token() -> Result<HSTRING> {
let vault = PasswordVault::new()?;
let credential = vault.Retrieve(RESOURCE, USERNAME)?;
let password = credential.Password()?;

Ok(password)
return credential.Password()
}

fn _get_temp_folder() -> Result<HSTRING> {
Expand All @@ -96,7 +98,8 @@ fn _get_temp_folder() -> Result<HSTRING> {

async fn _request_msstore_auto_update() -> Result<()> {
let context = StoreContext::GetDefault()?;
let updates = context.GetAppAndOptionalStorePackageUpdatesAsync()?.await?;
let updates =
context.GetAppAndOptionalStorePackageUpdatesAsync()?.await?;

if updates.Size()? > 0 {
context
Expand All @@ -112,7 +115,7 @@ impl From<Result<HSTRING>> for StringResult {
fn from(value: Result<HSTRING>) -> Self {
let (string, is_error) = match value {
Ok(password) => (password, false),
Err(error) => (error.message(), true),
Err(error) => (error.message().into(), true),
};

StringResult {
Expand Down
4 changes: 4 additions & 0 deletions bot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ plugins {
alias(libs.plugins.mikbot)
}

repositories {
maven("https://maven.topi.wtf/releases")
}

dependencies {
implementation(projects.common)
ktorDependency(libs.ktor.server.auth)
Expand Down
13 changes: 11 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
alias(libs.plugins.kotlin.serialization) apply false
Expand All @@ -7,7 +9,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.18.19"
version = "1.19.0"

repositories {
mavenCentral()
Expand All @@ -19,7 +21,14 @@ allprojects {
subprojects {
afterEvaluate {
extensions.findByType<KotlinTopLevelExtension>()?.apply {
jvmToolchain(21)
jvmToolchain(22)
}

// TODO: Remove after https://youtrack.jetbrains.com/issue/KT-66703/
tasks {
withType<KotlinJvmCompile> {
jvmTargetValidationMode = JvmTargetValidationMode.IGNORE
}
}
}
}
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[versions]
kotlin = "2.0.0-Beta4"
ktor = "2.3.8"
ktor = "2.3.9"
kmongo = "4.11.0"
kord = "0.13.1"
mikbot = "3.29.0"
ksp = "2.0.0-Beta4-1.0.17"
kordex = "1.7.1-SNAPSHOT"
android = "8.2.2"
compose = "1.6.0"
compose = "1.6.1"
compose-wear = "1.3.0"
lyricist = "1.6.2"
google-play = "2.1.0"
coroutines = "1.8.0"
play-services-wearable = "18.1.0"
horologist = "0.6.2"
protobuf = "3.25.3"
horologist = "0.6.4"
protobuf = "4.26.0"
compose-compiler = "1.5.11-dev-k2.0.0-Beta4-21f5e479a96"
coil = "3.0.0-alpha04"
coil = "3.0.0-alpha06"

[libraries]
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.6.3" }
Expand Down Expand Up @@ -50,21 +50,21 @@ ktor-sse = { group = "io.ktor", name = "ktor-sse", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }

mikbot-ktor = { group = "dev.schlaubi", name = "mikbot-ktor", version.ref = "mikbot" }
mikbot-music = { group = "dev.schlaubi", name = "mikbot-music-player", version = "3.3.0-SNAPSHOT" }
mikbot-music = { group = "dev.schlaubi", name = "mikbot-music-player", version = "3.5.15-SNAPSHOT" }

kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version = "6.0.3" }

lyricist = { group = "cafe.adriel.lyricist", name = "lyricist", version.ref = "lyricist" }
lyricist-processor = { group = "cafe.adriel.lyricist", name = "lyricist-processor", version.ref = "lyricist" }

logback = { group = "ch.qos.logback", name = "logback-classic", version = "1.4.14" }
logback = { group = "ch.qos.logback", name = "logback-classic", version = "1.5.3" }

kvault = { group = "com.liftric", name = "kvault", version = "1.12.0" }

androidx-activity = { group = "androidx.activity", name = "activity-compose", version = "1.8.2" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version = "1.6.1" }
androidx-core = { group = "androidx.core", name = "core-ktx", version = "1.12.0" }
androidx-browser = { group = "androidx.browser", name = "browser", version = "1.7.0" }
androidx-browser = { group = "androidx.browser", name = "browser", version = "1.8.0" }
mdc-android = { group = "com.google.android.material", name = "material", version = "1.11.0" }
google-play = { group = "com.google.android.play", name = "app-update", version.ref = "google-play" }
google-play-ktx = { group = "com.google.android.play", name = "app-update-ktx", version.ref = "google-play" }
Expand Down Expand Up @@ -102,5 +102,5 @@ android-base = { id = "com.android.base", version.ref = "android" }
android-application = { id = "com.android.application", version.ref = "android" }
android-library = { id = "com.android.library", version.ref = "android" }
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version = "5.3.3" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version = "5.3.5" }
protobuf = { id = "com.google.protobuf", version = "0.9.4" }

0 comments on commit 77b0a28

Please sign in to comment.