Skip to content

Commit

Permalink
Update to Kotlin 2.0.0 (#29)
Browse files Browse the repository at this point in the history
* Ignore new .kotlin folder

* Small fixes

* Kotlin update

* kotlinx-io update

* Update to latest xmlutil

* Try XMP Core 0.90.0-RC2

* Migrated to XMLUtil 0.90.0-RC3

* Updated to kotlinx-io 0.4.0

* Bumped version to 1.4.0

* Use Kotlin v2

* Source format & optimize imports
  • Loading branch information
StefanOltmann authored Jun 12, 2024
1 parent 9afa1c1 commit 5e65703
Show file tree
Hide file tree
Showing 223 changed files with 1,005 additions and 278 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
/.idea/vcs.xml
/.idea/workspace.xml
/.idea/xmpcore.iml
/.kotlin/
/build/
/local.properties
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.23-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 All @@ -20,7 +20,7 @@ It's part of [Ashampoo Photo Organizer](https://ashampoo.com/photo-organizer).
## Installation

```
implementation("com.ashampoo:xmpcore:1.3.0")
implementation("com.ashampoo:xmpcore:1.4.0")
```

## How to use
Expand Down
13 changes: 5 additions & 8 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.23"
kotlin("multiplatform") version "2.0.0"
id("com.android.library") version "8.2.2"
id("maven-publish")
id("signing")
Expand All @@ -24,8 +24,8 @@ repositories {

val productName = "Ashampoo XMP Core"

val xmlUtilVersion: String = "0.86.3"
val kotlinIoVersion: String = "0.3.1"
val xmlUtilVersion: String = "0.90.0-RC3"
val kotlinIoVersion: String = "0.4.0"

description = productName
group = "com.ashampoo"
Expand Down Expand Up @@ -157,11 +157,7 @@ kotlin {
js()

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

@OptIn(ExperimentalWasmDsl::class)
wasmWasi()
Expand All @@ -188,6 +184,7 @@ kotlin {
}
}

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

@Suppress("UnusedPrivateMember", "UNUSED_VARIABLE") // False positive
Expand Down
2 changes: 1 addition & 1 deletion examples/xmpcore-java-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
}

dependencies {
implementation 'com.ashampoo:xmpcore:1.3.0'
implementation 'com.ashampoo:xmpcore:1.4.0'
}

// Needed to make it work for the Gradle java plugin
Expand Down
4 changes: 2 additions & 2 deletions examples/xmpcore-kotlin-jvm-sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.9.23"
kotlin("jvm") version "2.0.0"
}

group = "com.ashampoo"
Expand All @@ -10,5 +10,5 @@ repositories {
}

dependencies {
implementation("com.ashampoo:xmpcore:1.3.0")
implementation("com.ashampoo:xmpcore:1.4.0")
}
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/com/ashampoo/xmp/XMPIterator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import com.ashampoo.xmp.internal.XMPErrorConst
import com.ashampoo.xmp.internal.XMPNode
import com.ashampoo.xmp.internal.XMPNodeUtils.findNode
import com.ashampoo.xmp.internal.XMPNodeUtils.findSchemaNode
import com.ashampoo.xmp.options.IteratorOptions
import com.ashampoo.xmp.options.PropertyOptions
import com.ashampoo.xmp.internal.XMPPath
import com.ashampoo.xmp.internal.XMPPathParser.expandXPath
import com.ashampoo.xmp.options.IteratorOptions
import com.ashampoo.xmp.options.PropertyOptions

