Skip to content

Commit

Permalink
Kotlin 1.9.20 Update (#10)
Browse files Browse the repository at this point in the history
* Dependency updates, including Kotlin 1.9.20

* Fixed some style issues detected by the linter.

* Fixed shadowed argument warnings.

* Renamed launch script.

* Source format.
  • Loading branch information
StefanOltmann authored Nov 3, 2023
1 parent cc313c0 commit 0ff63fb
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 136 deletions.

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

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMP Core for Kotlin Multiplatform

[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](httpw://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.20-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)
![macOS](https://img.shields.io/badge/-macOS-gray.svg?style=flat)
Expand All @@ -15,7 +15,7 @@ It's part of [Ashampoo Photos](https://ashampoo.com/photos).
## Installation

```
implementation("com.ashampoo:xmpcore:0.1.6")
implementation("com.ashampoo:xmpcore:0.1.7")
```

## How to use
Expand Down
18 changes: 10 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
kotlin("multiplatform") version "1.9.10"
kotlin("multiplatform") version "1.9.20"
id("com.android.library") version "7.4.2"
id("maven-publish")
id("signing")
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("io.gitlab.arturbosch.detekt") version "1.23.3"
id("org.sonarqube") version "4.3.1.3277"
id("org.jetbrains.kotlinx.kover") version "0.6.1"
id("com.asarkar.gradle.build-time-tracker") version "4.3.0"
id("me.qoomon.git-versioning") version "6.4.2"
id("com.goncalossilva.resources") version "0.4.0"
id("com.github.ben-manes.versions") version "0.48.0"
id("com.github.ben-manes.versions") version "0.49.0"
}

repositories {
Expand All @@ -22,7 +22,7 @@ repositories {

val productName = "Ashampoo XMP Core"

val ktorVersion: String = "2.3.4"
val ktorVersion: String = "2.3.5"
val xmlUtilVersion: String = "0.86.2"

description = productName
Expand Down Expand Up @@ -111,7 +111,7 @@ koverMerged {
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
}

kotlin {
Expand Down Expand Up @@ -148,8 +148,10 @@ kotlin {

dependencies {

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

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

/* Multiplatform file access */
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.2.1")
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.3.0")
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
android.useAndroidX=true
kotlin.code.style=official
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
org.gradle.caching=true
Expand Down
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ interface XMPMeta {
* *Note:* Qualifiers are only supported for simple leaf properties.
*
* @param schemaNS The namespace URI for the struct. Has the same usage as in getProperty.
* @param structName The name of the struct.
* @param propName The name of the struct.
* May be a general path expression, must not be `null` or the empty string.
* Has the same namespace prefix usage as propName in `getProperty()`.
* @param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ class XMPIteratorImpl(
else
nodeIterator = NodeIteratorChildren(startNode, initialPath)

} else
} else {

nodeIterator = emptySequence<XMPPropertyInfo>().iterator()
}
}

override fun skipSubtree() {
Expand Down
47 changes: 20 additions & 27 deletions src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPMetaImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class XMPMetaImpl : XMPMeta {
throw XMPException(XMPError.EMPTY_SCHEMA_TEXT, XMPError.BADPARAM)

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

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

val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
val normalizedSpecificLang = normalizeLangValue(specificLang)

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

object : XMPProperty {
override fun getValue(): String {
return itemNode!!.value!!
}

override fun getOptions(): PropertyOptions {
return itemNode!!.options
}
override fun getValue(): String =
itemNode!!.value!!

override fun getLanguage(): String {
return itemNode!!.getQualifier(1).value!!
}
override fun getOptions(): PropertyOptions =
itemNode!!.options

override fun toString(): String {
return itemNode!!.value.toString()
}
override fun getLanguage(): String =
itemNode!!.getQualifier(1).value!!

override fun toString(): String =
itemNode!!.value.toString()
}

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

val normalizedGenericLang = if (genericLang != null) normalizeLangValue(genericLang) else null
val normalizedGenericLang = genericLang?.let { normalizeLangValue(it) }
val normalizedSpecificLang = normalizeLangValue(specificLang)

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

return object : XMPProperty {

override fun getValue(): String? {
return value?.toString()
}
override fun getValue(): String? =
value?.toString()

override fun getOptions(): PropertyOptions {
return propNode.options
}
override fun getOptions(): PropertyOptions =
propNode.options

override fun getLanguage(): String? {
return null
}
override fun getLanguage(): String? =
null

override fun toString(): String {
return value.toString()
}
override fun toString(): String =
value.toString()
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNodeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ object XMPNodeUtils {
val index = when (stepKind) {

XMPPath.ARRAY_INDEX_STEP ->
findIndexedItem(parentNode, nextStep.name, createNodes)
findIndexedItem(parentNode, nextStep.name!!, createNodes)

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

var index: Int

try {

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

index = segment.toInt()
index = innerSegment.toInt()

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

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

// Append a new last + 1 node.
val newItem = XMPNode(XMPConst.ARRAY_ITEM_NAME, null)
Expand Down
16 changes: 7 additions & 9 deletions src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPNormalizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ internal object XMPNormalizer {
val path = expandXPath(XMPConst.NS_XMP_MM, "InstanceID")
val idNode = XMPNodeUtils.findNode(tree, path, true, null)

if (idNode != null) {

idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
idNode.value = "uuid:$nameStr"
idNode.removeChildren()
idNode.removeQualifiers()
if (idNode == null)
throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)

tree.name = null
idNode.options = PropertyOptions() // Clobber any existing xmpMM:InstanceID.
idNode.value = "uuid:$nameStr"
idNode.removeChildren()
idNode.removeQualifiers()

} else
throw XMPException("Failure creating xmpMM:InstanceID", XMPError.INTERNALFAILURE)
tree.name = null
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/commonMain/kotlin/com/ashampoo/xmp/impl/XMPRDFParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,10 @@ internal object XMPRDFParser {

parseRdfLiteralPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)

} else
} else {

parseEmptyPropertyElement(xmp, xmpParent, xmlNode, isTopLevel)
}
}
}

Expand Down Expand Up @@ -477,7 +479,7 @@ internal object XMPRDFParser {
if (XMPConst.XML_LANG == attribute.nodeName)
addQualifierNode(newCompound, XMPConst.XML_LANG, attribute.value)
else if ("ID" == attribute.localName && XMPConst.NS_RDF == attribute.namespaceURI)
continue // Ignore all rdf:ID attributes.
continue
else
throw XMPException("Invalid attribute for resource property element", XMPError.BADRDF)
}
Expand Down Expand Up @@ -582,7 +584,7 @@ internal object XMPRDFParser {
XMPConst.NS_RDF == attribute.namespaceURI &&
("ID" == attribute.localName || "datatype" == attribute.localName)
)
continue // Ignore all rdf:ID and rdf:datatype attributes.
continue
else
throw XMPException("Invalid attribute for literal property element", XMPError.BADRDF)
}
Expand Down
Loading

0 comments on commit 0ff63fb

Please sign in to comment.