Skip to content

Commit

Permalink
Update to Kotlin 2.0 (#100)
Browse files Browse the repository at this point in the history
Also other dependencies have been updated
  • Loading branch information
StefanOltmann authored May 25, 2024
1 parent 3af7a13 commit e4704ae
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/.idea/uiDesigner.xml
/.idea/vcs.xml
/.idea/workspace.xml
/.kotlin/
/build/
/local.properties
/src/commonTest/resources/com/ashampoo/kim/testdata/full/*.html
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kim - Kotlin Image Metadata

[![Kotlin](https://img.shields.io/badge/kotlin-1.9.24-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.0-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
![JVM](https://img.shields.io/badge/-JVM-gray.svg?style=flat)
![Android](https://img.shields.io/badge/-Android-gray.svg?style=flat)
![iOS](https://img.shields.io/badge/-iOS-gray.svg?style=flat)
Expand Down Expand Up @@ -39,7 +39,7 @@ of Ashampoo Photo Organizer, which, in turn, is driven by user community feedbac
## Installation

```
implementation("com.ashampoo:kim:0.18.2")
implementation("com.ashampoo:kim:0.18.3")
```

For the targets `wasmJs` & `js` you also need to specify this:
Expand Down
46 changes: 20 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform") version "1.9.24"
kotlin("multiplatform") version "2.0.0"
id("com.android.library") version "8.2.2"
id("maven-publish")
id("signing")
Expand All @@ -24,11 +24,11 @@ repositories {

val productName: String = "Ashampoo Kim"

val ktorVersion: String = "2.3.10"
val ktorVersion: String = "2.3.11"
val xmpCoreVersion: String = "1.3.0"
val dateTimeVersion: String = "0.5.0"
val dateTimeVersion: String = "0.6.0"
val testRessourcesVersion: String = "0.4.0"
val kotlinxIoVersion: String = "0.3.4"
val kotlinxIoVersion: String = "0.3.5"

description = productName
group = "com.ashampoo"
Expand Down Expand Up @@ -170,20 +170,14 @@ kotlin {
}
}

js {
// nodejs()
}
js()

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
// All tests reading from files fail, because kotlinx-io
// has no Path support for WASM (yet?).
// nodejs()
}
wasmJs()

// Note: Missing support in kotlinx-datetime
// @OptIn(ExperimentalWasmDsl::class)
// wasmWasi()
// WASI support is planned for kotlinx-datetime v0.7
// @OptIn(ExperimentalWasmDsl::class)
// wasmWasi()

@Suppress("UnusedPrivateMember") // False positive
val commonMain by sourceSets.getting {
Expand All @@ -198,7 +192,7 @@ kotlin {
}
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val commonTest by sourceSets.getting {
dependencies {

Expand Down Expand Up @@ -268,31 +262,31 @@ kotlin {
dependsOn(ktorMain)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val jvmMain by sourceSets.getting {

dependsOn(commonMain)
dependsOn(ktorMain)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val androidMain by sourceSets.getting {

dependsOn(commonMain)
dependsOn(ktorMain)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val winMain by sourceSets.getting {
dependsOn(posixMain)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val linuxX64Main by sourceSets.getting {
dependsOn(posixMain)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val linuxArm64Main by sourceSets.getting {
dependsOn(posixMain)
}
Expand All @@ -303,7 +297,7 @@ kotlin {
val macosX64Main by sourceSets.getting
val macosArm64Main by sourceSets.getting

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val appleMain by sourceSets.creating {

dependsOn(commonMain)
Expand All @@ -323,7 +317,7 @@ kotlin {
val macosX64Test by sourceSets.getting
val macosArm64Test by sourceSets.getting

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val appleTest by sourceSets.creating {

dependsOn(commonTest)
Expand All @@ -335,20 +329,20 @@ kotlin {
macosArm64Test.dependsOn(this)
}

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val jsMain by sourceSets.getting {

dependsOn(commonMain)

dependencies {
implementation(npm("pako", "2.1.0"))
api(npm("pako", "2.1.0"))
}
}

val wasmJsMain by sourceSets.getting
// val wasmWasiMain by sourceSets.getting

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
@Suppress("UnusedPrivateMember") // False positive
val wasmMain by sourceSets.creating {

dependsOn(commonMain)
Expand Down
8 changes: 4 additions & 4 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ complexity:
active: true
threshold: 600
LongMethod:
active: true
active: false
threshold: 60
LongParameterList:
active: false # already checked by SonarQube
Expand Down Expand Up @@ -609,10 +609,10 @@ style:
ignoreActualFunction: true
excludedFunctions: [ ]
LoopWithTooManyJumpStatements:
active: true
active: false
maxJumpCount: 1
MagicNumber:
active: true
active: false
excludes: [ '**/commonTest/**', '**/jvmTest/**' ]
ignoreNumbers:
- '-1'
Expand Down Expand Up @@ -730,7 +730,7 @@ style:
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
active: false
allowForUnclearPrecedence: false
UntilInsteadOfRangeTo:
active: true
Expand Down
41 changes: 18 additions & 23 deletions src/commonMain/kotlin/com/ashampoo/kim/model/PhotoMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ package com.ashampoo.kim.model

import com.ashampoo.kim.common.PhotoValueFormatter
import com.ashampoo.xmp.XMPRegionArea
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime

/**
* Represents a high-level summary of image metadata extracted from raw ImageMetadata.
Expand Down Expand Up @@ -68,34 +64,33 @@ public data class PhotoMetadata(

) {

val takenDateLocalDateTime: LocalDateTime? = takenDate?.let {
Instant.fromEpochMilliseconds(takenDate).toLocalDateTime(TimeZone.currentSystemDefault())
}

val megaPixelCount: Int = if (widthPx == null || heightPx == null)
0
else
(widthPx * heightPx).div(PhotoValueFormatter.MEGA_PIXEL_COUNT)
val megaPixelCount: Int
get() = if (widthPx == null || heightPx == null)
0
else
(widthPx * heightPx).div(PhotoValueFormatter.MEGA_PIXEL_COUNT)

val locationDisplay: String? =
location?.displayString ?: gpsCoordinates?.let { gpsCoordinates.displayString }
val locationDisplay: String?
get() = location?.displayString ?: gpsCoordinates?.let { gpsCoordinates.displayString }

val cameraName: String? =
PhotoValueFormatter.createCameraOrLensName(cameraMake, cameraModel)
val cameraName: String?
get() = PhotoValueFormatter.createCameraOrLensName(cameraMake, cameraModel)

val lensName: String? =
PhotoValueFormatter.createModifiedLensName(
val lensName: String?
get() = PhotoValueFormatter.createModifiedLensName(
cameraName = cameraName,
lensName = PhotoValueFormatter.createCameraOrLensName(lensMake, lensModel)
)

val cameraAndLensName: String? = PhotoValueFormatter.createCameraAndLensName(
cameraName = cameraName,
lensName = lensName
)
val cameraAndLensName: String?
get() = PhotoValueFormatter.createCameraAndLensName(
cameraName = cameraName,
lensName = lensName
)

@Suppress("DataClassContainsFunctions")
public fun isEmpty(): Boolean = this == emptyPhotoMetadata
public fun isEmpty(): Boolean =
this == emptyPhotoMetadata

/**
* Combine the current metadata with the given one,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ public fun Path.exists(): Boolean =

public fun Path.list(): Collection<Path> =
SystemFileSystem.list(this)

18 changes: 18 additions & 0 deletions src/wasmWasiTest/kotlin/com/ashampoo/kim/ResourcePath.wasmWasi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2024 Ashampoo GmbH & Co. KG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ashampoo.kim

actual fun getPathForResource(path: String): String = path

0 comments on commit e4704ae

Please sign in to comment.