Skip to content

Commit 0ff63fb

Browse files
Kotlin 1.9.20 Update (#10)
* Dependency updates, including Kotlin 1.9.20 * Fixed some style issues detected by the linter. * Fixed shadowed argument warnings. * Renamed launch script. * Source format.
1 parent cc313c0 commit 0ff63fb

15 files changed

Lines changed: 169 additions & 136 deletions

File tree

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# XMP Core for Kotlin Multiplatform
22

3-
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
3+
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.20-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
44
![JVM](https://img.shields.io/badge/-JVM-gray.svg?style=flat)
55
![Android](https://img.shields.io/badge/-Android-gray.svg?style=flat)
66
![macOS](https://img.shields.io/badge/-macOS-gray.svg?style=flat)
@@ -15,7 +15,7 @@ It's part of [Ashampoo Photos](https://ashampoo.com/photos).
1515
## Installation
1616

1717
```
18-
implementation("com.ashampoo:xmpcore:0.1.6")
18+
implementation("com.ashampoo:xmpcore:0.1.7")
1919
```
2020

2121
## How to use

build.gradle.kts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
22
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
33

44
plugins {
5-
kotlin("multiplatform") version "1.9.10"
5+
kotlin("multiplatform") version "1.9.20"
66
id("com.android.library") version "7.4.2"
77
id("maven-publish")
88
id("signing")
9-
id("io.gitlab.arturbosch.detekt") version "1.23.1"
9+
id("io.gitlab.arturbosch.detekt") version "1.23.3"
1010
id("org.sonarqube") version "4.3.1.3277"
1111
id("org.jetbrains.kotlinx.kover") version "0.6.1"
1212
id("com.asarkar.gradle.build-time-tracker") version "4.3.0"
1313
id("me.qoomon.git-versioning") version "6.4.2"
1414
id("com.goncalossilva.resources") version "0.4.0"
15-
id("com.github.ben-manes.versions") version "0.48.0"
15+
id("com.github.ben-manes.versions") version "0.49.0"
1616
}
1717

1818
repositories {
@@ -22,7 +22,7 @@ repositories {
2222

2323
val productName = "Ashampoo XMP Core"
2424

25-
val ktorVersion: String = "2.3.4"
25+
val ktorVersion: String = "2.3.5"
2626
val xmlUtilVersion: String = "0.86.2"
2727

2828
description = productName
@@ -111,7 +111,7 @@ koverMerged {
111111
}
112112

113113
dependencies {
114-
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
114+
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
115115
}
116116

117117
kotlin {
@@ -148,8 +148,10 @@ kotlin {
148148

149149
dependencies {
150150

151-
/* Needed for Charset class. */
152-
/* Defined as api() to prevent problems when used from a pure-java project. */
151+
/*
152+
* Needed for Charset class.
153+
* Defined as api() to prevent problems when used from a pure-java project.
154+
*/
153155
api("io.ktor:ktor-io:$ktorVersion")
154156

155157
/* Needed to parse XML and create a DOM Document */
@@ -169,7 +171,7 @@ kotlin {
169171
implementation("com.goncalossilva:resources:0.4.0")
170172

171173
/* Multiplatform file access */
172-
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.2.1")
174+
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.3.0")
173175
}
174176
}
175177

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
android.useAndroidX=true
22
kotlin.code.style=official
33
kotlin.mpp.androidSourceSetLayoutVersion=2
4+
kotlin.mpp.applyDefaultHierarchyTemplate=false
45
kotlin.mpp.enableCInteropCommonization=true
56
kotlin.mpp.stability.nowarn=true
67
org.gradle.caching=true

src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ interface XMPMeta {
124124
* *Note:* Qualifiers are only supported for simple leaf properties.
125125
*
126126
* @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty.
127-
* @param structName The name of the struct.
127+
* @param propName The name of the struct.
128128
* May be a general path expression, must not be `null` or the empty string.
129129
* Has the same namespace prefix usage as propName in `getProperty()`.
130130
* @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the

src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPIteratorImpl.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ class XMPIteratorImpl(
123123
else
124124
nodeIterator = NodeIteratorChildren(startNode, initialPath)
125125

126-
} else
126+
} else {
127+
127128
nodeIterator = emptySequence<XMPPropertyInfo>().iterator()
129+
}
128130
}
129131

130132
override fun skipSubtree() {

src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class XMPMetaImpl : XMPMeta {
153153
throw XMPException(XMPError.EMPTY_SCHEMA_TEXT, XMPError.BADPARAM)
154154

155155
if (propName.isEmpty())
156-
throw XMPException("Empty property name", XMPError.BADPARAM)
156+
throw XMPException("Can't delete empty property name.", XMPError.BADPARAM)
157157

158158
val propNode = findNode(
159159
xmpTree = this.root,
@@ -299,7 +299,7 @@ class XMPMetaImpl : XMPMeta {
299299
if (specificLang.isEmpty())
300300
throw XMPException("Empty specific language", XMPError.BADPARAM)
301301

302-
val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
302+
val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
303303
val normalizedSpecificLang = normalizeLangValue(specificLang)
304304

305305
val arrayPath = expandXPath(schemaNS, altTextName)
@@ -313,21 +313,18 @@ class XMPMetaImpl : XMPMeta {
313313
return if (match != XMPNodeUtils.CLT_NO_VALUES) {
314314

315315
object : XMPProperty {
316-
override fun getValue(): String {
317-
return itemNode!!.value!!
318-
}
319316

320-
override fun getOptions(): PropertyOptions {
321-
return itemNode!!.options
322-
}
317+
override fun getValue(): String =
318+
itemNode!!.value!!
323319

324-
override fun getLanguage(): String {
325-
return itemNode!!.getQualifier(1).value!!
326-
}
320+
override fun getOptions(): PropertyOptions =
321+
itemNode!!.options
327322

328-
override fun toString(): String {
329-
return itemNode!!.value.toString()
330-
}
323+
override fun getLanguage(): String =
324+
itemNode!!.getQualifier(1).value!!
325+
326+
override fun toString(): String =
327+
itemNode!!.value.toString()
331328
}
332329

333330
} else {
@@ -353,7 +350,7 @@ class XMPMetaImpl : XMPMeta {
353350
if (specificLang.isEmpty())
354351
throw XMPException("Empty specific language", XMPError.BADPARAM)
355352

356-
val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
353+
val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
357354
val normalizedSpecificLang = normalizeLangValue(specificLang)
358355

359356
val arrayPath = expandXPath(schemaNS, altTextName)
@@ -522,21 +519,17 @@ class XMPMetaImpl : XMPMeta {
522519

523520
return object : XMPProperty {
524521

525-
override fun getValue(): String? {
526-
return value?.toString()
527-
}
522+
override fun getValue(): String? =
523+
value?.toString()
528524

529-
override fun getOptions(): PropertyOptions {
530-
return propNode.options
531-
}
525+
override fun getOptions(): PropertyOptions =
526+
propNode.options
532527

533-
override fun getLanguage(): String? {
534-
return null
535-
}
528+
override fun getLanguage(): String? =
529+
null
536530

537-
override fun toString(): String {
538-
return value.toString()
539-
}
531+
override fun toString(): String =
532+
value.toString()
540533
}
541534
}
542535

src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ object XMPNodeUtils {
353353
val index = when (stepKind) {
354354

355355
XMPPath.ARRAY_INDEX_STEP ->
356-
findIndexedItem(parentNode, nextStep.name, createNodes)
356+
findIndexedItem(parentNode, nextStep.name!!, createNodes)
357357

358358
XMPPath.ARRAY_LAST_STEP ->
359359
parentNode.getChildrenLength()
@@ -418,15 +418,15 @@ object XMPNodeUtils {
418418
* @param createNodes flag if new nodes are allowed to be created.
419419
* @return Returns the index or index = -1 if not found
420420
*/
421-
private fun findIndexedItem(arrayNode: XMPNode?, segment: String?, createNodes: Boolean): Int {
421+
private fun findIndexedItem(arrayNode: XMPNode, segment: String, createNodes: Boolean): Int {
422422

423423
var index: Int
424424

425425
try {
426426

427-
var segment = segment!!.substring(1, segment.length - 1)
427+
val innerSegment = segment.substring(1, segment.length - 1)
428428

429-
index = segment.toInt()
429+
index = innerSegment.toInt()
430430

431431
if (index < 1)
432432
throw XMPException("Array index must be larger than zero", XMPError.BADXPATH)
@@ -435,7 +435,7 @@ object XMPNodeUtils {
435435
throw XMPException("Array index not digits.", XMPError.BADXPATH, ex)
436436
}
437437

438-
if (createNodes && index == arrayNode!!.getChildrenLength() + 1) {
438+
if (createNodes && index == arrayNode.getChildrenLength() + 1) {
439439

440440
// Append a new last + 1 node.
441441
val newItem = XMPNode(XMPConst.ARRAY_ITEM_NAME, null)

src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,15 @@ internal object XMPNormalizer {
7272
val path = expandXPath(XMPConst.NS_XMP_MM, "InstanceID")
7373
val idNode = XMPNodeUtils.findNode(tree, path, true, null)
7474

75-
if (idNode != null) {
76-
77-
idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
78-
idNode.value = "uuid:$nameStr"
79-
idNode.removeChildren()
80-
idNode.removeQualifiers()
75+
if (idNode == null)
76+
throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)
8177

82-
tree.name = null
78+
idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
79+
idNode.value = "uuid:$nameStr"
80+
idNode.removeChildren()
81+
idNode.removeQualifiers()
8382

84-
} else
85-
throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)
83+
tree.name = null
8684
}
8785
}
8886
}

src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ internal object XMPRDFParser {
436436

437437
parseRdfLiteralPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)
438438

439-
} else
439+
} else {
440+
440441
parseEmptyPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)
442+
}
441443
}
442444
}
443445

@@ -477,7 +479,7 @@ internal object XMPRDFParser {
477479
if (XMPConst.XML_LANG == attribute.nodeName)
478480
addQualifierNode(newCompound, XMPConst.XML_LANG, attribute.value)
479481
else if ("ID" == attribute.localName && XMPConst.NS_RDF == attribute.namespaceURI)
480-
continue // Ignore all rdf:ID attributes.
482+
continue
481483
else
482484
throw XMPException("Invalid attribute for resource property element", XMPError.BADRDF)
483485
}
@@ -582,7 +584,7 @@ internal object XMPRDFParser {
582584
XMPConst.NS_RDF == attribute.namespaceURI &&
583585
("ID" == attribute.localName || "datatype" == attribute.localName)
584586
)
585-
continue // Ignore all rdf:ID and rdf:datatype attributes.
587+
continue
586588
else
587589
throw XMPException("Invalid attribute for literal property element", XMPError.BADRDF)
588590
}

0 commit comments

Comments
 (0)