/**
* Interface for the `XMPMeta` iteration services.
Expand Down
22 changes: 17 additions & 5 deletions src/commonMain/kotlin/com/ashampoo/xmp/XMPMeta.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.ashampoo.xmp.internal.XMPNodeUtils.findNode
import com.ashampoo.xmp.internal.XMPNodeUtils.setNodeValue
import com.ashampoo.xmp.internal.XMPNodeUtils.verifySetOptions
import com.ashampoo.xmp.internal.XMPNormalizer.normalize
import com.ashampoo.xmp.internal.XMPPathParser.expandXPath
import com.ashampoo.xmp.internal.XMPUtils.convertToBoolean
import com.ashampoo.xmp.internal.XMPUtils.convertToDouble
import com.ashampoo.xmp.internal.XMPUtils.convertToInteger
Expand All @@ -33,7 +34,6 @@ import com.ashampoo.xmp.internal.XMPUtils.decodeBase64
import com.ashampoo.xmp.options.IteratorOptions
import com.ashampoo.xmp.options.ParseOptions
import com.ashampoo.xmp.options.PropertyOptions
import com.ashampoo.xmp.internal.XMPPathParser.expandXPath

/**
* This class represents the set of XMP metadata as a DOM representation. It has methods to read and
Expand Down Expand Up @@ -106,7 +106,10 @@ public class XMPMeta internal constructor() {
) ?: return null

if (valueType != XMPValueType.STRING && propNode.options.isCompositeProperty())
throw XMPException("Property must be simple when a value type is requested", XMPErrorConst.BADXPATH)
throw XMPException(
"Property must be simple when a value type is requested",
XMPErrorConst.BADXPATH
)

val value = evaluateNodeValue(valueType, propNode)

Expand Down Expand Up @@ -547,7 +550,10 @@ public class XMPMeta internal constructor() {
} else {

// array options missing
throw XMPException("Explicit arrayOptions required to create new array", XMPErrorConst.BADOPTIONS)
throw XMPException(
"Explicit arrayOptions required to create new array",
XMPErrorConst.BADOPTIONS
)
}
}

Expand Down Expand Up @@ -1200,7 +1206,10 @@ public class XMPMeta internal constructor() {
}

else -> // does not happen under normal circumstances
throw XMPException("Unexpected result from ChooseLocalizedText", XMPErrorConst.INTERNALFAILURE)
throw XMPException(
"Unexpected result from ChooseLocalizedText",
XMPErrorConst.INTERNALFAILURE
)
}

// Add an x-default at the front if needed.
Expand Down Expand Up @@ -1297,7 +1306,10 @@ public class XMPMeta internal constructor() {
) ?: return null

if (valueType != XMPValueType.STRING && propNode.options.isCompositeProperty())
throw XMPException("Property must be simple when a value type is requested", XMPErrorConst.BADXPATH)
throw XMPException(
"Property must be simple when a value type is requested",
XMPErrorConst.BADXPATH
)

return evaluateNodeValue(valueType, propNode)
}
Expand Down
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/com/ashampoo/xmp/XMPVersionInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package com.ashampoo.xmp
public object XMPVersionInfo {

public const val MAJOR: Int = 1
public const val MINOR: Int = 3
public const val MINOR: Int = 4
public const val PATCH: Int = 0

public const val VERSION_MESSAGE: String =
Expand Down
4 changes: 3 additions & 1 deletion src/commonMain/kotlin/com/ashampoo/xmp/internal/DomParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package com.ashampoo.xmp.internal
import com.ashampoo.xmp.XMPException
import nl.adaptivity.xmlutil.DomWriter
import nl.adaptivity.xmlutil.EventType
import nl.adaptivity.xmlutil.dom.Document
import nl.adaptivity.xmlutil.XmlUtilInternal
import nl.adaptivity.xmlutil.dom2.Document
import nl.adaptivity.xmlutil.writeCurrent
import nl.adaptivity.xmlutil.xmlStreaming

internal object DomParser {

private const val RDF_RDF_END = "</rdf:RDF>"

@OptIn(XmlUtilInternal::class)
fun parseDocumentFromString(input: String): Document {

/*
Expand Down
18 changes: 8 additions & 10 deletions src/commonMain/kotlin/com/ashampoo/xmp/internal/XMPMetaParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import com.ashampoo.xmp.XMPConst
import com.ashampoo.xmp.XMPMeta
import com.ashampoo.xmp.internal.XMPNormalizer.normalize
import com.ashampoo.xmp.options.ParseOptions
import nl.adaptivity.xmlutil.dom.Element
import nl.adaptivity.xmlutil.dom.Node
import nl.adaptivity.xmlutil.dom.NodeConsts
import nl.adaptivity.xmlutil.dom.ProcessingInstruction
import nl.adaptivity.xmlutil.dom.childNodes
import nl.adaptivity.xmlutil.dom.nodeType
import nl.adaptivity.xmlutil.dom.getData
import nl.adaptivity.xmlutil.dom.getTarget
import nl.adaptivity.xmlutil.dom.length
import nl.adaptivity.xmlutil.dom.localName
import nl.adaptivity.xmlutil.dom.namespaceURI
import nl.adaptivity.xmlutil.dom2.Element
import nl.adaptivity.xmlutil.dom2.Node
import nl.adaptivity.xmlutil.dom2.ProcessingInstruction
import nl.adaptivity.xmlutil.dom2.childNodes
import nl.adaptivity.xmlutil.dom2.length
import nl.adaptivity.xmlutil.dom2.localName
import nl.adaptivity.xmlutil.dom2.namespaceURI
import nl.adaptivity.xmlutil.dom2.nodeType

/**
* This class replaces the `ExpatAdapter.cpp` and does the XML-parsing and fixes the prefix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ internal object XMPNodeUtils {

!parent.isImplicit ->
throw XMPException(
"Named children only allowed for schemas and structs: $childName", XMPErrorConst.BADXPATH
"Named children only allowed for schemas and structs: $childName",
XMPErrorConst.BADXPATH
)

parent.options.isArray() ->
throw XMPException("Named children not allowed for arrays: $childName", XMPErrorConst.BADXPATH)
throw XMPException(
"Named children not allowed for arrays: $childName",
XMPErrorConst.BADXPATH
)

createNodes ->
parent.options.setStruct(true)
Expand Down
10 changes: 6 additions & 4 deletions src/commonMain/kotlin/com/ashampoo/xmp/internal/XMPNormalizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import com.ashampoo.xmp.XMPException
import com.ashampoo.xmp.XMPMeta
import com.ashampoo.xmp.XMPSchemaRegistry
import com.ashampoo.xmp.internal.Utils.checkUUIDFormat
import com.ashampoo.xmp.internal.XMPPathParser.expandXPath
import com.ashampoo.xmp.options.ParseOptions
import com.ashampoo.xmp.options.PropertyOptions
import com.ashampoo.xmp.internal.XMPPathParser.expandXPath

internal object XMPNormalizer {

Expand Down Expand Up @@ -355,10 +355,9 @@ internal object XMPNormalizer {
/**
* Moves an alias node of array form to another schema into an array
*
* @param removeChildFromTree lambda used to delete the property of the schema
* @param childNode the node to be moved
* @param baseArray the base array for the array item
*
* @param removeChildFromTree lambda used to delete the property of the schema
*/
private fun transplantArrayItemAlias(
childNode: XMPNode,
Expand All @@ -370,7 +369,10 @@ internal object XMPNormalizer {

// *** Allow x-default.
if (childNode.options.hasLanguage())
throw XMPException("Alias to x-default already has a language qualifier", XMPErrorConst.BADXMP)
throw XMPException(
"Alias to x-default already has a language qualifier",
XMPErrorConst.BADXMP
)

val langQual = XMPNode(XMPConst.XML_LANG, XMPConst.X_DEFAULT)

Expand Down
Loading

0 comments on commit 5e65703

Please sign in to comment.