Kotlin Gradle Plugin: Expose default compiler arguments via compilation task API
This commit is contained in:
+1
@@ -21,6 +21,7 @@ import org.gradle.api.Task
|
||||
|
||||
interface CompilerArgumentAware {
|
||||
val serializedCompilerArguments: List<String>
|
||||
val defaultSerializedCompilerArguments: List<String>
|
||||
}
|
||||
|
||||
interface KotlinCompile<T : KotlinCommonOptions> : Task, CompilerArgumentAware {
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||
import java.io.File
|
||||
|
||||
internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompilerArguments>() {
|
||||
override fun populateCompilerArguments(): K2MetadataCompilerArguments =
|
||||
override fun populateCompilerArguments(defaultsOnly: Boolean): K2MetadataCompilerArguments =
|
||||
K2MetadataCompilerArguments()
|
||||
|
||||
override fun getSourceRoots(): SourceRoots =
|
||||
|
||||
+15
-3
@@ -53,7 +53,7 @@ const val KOTLIN_BUILD_DIR_NAME = "kotlin"
|
||||
const val USING_EXPERIMENTAL_INCREMENTAL_MESSAGE = "Using experimental kotlin incremental compilation"
|
||||
|
||||
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile(), CompilerArgumentAware {
|
||||
abstract protected fun populateCompilerArguments(): T
|
||||
abstract protected fun populateCompilerArguments(defaultsOnly: Boolean = false): T
|
||||
|
||||
protected val additionalClasspath = arrayListOf<File>()
|
||||
protected val compileClasspath: Iterable<File>
|
||||
@@ -67,6 +67,13 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCo
|
||||
return ArgumentUtils.convertArgumentsToStringList(arguments)
|
||||
}
|
||||
|
||||
override val defaultSerializedCompilerArguments: List<String>
|
||||
get() {
|
||||
val arguments = populateCompilerArguments(true)
|
||||
arguments.setupCommonCompilerArgs()
|
||||
return ArgumentUtils.convertArgumentsToStringList(arguments)
|
||||
}
|
||||
|
||||
private val kotlinExt: KotlinProjectExtension
|
||||
get() = project.extensions.findByType(KotlinProjectExtension::class.java)!!
|
||||
|
||||
@@ -180,9 +187,11 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
override fun findKotlinCompilerJar(project: Project): File? =
|
||||
findKotlinJvmCompilerJar(project)
|
||||
|
||||
override fun populateCompilerArguments(): K2JVMCompilerArguments {
|
||||
override fun populateCompilerArguments(defaultsOnly: Boolean): K2JVMCompilerArguments {
|
||||
val args = K2JVMCompilerArguments().apply { fillDefaultValues() }
|
||||
|
||||
if (defaultsOnly) return args
|
||||
|
||||
handleKaptProperties()
|
||||
args.pluginClasspaths = pluginOptions.classpath.toTypedArray()
|
||||
args.pluginOptions = pluginOptions.arguments.toTypedArray()
|
||||
@@ -320,8 +329,11 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
|
||||
override fun findKotlinCompilerJar(project: Project): File? =
|
||||
findKotlinJsCompilerJar(project)
|
||||
|
||||
override fun populateCompilerArguments(): K2JSCompilerArguments {
|
||||
override fun populateCompilerArguments(defaultsOnly: Boolean): K2JSCompilerArguments {
|
||||
val args = K2JSCompilerArguments().apply { fillDefaultValues() }
|
||||
|
||||
if (defaultsOnly) return args
|
||||
|
||||
args.outputFile = outputFile
|
||||
kotlinOptionsImpl.updateArguments(args)
|
||||
return args
|
||||
|
||||
Reference in New Issue
Block a user