Move Kotlin reflection into a kotlin/reflect directory

The maven coordinates stay the same.
This commit is contained in:
Jesse Wilson
2018-05-14 17:13:19 -04:00
parent a0df085b81
commit 60cb608956
6 changed files with 36 additions and 29 deletions

View File

@@ -15,9 +15,11 @@
*/ */
package com.squareup.moshi package com.squareup.moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
@Deprecated( @Deprecated(
message = "this moved to avoid a package name conflict in the Java Platform Module System.", 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 class KotlinJsonAdapterFactory
: JsonAdapter.Factory by com.squareup.moshi.kotlin.KotlinJsonAdapterFactory() : JsonAdapter.Factory by KotlinJsonAdapterFactory()

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.squareup.moshi.kotlin package com.squareup.moshi.kotlin.reflect
import com.squareup.moshi.Json import com.squareup.moshi.Json
import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonAdapter
@@ -228,8 +228,8 @@ class KotlinJsonAdapterFactory : JsonAdapter.Factory {
val adapter = moshi.adapter<Any>( val adapter = moshi.adapter<Any>(
resolvedPropertyType, Util.jsonAnnotations(allAnnotations.toTypedArray())) resolvedPropertyType, Util.jsonAnnotations(allAnnotations.toTypedArray()))
bindingsByName[property.name] = bindingsByName[property.name] = KotlinJsonAdapter.Binding(name, adapter,
KotlinJsonAdapter.Binding(name, adapter, property as KProperty1<Any, Any?>, parameter) property as KProperty1<Any, Any?>, parameter)
} }
val bindings = ArrayList<KotlinJsonAdapter.Binding<Any, Any?>?>() val bindings = ArrayList<KotlinJsonAdapter.Binding<Any, Any?>?>()

View File

@@ -18,6 +18,11 @@
<artifactId>moshi</artifactId> <artifactId>moshi</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.squareup.moshi</groupId>
<artifactId>moshi-kotlin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.jetbrains.kotlin</groupId> <groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId> <artifactId>kotlin-stdlib</artifactId>

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.squareup.moshi.kotlin package com.squareup.moshi.kotlin.reflect
import com.squareup.moshi.FromJson import com.squareup.moshi.FromJson
import com.squareup.moshi.Json import com.squareup.moshi.Json
@@ -350,7 +350,7 @@ class KotlinJsonAdapterTest {
} catch (expected: IllegalArgumentException) { } catch (expected: IllegalArgumentException) {
assertThat(expected).hasMessage("No default value for transient constructor parameter #0 " + assertThat(expected).hasMessage("No default value for transient constructor parameter #0 " +
"a of fun <init>(kotlin.Int): " + "a of fun <init>(kotlin.Int): " +
"com.squareup.moshi.kotlin.KotlinJsonAdapterTest.RequiredTransientConstructorParameter") "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter")
} }
} }
@@ -637,7 +637,7 @@ class KotlinJsonAdapterTest {
fail() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("No JsonAdapter for interface " + 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() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("Cannot serialize abstract class " + 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() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("Cannot serialize inner class " + 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() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("Cannot serialize local class or object expression " + 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() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("Cannot serialize object declaration " + assertThat(e).hasMessage("Cannot serialize object declaration " +
"com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$ObjectDeclaration") "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$ObjectDeclaration")
} }
} }
@@ -706,7 +706,7 @@ class KotlinJsonAdapterTest {
fail() fail()
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
assertThat(e).hasMessage("Cannot serialize local class or object expression " + assertThat(e).hasMessage("Cannot serialize local class or object expression " +
"com.squareup.moshi.kotlin.KotlinJsonAdapterTest\$objectExpressionsNotSupported" + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$objectExpressionsNotSupported" +
"\$expression$1") "\$expression$1")
} }
} }

View File

@@ -21,8 +21,8 @@
<module>moshi</module> <module>moshi</module>
<module>examples</module> <module>examples</module>
<module>adapters</module> <module>adapters</module>
<module>kotlin</module>
<module>kotlin/codegen</module> <module>kotlin/codegen</module>
<module>kotlin/reflect</module>
<module>kotlin/tests</module> <module>kotlin/tests</module>
</modules> </modules>