-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switching to Kotlin Multiplatform for JVM use (#1654)
* Transition to Kotlin Multiplatform for JVM use * Use jvmTest task instead of test task * Apply KMP plugin only to the kotlinpoet module * Fix setup check task * Fix targetExclude folder as the source set name change * Move Java code to jvmMain directory * Apply dokka workaround * Use js(IR) as phantom target * Update kotlinpoet/build.gradle.kts * Update kotlinpoet/build.gradle.kts * Update kotlinpoet/build.gradle.kts * Update gradle/libs.versions.toml * Update kotlinpoet/build.gradle.kts --------- Co-authored-by: Jake Wharton <[email protected]>
- Loading branch information
1 parent
26b5a71
commit 69c8b38
Showing
79 changed files
with
180 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*/ | ||
plugins { | ||
id("com.google.devtools.ksp") | ||
kotlin("jvm") | ||
} | ||
|
||
tasks.compileTestKotlin { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
kotlinpoet/src/jvmTest/java/com/squareup/kotlinpoet/JavaAnnotationSpecTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (C) 2015 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import com.google.testing.compile.CompilationRule | ||
import kotlin.test.Test | ||
import org.junit.Rule | ||
|
||
class JavaAnnotationSpecTest { | ||
|
||
@Rule @JvmField | ||
val compilation = CompilationRule() | ||
|
||
@Test fun getOnValueArrayTypeMirrorShouldNameValueArg() { | ||
val myClazz = compilation.elements | ||
.getTypeElement(JavaClassWithArrayValueAnnotation::class.java.canonicalName) | ||
val classBuilder = TypeSpec.classBuilder("Result") | ||
|
||
myClazz.annotationMirrors.map { AnnotationSpec.get(it) } | ||
.forEach { | ||
classBuilder.addAnnotation(it) | ||
} | ||
|
||
assertThat(toString(classBuilder.build())).isEqualTo( | ||
""" | ||
|package com.squareup.tacos | ||
| | ||
|import com.squareup.kotlinpoet.JavaClassWithArrayValueAnnotation | ||
|import java.lang.Boolean | ||
|import java.lang.Object | ||
| | ||
|@JavaClassWithArrayValueAnnotation.AnnotationWithArrayValue(value = arrayOf(Object::class, | ||
| Boolean::class)) | ||
|public class Result | ||
| | ||
""".trimMargin(), | ||
) | ||
} | ||
|
||
@Test fun getOnValueArrayTypeAnnotationShouldNameValueArg() { | ||
val annotation = JavaClassWithArrayValueAnnotation::class.java.getAnnotation( | ||
JavaClassWithArrayValueAnnotation.AnnotationWithArrayValue::class.java, | ||
) | ||
val classBuilder = TypeSpec.classBuilder("Result") | ||
.addAnnotation(AnnotationSpec.get(annotation)) | ||
|
||
assertThat(toString(classBuilder.build()).trim()).isEqualTo( | ||
""" | ||
|package com.squareup.tacos | ||
| | ||
|import com.squareup.kotlinpoet.JavaClassWithArrayValueAnnotation | ||
|import java.lang.Boolean | ||
|import java.lang.Object | ||
| | ||
|@JavaClassWithArrayValueAnnotation.AnnotationWithArrayValue(value = arrayOf(Object::class, | ||
| Boolean::class)) | ||
|public class Result | ||
""".trimMargin(), | ||
) | ||
} | ||
|
||
private fun toString(typeSpec: TypeSpec) = | ||
FileSpec.get("com.squareup.tacos", typeSpec).toString() | ||
} |
File renamed without changes.
File renamed without changes.