Prepare project for Kotlin migration (#1257)

This commit is contained in:
Zac Sweers
2021-02-02 13:11:38 -05:00
committed by GitHub
parent 8518f47f52
commit 6e5bb3a29b
17 changed files with 162 additions and 45 deletions

View File

@@ -25,16 +25,11 @@ plugins {
id("com.github.johnrengelman.shadow") version "6.0.0"
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf(
"-progressive",
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview"
)
}

View File

@@ -46,9 +46,9 @@ import javax.tools.Diagnostic
*/
@AutoService(Processor::class)
@IncrementalAnnotationProcessor(ISOLATING)
class JsonClassCodegenProcessor : AbstractProcessor() {
public class JsonClassCodegenProcessor : AbstractProcessor() {
companion object {
public companion object {
/**
* This annotation processing argument can be specified to have a `@Generated` annotation
* included in the generated code. It is not encouraged unless you need it for static analysis
@@ -58,7 +58,7 @@ class JsonClassCodegenProcessor : AbstractProcessor() {
* * `"javax.annotation.processing.Generated"` (JRE 9+)
* * `"javax.annotation.Generated"` (JRE <9)
*/
const val OPTION_GENERATED = "moshi.generated"
public const val OPTION_GENERATED: String = "moshi.generated"
private val POSSIBLE_GENERATED_NAMES = arrayOf(
ClassName("javax.annotation.processing", "Generated"),
ClassName("javax.annotation", "Generated")
@@ -73,11 +73,11 @@ class JsonClassCodegenProcessor : AbstractProcessor() {
private val annotation = JsonClass::class.java
private var generatedType: ClassName? = null
override fun getSupportedAnnotationTypes() = setOf(annotation.canonicalName)
override fun getSupportedAnnotationTypes(): Set<String> = setOf(annotation.canonicalName)
override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.latest()
override fun getSupportedOptions() = setOf(OPTION_GENERATED)
override fun getSupportedOptions(): Set<String> = setOf(OPTION_GENERATED)
override fun init(processingEnv: ProcessingEnvironment) {
super.init(processingEnv)

View File

@@ -37,7 +37,7 @@ import com.squareup.moshi.Types
* Rendering is pluggable so that type variables can either be resolved or emitted as other code
* blocks.
*/
abstract class TypeRenderer {
internal abstract class TypeRenderer {
abstract fun renderTypeVariable(typeVariable: TypeVariableName): CodeBlock
fun render(typeName: TypeName, forceBox: Boolean = false): CodeBlock {