Change gradle plugin default to Kotlin sources (#442)
This commit is contained in:
Родитель
163326db79
Коммит
0966b06f28
|
@ -1,12 +1,12 @@
|
|||
Gradle Plugin
|
||||
-------------------
|
||||
|
||||
Thrifty's Gradle plugin allows one to incorporate .thrift source files into a Java/Kotlin project
|
||||
and have Thrifty generate Java/Kotlin code from them as part of regular builds.
|
||||
Thrifty's Gradle plugin allows one to incorporate .thrift source files into a project
|
||||
and have Thrifty generate Kotlin or Java code from them as part of regular builds.
|
||||
|
||||
Incorporate it into your build like so:
|
||||
|
||||
```gradle
|
||||
```groovy
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'com.microsoft.thrifty'
|
||||
|
||||
|
@ -44,9 +44,9 @@ thrifty {
|
|||
// you can specify a different location:
|
||||
outputDir 'some/other/location'
|
||||
|
||||
// By default, Java sources will be generated. You can provide a few options to the Java
|
||||
// code generator (all options shown with their default values):
|
||||
java {
|
||||
// By default, Kotlin sources will be generated. You can provide a few options to the
|
||||
// Kotlin code generator (all options shown with their default values):
|
||||
kotlin {
|
||||
// Thrift service implementations are generated by default. Set 'false'
|
||||
// here to prevent them from being generated.
|
||||
emitServiceClients true
|
||||
|
@ -55,34 +55,19 @@ thrifty {
|
|||
// Other choices are 'java' and 'pascal' - 'someField' and 'SomeField', respectively.
|
||||
nameStyle 'default'
|
||||
|
||||
// Standard Java collections are used by default. If you want something custom, provide
|
||||
// Standard Kotlin collections are used by default. If you want something custom, provide
|
||||
// that here.
|
||||
// For example, you might choose 'android.util.ArrayMap' for maps.
|
||||
listType 'java.util.ArrayList'
|
||||
setType 'java.util.LinkedHashSet'
|
||||
mapType 'java.util.LinkedHashMap'
|
||||
listType 'kotlin.collections.ArrayList'
|
||||
setType 'kotlin.collections.LinkedHashSet'
|
||||
mapType 'kotlin.collections.LinkedHashMap'
|
||||
|
||||
// Specify an annotation type name if you want Thrifty to tag generated classes
|
||||
// with it. Known-compatible annotation types are 'javax.annotation.Generated'
|
||||
// (pre JDK-9) and 'javax.annotation.processing.Generated' (post JDK-9).
|
||||
//
|
||||
// The default behavior is that no annotation is supplied.
|
||||
generatedAnnotationType null
|
||||
// When true, generated structs will implement the Parcelable interface. This is optional,
|
||||
// and results in larger code.
|
||||
parcelable = false
|
||||
|
||||
// All of the options above are applicable to Kotlin. Options below are Java-specific.
|
||||
|
||||
// Specifies which kind of nullability annotations to add to generated code, if any.
|
||||
//
|
||||
// valid values are 'none' (the default), 'android-support', and 'androidx'.
|
||||
nullabilityAnnotationKind 'none'
|
||||
}
|
||||
|
||||
// On the other hand, if you want Kotlin sources, then _don't_ add the java block. Add at
|
||||
// least an empty 'kotlin' block - all options shown here may be left out entirely.
|
||||
kotlin {
|
||||
// Most of the options shown in the java block above also apply here.
|
||||
|
||||
// Kotlin-specific options follow.
|
||||
// The above options are also applicable to the 'java' block; Kotlin-specific options
|
||||
// follow.
|
||||
|
||||
// When true, generated structs will be include 'Builder' inner classes. This is
|
||||
// for legacy compatibiltity only, and leads to larger code.
|
||||
|
@ -92,5 +77,17 @@ thrifty {
|
|||
// Vaid values are 'default' (the default), 'coroutine', and 'none'.
|
||||
serviceClientStyle 'default'
|
||||
}
|
||||
|
||||
|
||||
// On the other hand, if you want Java sources, then _don't_ add the kotlin block. Add at
|
||||
// least an empty 'java' block - all options shown here may be left out entirely.
|
||||
java {
|
||||
// Most of the options shown in the kotlin block above also apply here.
|
||||
|
||||
// Specifies which kind of nullability annotations to add to generated code, if any.
|
||||
//
|
||||
// valid values are 'none' (the default), 'android-support', and 'androidx'.
|
||||
nullabilityAnnotationKind 'none'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class ThriftyExtension @Inject constructor(
|
|||
.include("**/*.thrift") as SourceDirectorySet)))
|
||||
|
||||
val thriftOptions: Property<ThriftOptions> = objects.property(ThriftOptions::class.java)
|
||||
.convention(JavaThriftOptions())
|
||||
.convention(KotlinThriftOptions())
|
||||
|
||||
val outputDirectory: DirectoryProperty = objects.directoryProperty()
|
||||
.convention(layout.buildDirectory.dir(DEFAULT_OUTPUT_DIR))
|
||||
|
|
|
@ -9,4 +9,8 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
api "com.microsoft.thrifty:thrifty-runtime:2.1.2"
|
||||
}
|
||||
|
||||
thrifty {
|
||||
java {}
|
||||
}
|
|
@ -4,10 +4,6 @@ plugins {
|
|||
id 'com.microsoft.thrifty'
|
||||
}
|
||||
|
||||
thrifty {
|
||||
kotlin {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@ plugins {
|
|||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
thrifty {
|
||||
kotlin {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ plugins {
|
|||
}
|
||||
|
||||
thrifty {
|
||||
kotlin {}
|
||||
|
||||
sourceDir "src/main/thrift-a"
|
||||
sourceDir "src/main/thrift-b"
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ plugins {
|
|||
}
|
||||
|
||||
thrifty {
|
||||
kotlin {}
|
||||
|
||||
sourceDir("src/main/thrift") {
|
||||
include "**/sample.thrift"
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@ plugins {
|
|||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
thrifty {
|
||||
java {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
|
|
@ -3,10 +3,6 @@ plugins {
|
|||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
thrifty {
|
||||
kotlin {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ plugins {
|
|||
thrifty {
|
||||
outputDir 'thrifts'
|
||||
includePath 'common'
|
||||
kotlin {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -5,7 +5,6 @@ plugins {
|
|||
|
||||
thrifty {
|
||||
includePath 'common'
|
||||
kotlin {}
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
Загрузка…
Ссылка в новой задаче