Skip to content

Commit 696769a

Browse files
authored
Feature/convert for to (#26)
* Update Gradle * Update Libraries * Extend MapConvert * Make MapConvert working for to in KOMMMap annotation * Refactoring * Add Examples * Increase version * Update README * Fix issue
1 parent b0abbcc commit 696769a

File tree

18 files changed

+225
-103
lines changed

18 files changed

+225
-103
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ The **Kotlin Object Multiplatform Mapper** provides you a possibility to generat
7373
#### JVM Project
7474
```kotlin
7575
plugins {
76-
id("com.google.devtools.ksp") version "2.1.0-1.0.28"
76+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
7777
}
7878

79-
val kommVersion = "0.22.8"
79+
val kommVersion = "0.24.3"
8080

8181
depensencies {
8282
implementation("com.ucasoft.komm:komm-annotations:$kommVersion")
@@ -86,10 +86,10 @@ depensencies {
8686
#### Multiplatform Project
8787
```kotlin
8888
plugins {
89-
id("com.google.devtools.ksp") version "2.1.0-1.0.28"
89+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
9090
}
9191

92-
val kommVersion = "0.22.8"
92+
val kommVersion = "0.24.3"
9393

9494
kotlin {
9595
jvm {
@@ -260,7 +260,7 @@ fun SourceObject.toDestinationObject(): DestinationObject = DestinationObject(
260260
### Use Converter
261261
#### Converter declaration
262262
```kotlin
263-
class CostConverter(source: SourceObject) : KOMMConverter<SourceObject, Double, String>(source) {
263+
class CostConverter(source: SourceObject) : KOMMConverter<SourceObject, Double, DestinationObject, String>(source) {
264264

265265
override fun convert(sourceMember: Double) = "$sourceMember ${source.currency}"
266266
}
@@ -275,7 +275,7 @@ class SourceObject {
275275
@KOMMMap(from = [SourceObject::class])
276276
data class DestinationObject(
277277
//...
278-
@MapConvert<SourceObject, CostConverter>(CostConverter::class)
278+
@MapConvert<SourceObject, DestinationObject, CostConverter>(CostConverter::class)
279279
val cost: String
280280
) {
281281
//...
@@ -459,10 +459,10 @@ fun SecondSourceObject.toDestinationObject(): DestinationObject = DestinationObj
459459
###### JVM Project
460460
```kotlin
461461
plugins {
462-
id("com.google.devtools.ksp") version "2.1.0-1.0.28"
462+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
463463
}
464464

465-
val kommVersion = "0.22.8"
465+
val kommVersion = "0.24.3"
466466

467467
depensencies {
468468
implementation("com.ucasoft.komm:komm-annotations:$kommVersion")
@@ -473,10 +473,10 @@ depensencies {
473473
###### Multiplatform Project
474474
```kotlin
475475
plugins {
476-
id("com.google.devtools.ksp") version "2.1.0-1.0.28"
476+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
477477
}
478478

479-
val kommVersion = "0.22.8"
479+
val kommVersion = "0.24.3"
480480

481481
//...
482482

@@ -533,10 +533,10 @@ public fun SourceObject.toDestinationObject(): DestinationObject = DestinationOb
533533
###### JVM Project
534534
```kotlin
535535
plugins {
536-
id("com.google.devtools.ksp") version "2.1.0-1.0.28"
536+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
537537
}
538538

539-
val kommVersion = "0.22.8"
539+
val kommVersion = "0.24.3"
540540

541541
depensencies {
542542
implementation("com.ucasoft.komm:komm-annotations:$kommVersion")

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ plugins {
66
}
77

88
tasks.wrapper {
9-
gradleVersion = "8.12"
9+
gradleVersion = "8.14"
1010
}
1111

1212
allprojects {
1313
group = "com.ucasoft.komm"
1414

15-
version = "0.22.8"
15+
version = "0.24.3"
1616

1717
repositories {
1818
mavenCentral()

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ kotlin = "2.0.21"
33
ksp = "2.0.21-1.0.28"
44
kotlin-poet = "1.18.1"
55
compile-testing = "1.6.0"
6-
junit = "5.11.4"
6+
junit = "5.12.2"
77
kotest = "5.9.1"
88
kover = "0.9.1"
9-
mockk = "1.13.16"
9+
mockk = "1.14.2"
1010
classgraph = "4.8.179"
1111
exposed = "0.57.0"
1212

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ done
8686
# shellcheck disable=SC2034
8787
APP_BASE_NAME=${0##*/}
8888
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90-
' "$PWD" ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9190

9291
# Use the maximum available, or set MAX_FD != -1 to use that value.
9392
MAX_FD=maximum
@@ -115,7 +114,7 @@ case "$( uname )" in #(
115114
NONSTOP* ) nonstop=true ;;
116115
esac
117116

118-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
119118

120119

121120
# Determine the Java command to use to start the JVM.
@@ -206,15 +205,15 @@ fi
206205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207206

208207
# Collect all arguments for the java command:
209-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210209
# and any embedded shellness will be escaped.
211210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212211
# treated as '${Hostname}' itself on the command line.
213212

214213
set -- \
215214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
216215
-classpath "$CLASSPATH" \
217-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
218217
"$@"
219218

220219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7474

7575

7676
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7878

7979
:end
8080
@rem End local scope for the variables with windows NT shell
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ucasoft.komm.abstractions
22

3-
abstract class KOMMConverter<S, SM, DM>(protected val source: S) {
3+
abstract class KOMMConverter<S, SM, D, DM>(protected val source: S) {
44

55
abstract fun convert(sourceMember: SM) : DM
66
}

komm-annotations/src/main/kotlin/com/ucasoft/komm/annotations/MapConvert.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import kotlin.reflect.KClass
66
@Target(AnnotationTarget.PROPERTY)
77
@Retention(AnnotationRetention.SOURCE)
88
@Repeatable
9-
annotation class MapConvert<S: Any, C : KOMMConverter<S, *, *>>(val converter: KClass<C>, val name: String = "")
9+
annotation class MapConvert<S: Any, D: Any, C : KOMMConverter<S, *, D, *>>(val converter: KClass<C>, val name: String = "")

komm-processor/src/main/kotlin/com/ucasoft/komm/processor/KOMMAnnotationFinder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class KOMMAnnotationFinder(private val forClass: KSType) {
2929
forClass.toClassName(),
3030
member,
3131
MapConvert::class.simpleName,
32-
MapConvert<*, *>::converter.name
32+
MapConvert<*, *, *>::converter.name
3333
)
3434

3535
fun findSubstituteResolver(member: KSPropertyDeclaration): String? {
@@ -83,7 +83,7 @@ class KOMMAnnotationFinder(private val forClass: KSType) {
8383
}
8484

8585
if (item.annotationType.toString() == MapConvert::class.simpleName) {
86-
return listOf(item.annotationType.element!!.typeArguments.first().type!!.resolve().toClassName())
86+
return item.annotationType.element!!.typeArguments.take(2).map { it.type!!.resolve().toClassName() }
8787
}
8888

8989
return emptyList()

0 commit comments

Comments
 (0)