From 60cb608956c9b4e268051a6f70152952609e6a3b Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Mon, 14 May 2018 17:13:19 -0400 Subject: [PATCH] Move Kotlin reflection into a kotlin/reflect directory The maven coordinates stay the same. --- kotlin/{ => reflect}/pom.xml | 0 .../com/squareup/moshi/KotlinJsonAdapter.kt | 6 ++- .../kotlin/reflect}/KotlinJsonAdapter.kt | 6 +-- kotlin/tests/pom.xml | 5 ++ .../kotlin/reflect}/KotlinJsonAdapterTest.kt | 46 +++++++++---------- pom.xml | 2 +- 6 files changed, 36 insertions(+), 29 deletions(-) rename kotlin/{ => reflect}/pom.xml (100%) rename kotlin/{ => reflect}/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt (77%) rename kotlin/{src/main/java/com/squareup/moshi/kotlin => reflect/src/main/java/com/squareup/moshi/kotlin/reflect}/KotlinJsonAdapter.kt (98%) rename kotlin/{src/test/java/com/squareup/moshi/kotlin => tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect}/KotlinJsonAdapterTest.kt (94%) diff --git a/kotlin/pom.xml b/kotlin/reflect/pom.xml similarity index 100% rename from kotlin/pom.xml rename to kotlin/reflect/pom.xml diff --git a/kotlin/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt b/kotlin/reflect/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt similarity index 77% rename from kotlin/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt rename to kotlin/reflect/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt index be25787..ee2d0fb 100644 --- a/kotlin/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt +++ b/kotlin/reflect/src/main/java/com/squareup/moshi/KotlinJsonAdapter.kt @@ -15,9 +15,11 @@ */ package com.squareup.moshi +import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory + @Deprecated( message = "this moved to avoid a package name conflict in the Java Platform Module System.", - replaceWith = ReplaceWith("com.squareup.moshi.kotlin.KotlinJsonAdapterFactory") + replaceWith = ReplaceWith("com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory") ) class KotlinJsonAdapterFactory - : JsonAdapter.Factory by com.squareup.moshi.kotlin.KotlinJsonAdapterFactory() + : JsonAdapter.Factory by KotlinJsonAdapterFactory() diff --git a/kotlin/src/main/java/com/squareup/moshi/kotlin/KotlinJsonAdapter.kt b/kotlin/reflect/src/main/java/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapter.kt similarity index 98% rename from kotlin/src/main/java/com/squareup/moshi/kotlin/KotlinJsonAdapter.kt rename to kotlin/reflect/src/main/java/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapter.kt index 82762f0..3bc8eaa 100644 --- a/kotlin/src/main/java/com/squareup/moshi/kotlin/KotlinJsonAdapter.kt +++ b/kotlin/reflect/src/main/java/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapter.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.squareup.moshi.kotlin +package com.squareup.moshi.kotlin.reflect import com.squareup.moshi.Json import com.squareup.moshi.JsonAdapter @@ -228,8 +228,8 @@ class KotlinJsonAdapterFactory : JsonAdapter.Factory { val adapter = moshi.adapter( resolvedPropertyType, Util.jsonAnnotations(allAnnotations.toTypedArray())) - bindingsByName[property.name] = - KotlinJsonAdapter.Binding(name, adapter, property as KProperty1, parameter) + bindingsByName[property.name] = KotlinJsonAdapter.Binding(name, adapter, + property as KProperty1, parameter) } val bindings = ArrayList?>() diff --git a/kotlin/tests/pom.xml b/kotlin/tests/pom.xml index 97026ae..100f6e4 100644 --- a/kotlin/tests/pom.xml +++ b/kotlin/tests/pom.xml @@ -18,6 +18,11 @@ moshi ${project.version} + + com.squareup.moshi + moshi-kotlin + ${project.version} + org.jetbrains.kotlin kotlin-stdlib diff --git a/kotlin/src/test/java/com/squareup/moshi/kotlin/KotlinJsonAdapterTest.kt b/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt similarity index 94% rename from kotlin/src/test/java/com/squareup/moshi/kotlin/KotlinJsonAdapterTest.kt rename to kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt index 9255f63..f671d60 100644 --- a/kotlin/src/test/java/com/squareup/moshi/kotlin/KotlinJsonAdapterTest.kt +++ b/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.squareup.moshi.kotlin +package com.squareup.moshi.kotlin.reflect import com.squareup.moshi.FromJson import com.squareup.moshi.Json @@ -350,7 +350,7 @@ class KotlinJsonAdapterTest { } catch (expected: IllegalArgumentException) { assertThat(expected).hasMessage("No default value for transient constructor parameter #0 " + "a of fun (kotlin.Int): " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest.RequiredTransientConstructorParameter") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter") } } @@ -637,7 +637,7 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("No JsonAdapter for interface " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$Interface (with no annotations)") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$Interface (with no annotations)") } } @@ -650,7 +650,7 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("Cannot serialize abstract class " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$AbstractClass") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$AbstractClass") } } @@ -663,7 +663,7 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("Cannot serialize inner class " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$InnerClass") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$InnerClass") } } @@ -677,7 +677,7 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("Cannot serialize local class or object expression " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$localClassesNotSupported\$LocalClass") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$localClassesNotSupported\$LocalClass") } } @@ -688,7 +688,7 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("Cannot serialize object declaration " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$ObjectDeclaration") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$ObjectDeclaration") } } @@ -706,8 +706,8 @@ class KotlinJsonAdapterTest { fail() } catch (e: IllegalArgumentException) { assertThat(e).hasMessage("Cannot serialize local class or object expression " + - "com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$objectExpressionsNotSupported" + - "\$expression$1") + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$objectExpressionsNotSupported" + + "\$expression$1") } } @@ -743,13 +743,13 @@ class KotlinJsonAdapterTest { } class ManyProperties32( - var v01: Int, var v02: Int, var v03: Int, var v04: Int, var v05: Int, - var v06: Int, var v07: Int, var v08: Int, var v09: Int, var v10: Int, - var v11: Int, var v12: Int, var v13: Int, var v14: Int, var v15: Int, - var v16: Int, var v17: Int, var v18: Int, var v19: Int, var v20: Int, - var v21: Int, var v22: Int, var v23: Int, var v24: Int, var v25: Int, - var v26: Int, var v27: Int, var v28: Int, var v29: Int, var v30: Int, - var v31: Int, var v32: Int) + var v01: Int, var v02: Int, var v03: Int, var v04: Int, var v05: Int, + var v06: Int, var v07: Int, var v08: Int, var v09: Int, var v10: Int, + var v11: Int, var v12: Int, var v13: Int, var v14: Int, var v15: Int, + var v16: Int, var v17: Int, var v18: Int, var v19: Int, var v20: Int, + var v21: Int, var v22: Int, var v23: Int, var v24: Int, var v25: Int, + var v26: Int, var v27: Int, var v28: Int, var v29: Int, var v30: Int, + var v31: Int, var v32: Int) @Test fun manyProperties33() { val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() @@ -784,13 +784,13 @@ class KotlinJsonAdapterTest { } class ManyProperties33( - var v01: Int, var v02: Int, var v03: Int, var v04: Int, var v05: Int, - var v06: Int, var v07: Int, var v08: Int, var v09: Int, var v10: Int, - var v11: Int, var v12: Int, var v13: Int, var v14: Int, var v15: Int, - var v16: Int, var v17: Int, var v18: Int, var v19: Int, var v20: Int, - var v21: Int, var v22: Int, var v23: Int, var v24: Int, var v25: Int, - var v26: Int, var v27: Int, var v28: Int, var v29: Int, var v30: Int, - var v31: Int, var v32: Int, var v33: Int) + var v01: Int, var v02: Int, var v03: Int, var v04: Int, var v05: Int, + var v06: Int, var v07: Int, var v08: Int, var v09: Int, var v10: Int, + var v11: Int, var v12: Int, var v13: Int, var v14: Int, var v15: Int, + var v16: Int, var v17: Int, var v18: Int, var v19: Int, var v20: Int, + var v21: Int, var v22: Int, var v23: Int, var v24: Int, var v25: Int, + var v26: Int, var v27: Int, var v28: Int, var v29: Int, var v30: Int, + var v31: Int, var v32: Int, var v33: Int) data class Box(val data: T) diff --git a/pom.xml b/pom.xml index b1ed608..a8d3507 100644 --- a/pom.xml +++ b/pom.xml @@ -21,8 +21,8 @@ moshi examples adapters - kotlin kotlin/codegen + kotlin/reflect kotlin/tests