Reformat kotlin-gradle-plugin according to code style
This commit is contained in:
@@ -194,7 +194,9 @@ private fun Printer.generateImpl(
|
|||||||
generatePropertyDeclaration(property, modifiers = "override")
|
generatePropertyDeclaration(property, modifiers = "override")
|
||||||
withIndent {
|
withIndent {
|
||||||
println("get() = $backingField ?: ${property.gradleDefaultValue}")
|
println("get() = $backingField ?: ${property.gradleDefaultValue}")
|
||||||
println("set(value) { $backingField = value }")
|
println("set(value) {")
|
||||||
|
withIndent { println("$backingField = value") }
|
||||||
|
println("}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -15,7 +15,11 @@ import java.rmi.server.UnicastRemoteObject
|
|||||||
internal class GradleCompilationResults(
|
internal class GradleCompilationResults(
|
||||||
project: Project
|
project: Project
|
||||||
) : CompilationResults,
|
) : CompilationResults,
|
||||||
UnicastRemoteObject(SOCKET_ANY_FREE_PORT, LoopbackNetworkInterface.clientLoopbackSocketFactory, LoopbackNetworkInterface.serverLoopbackSocketFactory) {
|
UnicastRemoteObject(
|
||||||
|
SOCKET_ANY_FREE_PORT,
|
||||||
|
LoopbackNetworkInterface.clientLoopbackSocketFactory,
|
||||||
|
LoopbackNetworkInterface.serverLoopbackSocketFactory
|
||||||
|
) {
|
||||||
|
|
||||||
private val log = project.logger
|
private val log = project.logger
|
||||||
private val projectRootFile = project.rootProject.projectDir
|
private val projectRootFile = project.rootProject.projectDir
|
||||||
|
|||||||
+2
-1
@@ -39,7 +39,8 @@ internal open class GradleCompilerServicesFacadeImpl(
|
|||||||
category = category,
|
category = category,
|
||||||
severity = severity,
|
severity = severity,
|
||||||
message = message,
|
message = message,
|
||||||
attachment = attachment)
|
attachment = attachment
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-24
@@ -148,8 +148,10 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
): ExitCode {
|
): ExitCode {
|
||||||
if (compilerArgs.version) {
|
if (compilerArgs.version) {
|
||||||
project.logger.lifecycle("Kotlin version " + loadCompilerVersion(environment.compilerClasspath) +
|
project.logger.lifecycle(
|
||||||
" (JRE " + System.getProperty("java.runtime.version") + ")")
|
"Kotlin version " + loadCompilerVersion(environment.compilerClasspath) +
|
||||||
|
" (JRE " + System.getProperty("java.runtime.version") + ")"
|
||||||
|
)
|
||||||
compilerArgs.version = false
|
compilerArgs.version = false
|
||||||
}
|
}
|
||||||
val argsArray = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray()
|
val argsArray = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray()
|
||||||
@@ -165,8 +167,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
|
|
||||||
if (daemonExitCode != null) {
|
if (daemonExitCode != null) {
|
||||||
return daemonExitCode
|
return daemonExitCode
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log.warn("Could not connect to kotlin daemon. Using fallback strategy.")
|
log.warn("Could not connect to kotlin daemon. Using fallback strategy.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,8 +175,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
val isGradleDaemonUsed = System.getProperty("org.gradle.daemon")?.let(String::toBoolean)
|
val isGradleDaemonUsed = System.getProperty("org.gradle.daemon")?.let(String::toBoolean)
|
||||||
return if (executionStrategy == IN_PROCESS_EXECUTION_STRATEGY || isGradleDaemonUsed == false) {
|
return if (executionStrategy == IN_PROCESS_EXECUTION_STRATEGY || isGradleDaemonUsed == false) {
|
||||||
compileInProcess(argsArray, compilerClassName, environment)
|
compileInProcess(argsArray, compilerClassName, environment)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
compileOutOfProcess(argsArray, compilerClassName, environment)
|
compileOutOfProcess(argsArray, compilerClassName, environment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,12 +183,15 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
private val kotlinCompilerExecutionStrategy: String
|
private val kotlinCompilerExecutionStrategy: String
|
||||||
get() = System.getProperty(KOTLIN_COMPILER_EXECUTION_STRATEGY_PROPERTY) ?: DAEMON_EXECUTION_STRATEGY
|
get() = System.getProperty(KOTLIN_COMPILER_EXECUTION_STRATEGY_PROPERTY) ?: DAEMON_EXECUTION_STRATEGY
|
||||||
|
|
||||||
override fun compileWithDaemon(compilerClassName: String, compilerArgs: CommonCompilerArguments, environment: GradleCompilerEnvironment): ExitCode? {
|
override fun compileWithDaemon(
|
||||||
|
compilerClassName: String,
|
||||||
|
compilerArgs: CommonCompilerArguments,
|
||||||
|
environment: GradleCompilerEnvironment
|
||||||
|
): ExitCode? {
|
||||||
val connection =
|
val connection =
|
||||||
try {
|
try {
|
||||||
getDaemonConnection(environment)
|
getDaemonConnection(environment)
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
log.warn("Caught an exception trying to connect to Kotlin Daemon")
|
log.warn("Caught an exception trying to connect to Kotlin Daemon")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
null
|
null
|
||||||
@@ -196,8 +199,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
if (environment is GradleIncrementalCompilerEnvironment) {
|
if (environment is GradleIncrementalCompilerEnvironment) {
|
||||||
log.warn("Could not perform incremental compilation: $COULD_NOT_CONNECT_TO_DAEMON_MESSAGE")
|
log.warn("Could not perform incremental compilation: $COULD_NOT_CONNECT_TO_DAEMON_MESSAGE")
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log.warn(COULD_NOT_CONNECT_TO_DAEMON_MESSAGE)
|
log.warn(COULD_NOT_CONNECT_TO_DAEMON_MESSAGE)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
@@ -217,8 +219,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
nonIncrementalCompilationWithDaemon(daemon, sessionId, targetPlatform, environment)
|
nonIncrementalCompilationWithDaemon(daemon, sessionId, targetPlatform, environment)
|
||||||
}
|
}
|
||||||
exitCodeFromProcessExitCode(res.get())
|
exitCodeFromProcessExitCode(res.get())
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
log.warn("Compilation with Kotlin compile daemon was not successful")
|
log.warn("Compilation with Kotlin compile daemon was not successful")
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
null
|
null
|
||||||
@@ -228,8 +229,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
// TODO: implement a proper logic to avoid remote calls in such cases
|
// TODO: implement a proper logic to avoid remote calls in such cases
|
||||||
try {
|
try {
|
||||||
daemon.clearJarCache()
|
daemon.clearJarCache()
|
||||||
}
|
} catch (e: RemoteException) {
|
||||||
catch (e: RemoteException) {
|
|
||||||
log.warn("Unable to clear jar cache after compilation, maybe daemon is already down: $e")
|
log.warn("Unable to clear jar cache after compilation, maybe daemon is already down: $e")
|
||||||
}
|
}
|
||||||
logFinish(DAEMON_EXECUTION_STRATEGY)
|
logFinish(DAEMON_EXECUTION_STRATEGY)
|
||||||
@@ -248,7 +248,8 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
targetPlatform = targetPlatform,
|
targetPlatform = targetPlatform,
|
||||||
reportCategories = reportCategories(verbose),
|
reportCategories = reportCategories(verbose),
|
||||||
reportSeverity = reportSeverity(verbose),
|
reportSeverity = reportSeverity(verbose),
|
||||||
requestedCompilationResults = emptyArray())
|
requestedCompilationResults = emptyArray()
|
||||||
|
)
|
||||||
val servicesFacade = GradleCompilerServicesFacadeImpl(project, environment.messageCollector)
|
val servicesFacade = GradleCompilerServicesFacadeImpl(project, environment.messageCollector)
|
||||||
val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray()
|
val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray()
|
||||||
return daemon.compile(sessionId, argsArray, compilationOptions, servicesFacade, compilationResults = null)
|
return daemon.compile(sessionId, argsArray, compilationOptions, servicesFacade, compilationResults = null)
|
||||||
@@ -288,16 +289,14 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
private fun reportCategories(verbose: Boolean): Array<Int> =
|
private fun reportCategories(verbose: Boolean): Array<Int> =
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
arrayOf(ReportCategory.COMPILER_MESSAGE.code)
|
arrayOf(ReportCategory.COMPILER_MESSAGE.code)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ReportCategory.values().map { it.code }.toTypedArray()
|
ReportCategory.values().map { it.code }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reportSeverity(verbose: Boolean): Int =
|
private fun reportSeverity(verbose: Boolean): Int =
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
ReportSeverity.INFO.code
|
ReportSeverity.INFO.code
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ReportSeverity.DEBUG.code
|
ReportSeverity.DEBUG.code
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,8 +418,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
val projectName = project.rootProject.name.normalizeForFlagFile()
|
val projectName = project.rootProject.name.normalizeForFlagFile()
|
||||||
clientIsAliveFlagFile = newTmpFile(prefix = "kotlin-compiler-in-$projectName-", suffix = ".alive")
|
clientIsAliveFlagFile = newTmpFile(prefix = "kotlin-compiler-in-$projectName-", suffix = ".alive")
|
||||||
log.kotlinDebug { CREATED_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath }
|
log.kotlinDebug { CREATED_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log.kotlinDebug { EXISTING_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath }
|
log.kotlinDebug { EXISTING_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,8 +442,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
|||||||
val sessionFilesDir = sessionsDir(project).apply { mkdirs() }
|
val sessionFilesDir = sessionsDir(project).apply { mkdirs() }
|
||||||
sessionFlagFile = newTmpFile(prefix = "kotlin-compiler-", suffix = ".salive", directory = sessionFilesDir)
|
sessionFlagFile = newTmpFile(prefix = "kotlin-compiler-", suffix = ".salive", directory = sessionFilesDir)
|
||||||
log.kotlinDebug { CREATED_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeToRoot(project) }
|
log.kotlinDebug { CREATED_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeToRoot(project) }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log.kotlinDebug { EXISTING_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeToRoot(project) }
|
log.kotlinDebug { EXISTING_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeToRoot(project) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-11
@@ -121,9 +121,11 @@ internal abstract class KonanCliRunner(
|
|||||||
override fun run(args: List<String>) {
|
override fun run(args: List<String>) {
|
||||||
project.logger.info("Run tool: $toolName with args: ${args.joinToString(separator = " ")}")
|
project.logger.info("Run tool: $toolName with args: ${args.joinToString(separator = " ")}")
|
||||||
if (classpath.isEmpty) {
|
if (classpath.isEmpty) {
|
||||||
throw IllegalStateException("Classpath of the tool is empty: $toolName\n" +
|
throw IllegalStateException(
|
||||||
|
"Classpath of the tool is empty: $toolName\n" +
|
||||||
"Probably the '${KotlinNativeProjectProperty.KONAN_HOME_OVERRIDE}' project property contains an incorrect path.\n" +
|
"Probably the '${KotlinNativeProjectProperty.KONAN_HOME_OVERRIDE}' project property contains an incorrect path.\n" +
|
||||||
"Please change it to the compiler root directory and rerun the build.")
|
"Please change it to the compiler root directory and rerun the build."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.javaexec { spec ->
|
project.javaexec { spec ->
|
||||||
@@ -145,15 +147,16 @@ internal abstract class KonanCliRunner(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class KonanInteropRunner(project: Project, additionalJvmArgs: List<String> = emptyList())
|
internal class KonanInteropRunner(project: Project, additionalJvmArgs: List<String> = emptyList()) :
|
||||||
: KonanCliRunner("cinterop", "Kotlin/Native cinterop tool", project, additionalJvmArgs)
|
KonanCliRunner("cinterop", "Kotlin/Native cinterop tool", project, additionalJvmArgs) {
|
||||||
{
|
|
||||||
init {
|
init {
|
||||||
if (HostManager.host == KonanTarget.MINGW_X64) {
|
if (HostManager.host == KonanTarget.MINGW_X64) {
|
||||||
//TODO: Oh-ho-ho fix it in more convinient way.
|
//TODO: Oh-ho-ho fix it in more convinient way.
|
||||||
environment.put("PATH", DependencyDirectories.defaultDependenciesRoot.absolutePath +
|
environment.put(
|
||||||
|
"PATH", DependencyDirectories.defaultDependenciesRoot.absolutePath +
|
||||||
"\\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1" +
|
"\\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1" +
|
||||||
"\\bin;${environment.get("PATH")}")
|
"\\bin;${environment.get("PATH")}"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,8 +165,7 @@ internal class KonanCompilerRunner(
|
|||||||
project: Project,
|
project: Project,
|
||||||
additionalJvmArgs: List<String> = emptyList(),
|
additionalJvmArgs: List<String> = emptyList(),
|
||||||
val useArgFile: Boolean = true
|
val useArgFile: Boolean = true
|
||||||
) : KonanCliRunner("konanc", "Kotlin/Native compiler", project, additionalJvmArgs)
|
) : KonanCliRunner("konanc", "Kotlin/Native compiler", project, additionalJvmArgs) {
|
||||||
{
|
|
||||||
override fun transformArgs(args: List<String>): List<String> {
|
override fun transformArgs(args: List<String>): List<String> {
|
||||||
if (!useArgFile) {
|
if (!useArgFile) {
|
||||||
return args
|
return args
|
||||||
@@ -182,5 +184,5 @@ internal class KonanCompilerRunner(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class KonanKlibRunner(project: Project, additionalJvmArgs: List<String> = emptyList())
|
internal class KonanKlibRunner(project: Project, additionalJvmArgs: List<String> = emptyList()) :
|
||||||
: KonanCliRunner("klib", "Klib management tool", project, additionalJvmArgs)
|
KonanCliRunner("klib", "Klib management tool", project, additionalJvmArgs)
|
||||||
|
|||||||
+2
-3
@@ -54,16 +54,15 @@ internal fun loadCompilerVersion(compilerClasspath: List<File>): String {
|
|||||||
val bytes = jar.getInputStream(jar.getEntry(versionClassFileName)).use { it.readBytes() }
|
val bytes = jar.getInputStream(jar.getEntry(versionClassFileName)).use { it.readBytes() }
|
||||||
checkVersion(bytes)
|
checkVersion(bytes)
|
||||||
}
|
}
|
||||||
}
|
} else if (cpFile.isDirectory) {
|
||||||
else if (cpFile.isDirectory) {
|
|
||||||
File(cpFile, versionClassFileName).takeIf { it.isFile }?.let {
|
File(cpFile, versionClassFileName).takeIf { it.isFile }?.let {
|
||||||
checkVersion(it.readBytes())
|
checkVersion(it.readBytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result != null) break
|
if (result != null) break
|
||||||
}
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {}
|
|
||||||
|
|
||||||
return result ?: "<unknown>"
|
return result ?: "<unknown>"
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -18,10 +18,7 @@ package org.jetbrains.kotlin.gradle.dsl
|
|||||||
|
|
||||||
import groovy.lang.Closure
|
import groovy.lang.Closure
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.Input
|
|
||||||
import org.gradle.api.tasks.Internal
|
import org.gradle.api.tasks.Internal
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments
|
|
||||||
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
|
||||||
|
|
||||||
interface KotlinCompile<T : KotlinCommonOptions> : Task {
|
interface KotlinCompile<T : KotlinCommonOptions> : Task {
|
||||||
@get:Internal
|
@get:Internal
|
||||||
|
|||||||
+15
-5
@@ -7,27 +7,37 @@ internal abstract class KotlinJsDceOptionsBase : org.jetbrains.kotlin.gradle.dsl
|
|||||||
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
||||||
override var allWarningsAsErrors: kotlin.Boolean
|
override var allWarningsAsErrors: kotlin.Boolean
|
||||||
get() = allWarningsAsErrorsField ?: false
|
get() = allWarningsAsErrorsField ?: false
|
||||||
set(value) { allWarningsAsErrorsField = value }
|
set(value) {
|
||||||
|
allWarningsAsErrorsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var suppressWarningsField: kotlin.Boolean? = null
|
private var suppressWarningsField: kotlin.Boolean? = null
|
||||||
override var suppressWarnings: kotlin.Boolean
|
override var suppressWarnings: kotlin.Boolean
|
||||||
get() = suppressWarningsField ?: false
|
get() = suppressWarningsField ?: false
|
||||||
set(value) { suppressWarningsField = value }
|
set(value) {
|
||||||
|
suppressWarningsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var verboseField: kotlin.Boolean? = null
|
private var verboseField: kotlin.Boolean? = null
|
||||||
override var verbose: kotlin.Boolean
|
override var verbose: kotlin.Boolean
|
||||||
get() = verboseField ?: false
|
get() = verboseField ?: false
|
||||||
set(value) { verboseField = value }
|
set(value) {
|
||||||
|
verboseField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var devModeField: kotlin.Boolean? = null
|
private var devModeField: kotlin.Boolean? = null
|
||||||
override var devMode: kotlin.Boolean
|
override var devMode: kotlin.Boolean
|
||||||
get() = devModeField ?: false
|
get() = devModeField ?: false
|
||||||
set(value) { devModeField = value }
|
set(value) {
|
||||||
|
devModeField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var outputDirectoryField: kotlin.String?? = null
|
private var outputDirectoryField: kotlin.String?? = null
|
||||||
override var outputDirectory: kotlin.String?
|
override var outputDirectory: kotlin.String?
|
||||||
get() = outputDirectoryField ?: null
|
get() = outputDirectoryField ?: null
|
||||||
set(value) { outputDirectoryField = value }
|
set(value) {
|
||||||
|
outputDirectoryField = value
|
||||||
|
}
|
||||||
|
|
||||||
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JSDceArguments) {
|
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JSDceArguments) {
|
||||||
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
||||||
|
|||||||
+48
-16
@@ -7,82 +7,114 @@ internal abstract class KotlinJsOptionsBase : org.jetbrains.kotlin.gradle.dsl.Ko
|
|||||||
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
||||||
override var allWarningsAsErrors: kotlin.Boolean
|
override var allWarningsAsErrors: kotlin.Boolean
|
||||||
get() = allWarningsAsErrorsField ?: false
|
get() = allWarningsAsErrorsField ?: false
|
||||||
set(value) { allWarningsAsErrorsField = value }
|
set(value) {
|
||||||
|
allWarningsAsErrorsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var suppressWarningsField: kotlin.Boolean? = null
|
private var suppressWarningsField: kotlin.Boolean? = null
|
||||||
override var suppressWarnings: kotlin.Boolean
|
override var suppressWarnings: kotlin.Boolean
|
||||||
get() = suppressWarningsField ?: false
|
get() = suppressWarningsField ?: false
|
||||||
set(value) { suppressWarningsField = value }
|
set(value) {
|
||||||
|
suppressWarningsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var verboseField: kotlin.Boolean? = null
|
private var verboseField: kotlin.Boolean? = null
|
||||||
override var verbose: kotlin.Boolean
|
override var verbose: kotlin.Boolean
|
||||||
get() = verboseField ?: false
|
get() = verboseField ?: false
|
||||||
set(value) { verboseField = value }
|
set(value) {
|
||||||
|
verboseField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var apiVersionField: kotlin.String?? = null
|
private var apiVersionField: kotlin.String?? = null
|
||||||
override var apiVersion: kotlin.String?
|
override var apiVersion: kotlin.String?
|
||||||
get() = apiVersionField ?: null
|
get() = apiVersionField ?: null
|
||||||
set(value) { apiVersionField = value }
|
set(value) {
|
||||||
|
apiVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var languageVersionField: kotlin.String?? = null
|
private var languageVersionField: kotlin.String?? = null
|
||||||
override var languageVersion: kotlin.String?
|
override var languageVersion: kotlin.String?
|
||||||
get() = languageVersionField ?: null
|
get() = languageVersionField ?: null
|
||||||
set(value) { languageVersionField = value }
|
set(value) {
|
||||||
|
languageVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var friendModulesDisabledField: kotlin.Boolean? = null
|
private var friendModulesDisabledField: kotlin.Boolean? = null
|
||||||
override var friendModulesDisabled: kotlin.Boolean
|
override var friendModulesDisabled: kotlin.Boolean
|
||||||
get() = friendModulesDisabledField ?: false
|
get() = friendModulesDisabledField ?: false
|
||||||
set(value) { friendModulesDisabledField = value }
|
set(value) {
|
||||||
|
friendModulesDisabledField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var mainField: kotlin.String? = null
|
private var mainField: kotlin.String? = null
|
||||||
override var main: kotlin.String
|
override var main: kotlin.String
|
||||||
get() = mainField ?: "call"
|
get() = mainField ?: "call"
|
||||||
set(value) { mainField = value }
|
set(value) {
|
||||||
|
mainField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var metaInfoField: kotlin.Boolean? = null
|
private var metaInfoField: kotlin.Boolean? = null
|
||||||
override var metaInfo: kotlin.Boolean
|
override var metaInfo: kotlin.Boolean
|
||||||
get() = metaInfoField ?: true
|
get() = metaInfoField ?: true
|
||||||
set(value) { metaInfoField = value }
|
set(value) {
|
||||||
|
metaInfoField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var moduleKindField: kotlin.String? = null
|
private var moduleKindField: kotlin.String? = null
|
||||||
override var moduleKind: kotlin.String
|
override var moduleKind: kotlin.String
|
||||||
get() = moduleKindField ?: "plain"
|
get() = moduleKindField ?: "plain"
|
||||||
set(value) { moduleKindField = value }
|
set(value) {
|
||||||
|
moduleKindField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var noStdlibField: kotlin.Boolean? = null
|
private var noStdlibField: kotlin.Boolean? = null
|
||||||
override var noStdlib: kotlin.Boolean
|
override var noStdlib: kotlin.Boolean
|
||||||
get() = noStdlibField ?: true
|
get() = noStdlibField ?: true
|
||||||
set(value) { noStdlibField = value }
|
set(value) {
|
||||||
|
noStdlibField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var outputFileField: kotlin.String?? = null
|
private var outputFileField: kotlin.String?? = null
|
||||||
override var outputFile: kotlin.String?
|
override var outputFile: kotlin.String?
|
||||||
get() = outputFileField ?: null
|
get() = outputFileField ?: null
|
||||||
set(value) { outputFileField = value }
|
set(value) {
|
||||||
|
outputFileField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var sourceMapField: kotlin.Boolean? = null
|
private var sourceMapField: kotlin.Boolean? = null
|
||||||
override var sourceMap: kotlin.Boolean
|
override var sourceMap: kotlin.Boolean
|
||||||
get() = sourceMapField ?: false
|
get() = sourceMapField ?: false
|
||||||
set(value) { sourceMapField = value }
|
set(value) {
|
||||||
|
sourceMapField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var sourceMapEmbedSourcesField: kotlin.String?? = null
|
private var sourceMapEmbedSourcesField: kotlin.String?? = null
|
||||||
override var sourceMapEmbedSources: kotlin.String?
|
override var sourceMapEmbedSources: kotlin.String?
|
||||||
get() = sourceMapEmbedSourcesField ?: null
|
get() = sourceMapEmbedSourcesField ?: null
|
||||||
set(value) { sourceMapEmbedSourcesField = value }
|
set(value) {
|
||||||
|
sourceMapEmbedSourcesField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var sourceMapPrefixField: kotlin.String?? = null
|
private var sourceMapPrefixField: kotlin.String?? = null
|
||||||
override var sourceMapPrefix: kotlin.String?
|
override var sourceMapPrefix: kotlin.String?
|
||||||
get() = sourceMapPrefixField ?: null
|
get() = sourceMapPrefixField ?: null
|
||||||
set(value) { sourceMapPrefixField = value }
|
set(value) {
|
||||||
|
sourceMapPrefixField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var targetField: kotlin.String? = null
|
private var targetField: kotlin.String? = null
|
||||||
override var target: kotlin.String
|
override var target: kotlin.String
|
||||||
get() = targetField ?: "v5"
|
get() = targetField ?: "v5"
|
||||||
set(value) { targetField = value }
|
set(value) {
|
||||||
|
targetField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var typedArraysField: kotlin.Boolean? = null
|
private var typedArraysField: kotlin.Boolean? = null
|
||||||
override var typedArrays: kotlin.Boolean
|
override var typedArrays: kotlin.Boolean
|
||||||
get() = typedArraysField ?: true
|
get() = typedArraysField ?: true
|
||||||
set(value) { typedArraysField = value }
|
set(value) {
|
||||||
|
typedArraysField = value
|
||||||
|
}
|
||||||
|
|
||||||
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments) {
|
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments) {
|
||||||
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
||||||
|
|||||||
+36
-12
@@ -7,62 +7,86 @@ internal abstract class KotlinJvmOptionsBase : org.jetbrains.kotlin.gradle.dsl.K
|
|||||||
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
||||||
override var allWarningsAsErrors: kotlin.Boolean
|
override var allWarningsAsErrors: kotlin.Boolean
|
||||||
get() = allWarningsAsErrorsField ?: false
|
get() = allWarningsAsErrorsField ?: false
|
||||||
set(value) { allWarningsAsErrorsField = value }
|
set(value) {
|
||||||
|
allWarningsAsErrorsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var suppressWarningsField: kotlin.Boolean? = null
|
private var suppressWarningsField: kotlin.Boolean? = null
|
||||||
override var suppressWarnings: kotlin.Boolean
|
override var suppressWarnings: kotlin.Boolean
|
||||||
get() = suppressWarningsField ?: false
|
get() = suppressWarningsField ?: false
|
||||||
set(value) { suppressWarningsField = value }
|
set(value) {
|
||||||
|
suppressWarningsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var verboseField: kotlin.Boolean? = null
|
private var verboseField: kotlin.Boolean? = null
|
||||||
override var verbose: kotlin.Boolean
|
override var verbose: kotlin.Boolean
|
||||||
get() = verboseField ?: false
|
get() = verboseField ?: false
|
||||||
set(value) { verboseField = value }
|
set(value) {
|
||||||
|
verboseField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var apiVersionField: kotlin.String?? = null
|
private var apiVersionField: kotlin.String?? = null
|
||||||
override var apiVersion: kotlin.String?
|
override var apiVersion: kotlin.String?
|
||||||
get() = apiVersionField ?: null
|
get() = apiVersionField ?: null
|
||||||
set(value) { apiVersionField = value }
|
set(value) {
|
||||||
|
apiVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var languageVersionField: kotlin.String?? = null
|
private var languageVersionField: kotlin.String?? = null
|
||||||
override var languageVersion: kotlin.String?
|
override var languageVersion: kotlin.String?
|
||||||
get() = languageVersionField ?: null
|
get() = languageVersionField ?: null
|
||||||
set(value) { languageVersionField = value }
|
set(value) {
|
||||||
|
languageVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var includeRuntimeField: kotlin.Boolean? = null
|
private var includeRuntimeField: kotlin.Boolean? = null
|
||||||
override var includeRuntime: kotlin.Boolean
|
override var includeRuntime: kotlin.Boolean
|
||||||
get() = includeRuntimeField ?: false
|
get() = includeRuntimeField ?: false
|
||||||
set(value) { includeRuntimeField = value }
|
set(value) {
|
||||||
|
includeRuntimeField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var javaParametersField: kotlin.Boolean? = null
|
private var javaParametersField: kotlin.Boolean? = null
|
||||||
override var javaParameters: kotlin.Boolean
|
override var javaParameters: kotlin.Boolean
|
||||||
get() = javaParametersField ?: false
|
get() = javaParametersField ?: false
|
||||||
set(value) { javaParametersField = value }
|
set(value) {
|
||||||
|
javaParametersField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var jdkHomeField: kotlin.String?? = null
|
private var jdkHomeField: kotlin.String?? = null
|
||||||
override var jdkHome: kotlin.String?
|
override var jdkHome: kotlin.String?
|
||||||
get() = jdkHomeField ?: null
|
get() = jdkHomeField ?: null
|
||||||
set(value) { jdkHomeField = value }
|
set(value) {
|
||||||
|
jdkHomeField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var jvmTargetField: kotlin.String? = null
|
private var jvmTargetField: kotlin.String? = null
|
||||||
override var jvmTarget: kotlin.String
|
override var jvmTarget: kotlin.String
|
||||||
get() = jvmTargetField ?: "1.6"
|
get() = jvmTargetField ?: "1.6"
|
||||||
set(value) { jvmTargetField = value }
|
set(value) {
|
||||||
|
jvmTargetField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var noJdkField: kotlin.Boolean? = null
|
private var noJdkField: kotlin.Boolean? = null
|
||||||
override var noJdk: kotlin.Boolean
|
override var noJdk: kotlin.Boolean
|
||||||
get() = noJdkField ?: false
|
get() = noJdkField ?: false
|
||||||
set(value) { noJdkField = value }
|
set(value) {
|
||||||
|
noJdkField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var noReflectField: kotlin.Boolean? = null
|
private var noReflectField: kotlin.Boolean? = null
|
||||||
override var noReflect: kotlin.Boolean
|
override var noReflect: kotlin.Boolean
|
||||||
get() = noReflectField ?: true
|
get() = noReflectField ?: true
|
||||||
set(value) { noReflectField = value }
|
set(value) {
|
||||||
|
noReflectField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var noStdlibField: kotlin.Boolean? = null
|
private var noStdlibField: kotlin.Boolean? = null
|
||||||
override var noStdlib: kotlin.Boolean
|
override var noStdlib: kotlin.Boolean
|
||||||
get() = noStdlibField ?: true
|
get() = noStdlibField ?: true
|
||||||
set(value) { noStdlibField = value }
|
set(value) {
|
||||||
|
noStdlibField = value
|
||||||
|
}
|
||||||
|
|
||||||
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments) {
|
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments) {
|
||||||
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
||||||
|
|||||||
+15
-5
@@ -7,27 +7,37 @@ internal abstract class KotlinMultiplatformCommonOptionsBase : org.jetbrains.kot
|
|||||||
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
private var allWarningsAsErrorsField: kotlin.Boolean? = null
|
||||||
override var allWarningsAsErrors: kotlin.Boolean
|
override var allWarningsAsErrors: kotlin.Boolean
|
||||||
get() = allWarningsAsErrorsField ?: false
|
get() = allWarningsAsErrorsField ?: false
|
||||||
set(value) { allWarningsAsErrorsField = value }
|
set(value) {
|
||||||
|
allWarningsAsErrorsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var suppressWarningsField: kotlin.Boolean? = null
|
private var suppressWarningsField: kotlin.Boolean? = null
|
||||||
override var suppressWarnings: kotlin.Boolean
|
override var suppressWarnings: kotlin.Boolean
|
||||||
get() = suppressWarningsField ?: false
|
get() = suppressWarningsField ?: false
|
||||||
set(value) { suppressWarningsField = value }
|
set(value) {
|
||||||
|
suppressWarningsField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var verboseField: kotlin.Boolean? = null
|
private var verboseField: kotlin.Boolean? = null
|
||||||
override var verbose: kotlin.Boolean
|
override var verbose: kotlin.Boolean
|
||||||
get() = verboseField ?: false
|
get() = verboseField ?: false
|
||||||
set(value) { verboseField = value }
|
set(value) {
|
||||||
|
verboseField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var apiVersionField: kotlin.String?? = null
|
private var apiVersionField: kotlin.String?? = null
|
||||||
override var apiVersion: kotlin.String?
|
override var apiVersion: kotlin.String?
|
||||||
get() = apiVersionField ?: null
|
get() = apiVersionField ?: null
|
||||||
set(value) { apiVersionField = value }
|
set(value) {
|
||||||
|
apiVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
private var languageVersionField: kotlin.String?? = null
|
private var languageVersionField: kotlin.String?? = null
|
||||||
override var languageVersion: kotlin.String?
|
override var languageVersion: kotlin.String?
|
||||||
get() = languageVersionField ?: null
|
get() = languageVersionField ?: null
|
||||||
set(value) { languageVersionField = value }
|
set(value) {
|
||||||
|
languageVersionField = value
|
||||||
|
}
|
||||||
|
|
||||||
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments) {
|
internal open fun updateArguments(args: org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments) {
|
||||||
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
allWarningsAsErrorsField?.let { args.allWarningsAsErrors = it }
|
||||||
|
|||||||
-1
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.dsl
|
package org.jetbrains.kotlin.gradle.dsl
|
||||||
|
|
||||||
import org.gradle.api.InvalidUserCodeException
|
|
||||||
import org.gradle.api.NamedDomainObjectCollection
|
import org.gradle.api.NamedDomainObjectCollection
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
||||||
|
|||||||
+3
-1
@@ -41,7 +41,9 @@ open class KotlinProjectExtension {
|
|||||||
var sourceSets: NamedDomainObjectContainer<out KotlinSourceSet>
|
var sourceSets: NamedDomainObjectContainer<out KotlinSourceSet>
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
get() = DslObject(this).extensions.getByName("sourceSets") as NamedDomainObjectContainer<out KotlinSourceSet>
|
get() = DslObject(this).extensions.getByName("sourceSets") as NamedDomainObjectContainer<out KotlinSourceSet>
|
||||||
internal set(value) { DslObject(this).extensions.add("sourceSets", value) }
|
internal set(value) {
|
||||||
|
DslObject(this).extensions.add("sourceSets", value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open class KotlinSingleJavaTargetExtension : KotlinProjectExtension() {
|
open class KotlinSingleJavaTargetExtension : KotlinProjectExtension() {
|
||||||
|
|||||||
+35
-18
@@ -38,7 +38,8 @@ import javax.inject.Inject
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory
|
import javax.xml.parsers.DocumentBuilderFactory
|
||||||
|
|
||||||
// Use apply plugin: 'kotlin-android-extensions' to enable Android Extensions in an Android project.
|
// Use apply plugin: 'kotlin-android-extensions' to enable Android Extensions in an Android project.
|
||||||
class AndroidExtensionsSubpluginIndicator @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) : Plugin<Project> {
|
class AndroidExtensionsSubpluginIndicator @Inject internal constructor(private val registry: ToolingModelBuilderRegistry) :
|
||||||
|
Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
val extension = project.extensions.create("androidExtensions", AndroidExtensionsExtension::class.java)
|
val extension = project.extensions.create("androidExtensions", AndroidExtensionsExtension::class.java)
|
||||||
|
|
||||||
@@ -69,8 +70,11 @@ class AndroidExtensionsSubpluginIndicator @Inject internal constructor(private v
|
|||||||
|
|
||||||
if (name != requiredConfigurationName) return@all
|
if (name != requiredConfigurationName) return@all
|
||||||
|
|
||||||
configuration.dependencies.add(project.dependencies.create(
|
configuration.dependencies.add(
|
||||||
"org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlinPluginVersion"))
|
project.dependencies.create(
|
||||||
|
"org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlinPluginVersion"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,8 +111,10 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
val androidExtensionsExtension = project.extensions.getByType(AndroidExtensionsExtension::class.java)
|
val androidExtensionsExtension = project.extensions.getByType(AndroidExtensionsExtension::class.java)
|
||||||
|
|
||||||
if (androidExtensionsExtension.isExperimental) {
|
if (androidExtensionsExtension.isExperimental) {
|
||||||
return applyExperimental(kotlinCompile, androidExtension, androidExtensionsExtension,
|
return applyExperimental(
|
||||||
project, variantData, androidProjectHandler)
|
kotlinCompile, androidExtension, androidExtensionsExtension,
|
||||||
|
project, variantData, androidProjectHandler
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourceSets = androidExtension.sourceSets
|
val sourceSets = androidExtension.sourceSets
|
||||||
@@ -120,7 +126,8 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
val manifestFile = mainSourceSet.manifest.srcFile
|
val manifestFile = mainSourceSet.manifest.srcFile
|
||||||
val applicationPackage = getApplicationPackageFromManifest(manifestFile) ?: run {
|
val applicationPackage = getApplicationPackageFromManifest(manifestFile) ?: run {
|
||||||
project.logger.warn(
|
project.logger.warn(
|
||||||
"Application package name is not present in the manifest file (${manifestFile.absolutePath})")
|
"Application package name is not present in the manifest file (${manifestFile.absolutePath})"
|
||||||
|
)
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
pluginOptions += SubpluginOption("package", applicationPackage)
|
pluginOptions += SubpluginOption("package", applicationPackage)
|
||||||
@@ -128,11 +135,13 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
fun addVariant(sourceSet: AndroidSourceSet) {
|
fun addVariant(sourceSet: AndroidSourceSet) {
|
||||||
val optionValue = sourceSet.name + ';' +
|
val optionValue = sourceSet.name + ';' +
|
||||||
sourceSet.res.srcDirs.joinToString(";") { it.absolutePath }
|
sourceSet.res.srcDirs.joinToString(";") { it.absolutePath }
|
||||||
pluginOptions += CompositeSubpluginOption("variant", optionValue, listOf(
|
pluginOptions += CompositeSubpluginOption(
|
||||||
|
"variant", optionValue, listOf(
|
||||||
SubpluginOption("sourceSetName", sourceSet.name),
|
SubpluginOption("sourceSetName", sourceSet.name),
|
||||||
//use the INTERNAL option kind since the resources are tracked as sources (see below)
|
//use the INTERNAL option kind since the resources are tracked as sources (see below)
|
||||||
FilesSubpluginOption("resDirs", sourceSet.res.srcDirs.toList())
|
FilesSubpluginOption("resDirs", sourceSet.res.srcDirs.toList())
|
||||||
))
|
)
|
||||||
|
)
|
||||||
kotlinCompile.source(project.files(getLayoutDirectories(sourceSet.res.srcDirs)))
|
kotlinCompile.source(project.files(getLayoutDirectories(sourceSet.res.srcDirs)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +181,10 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
AndroidExtensionsFeature.parseFeatures(androidExtensionsExtension.features).joinToString(",") { it.featureName })
|
AndroidExtensionsFeature.parseFeatures(androidExtensionsExtension.features).joinToString(",") { it.featureName })
|
||||||
|
|
||||||
pluginOptions += SubpluginOption("experimental", "true")
|
pluginOptions += SubpluginOption("experimental", "true")
|
||||||
pluginOptions += SubpluginOption("defaultCacheImplementation",
|
pluginOptions += SubpluginOption(
|
||||||
androidExtensionsExtension.defaultCacheImplementation.optionName)
|
"defaultCacheImplementation",
|
||||||
|
androidExtensionsExtension.defaultCacheImplementation.optionName
|
||||||
|
)
|
||||||
|
|
||||||
val mainSourceSet = androidExtension.sourceSets.getByName("main")
|
val mainSourceSet = androidExtension.sourceSets.getByName("main")
|
||||||
pluginOptions += SubpluginOption("package", getApplicationPackage(project, mainSourceSet))
|
pluginOptions += SubpluginOption("package", getApplicationPackage(project, mainSourceSet))
|
||||||
@@ -184,10 +195,13 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
append(';')
|
append(';')
|
||||||
resDirectories.joinTo(this, separator = ";") { it.canonicalPath }
|
resDirectories.joinTo(this, separator = ";") { it.canonicalPath }
|
||||||
}
|
}
|
||||||
pluginOptions += CompositeSubpluginOption("variant", optionValue, listOf(
|
pluginOptions += CompositeSubpluginOption(
|
||||||
|
"variant", optionValue, listOf(
|
||||||
SubpluginOption("variantName", name),
|
SubpluginOption("variantName", name),
|
||||||
// use INTERNAL option kind since the resources are tracked as sources (see below)
|
// use INTERNAL option kind since the resources are tracked as sources (see below)
|
||||||
FilesSubpluginOption("resDirs", resDirectories)))
|
FilesSubpluginOption("resDirs", resDirectories)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
kotlinCompile.source(project.files(getLayoutDirectories(resDirectories)))
|
kotlinCompile.source(project.files(getLayoutDirectories(resDirectories)))
|
||||||
}
|
}
|
||||||
@@ -232,8 +246,10 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
is TestVariantData -> getVariantComponentNames(flavorData.testedVariantData)
|
is TestVariantData -> getVariantComponentNames(flavorData.testedVariantData)
|
||||||
is TestVariant -> getVariantComponentNames(flavorData.testedVariant)
|
is TestVariant -> getVariantComponentNames(flavorData.testedVariant)
|
||||||
is BaseVariant -> VariantComponentNames(flavorData.name, flavorData.flavorName, flavorData.buildType.name)
|
is BaseVariant -> VariantComponentNames(flavorData.name, flavorData.flavorName, flavorData.buildType.name)
|
||||||
is BaseVariantData<*> -> VariantComponentNames(flavorData.name, flavorData.variantConfiguration.flavorName,
|
is BaseVariantData<*> -> VariantComponentNames(
|
||||||
flavorData.variantConfiguration.buildType.name)
|
flavorData.name, flavorData.variantConfiguration.flavorName,
|
||||||
|
flavorData.variantConfiguration.buildType.name
|
||||||
|
)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +270,10 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
val applicationPackage = getApplicationPackageFromManifest(manifestFile)
|
val applicationPackage = getApplicationPackageFromManifest(manifestFile)
|
||||||
|
|
||||||
if (applicationPackage == null) {
|
if (applicationPackage == null) {
|
||||||
project.logger.warn("Application package name is not present in the manifest file " +
|
project.logger.warn(
|
||||||
"(${manifestFile.absolutePath})")
|
"Application package name is not present in the manifest file " +
|
||||||
|
"(${manifestFile.absolutePath})"
|
||||||
|
)
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else {
|
||||||
@@ -266,8 +284,7 @@ class AndroidSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
private fun getApplicationPackageFromManifest(manifestFile: File): String? {
|
private fun getApplicationPackageFromManifest(manifestFile: File): String? {
|
||||||
try {
|
try {
|
||||||
return manifestFile.parseXml().documentElement.getAttribute("package")
|
return manifestFile.parseXml().documentElement.getAttribute("package")
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.gradle.internal
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
import kotlin.reflect.KProperty1
|
import kotlin.reflect.KProperty1
|
||||||
import kotlin.reflect.full.memberProperties
|
|
||||||
|
|
||||||
internal object CompilerArgumentsGradleInput {
|
internal object CompilerArgumentsGradleInput {
|
||||||
fun <T : CommonToolArguments> createInputsMap(args: T): Map<String, String> {
|
fun <T : CommonToolArguments> createInputsMap(args: T): Map<String, String> {
|
||||||
|
|||||||
+6
-5
@@ -24,10 +24,10 @@ import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin.Companion.getKa
|
|||||||
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin.Companion.getKaptGeneratedSourcesDir
|
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin.Companion.getKaptGeneratedSourcesDir
|
||||||
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin.Companion.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME
|
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin.Companion.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME
|
||||||
import org.jetbrains.kotlin.gradle.model.builder.KaptModelBuilder
|
import org.jetbrains.kotlin.gradle.model.builder.KaptModelBuilder
|
||||||
import org.jetbrains.kotlin.gradle.tasks.isWorkerAPISupported
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.isWorkerAPISupported
|
||||||
import org.jetbrains.kotlin.gradle.utils.isGradleVersionAtLeast
|
import org.jetbrains.kotlin.gradle.utils.isGradleVersionAtLeast
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -76,7 +76,8 @@ abstract class KaptVariantData<T>(val variantData: T) {
|
|||||||
abstract fun registerGeneratedJavaSource(
|
abstract fun registerGeneratedJavaSource(
|
||||||
project: Project,
|
project: Project,
|
||||||
kaptTask: KaptTask,
|
kaptTask: KaptTask,
|
||||||
javaTask: AbstractCompile)
|
javaTask: AbstractCompile
|
||||||
|
)
|
||||||
|
|
||||||
open val annotationProcessorOptionProviders: List<*>
|
open val annotationProcessorOptionProviders: List<*>
|
||||||
get() = emptyList<Any>()
|
get() = emptyList<Any>()
|
||||||
@@ -201,8 +202,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kaptVariantData.name
|
kaptVariantData.name
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (kotlinCompilation == null) error("In non-Android projects, Kotlin compilation should not be null")
|
if (kotlinCompilation == null) error("In non-Android projects, Kotlin compilation should not be null")
|
||||||
|
|
||||||
handleSourceSet(kotlinCompilation.compilationName)
|
handleSourceSet(kotlinCompilation.compilationName)
|
||||||
@@ -410,7 +410,8 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
private fun Kapt3SubpluginContext.createKaptGenerateStubsTask(): KaptGenerateStubsTask {
|
private fun Kapt3SubpluginContext.createKaptGenerateStubsTask(): KaptGenerateStubsTask {
|
||||||
val kaptTask = project.tasks.create(
|
val kaptTask = project.tasks.create(
|
||||||
getKaptTaskName("kaptGenerateStubs"),
|
getKaptTaskName("kaptGenerateStubs"),
|
||||||
KaptGenerateStubsTask::class.java)
|
KaptGenerateStubsTask::class.java
|
||||||
|
)
|
||||||
|
|
||||||
kaptTask.sourceSetName = sourceSetName
|
kaptTask.sourceSetName = sourceSetName
|
||||||
kaptTask.kotlinCompileTask = kotlinCompile
|
kaptTask.kotlinCompileTask = kotlinCompile
|
||||||
|
|||||||
+10
-5
@@ -21,15 +21,15 @@ import org.gradle.api.file.FileCollection
|
|||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.gradle.incremental.ChangedFiles
|
||||||
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.tasks.FilteringSourceRootsContainer
|
import org.jetbrains.kotlin.gradle.tasks.FilteringSourceRootsContainer
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
import org.jetbrains.kotlin.gradle.tasks.SourceRoots
|
import org.jetbrains.kotlin.gradle.tasks.SourceRoots
|
||||||
import org.jetbrains.kotlin.gradle.incremental.ChangedFiles
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.isParentOf
|
import org.jetbrains.kotlin.gradle.utils.isParentOf
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.pathsAsStringRelativeTo
|
||||||
import org.jetbrains.kotlin.incremental.classpathAsList
|
import org.jetbrains.kotlin.incremental.classpathAsList
|
||||||
import org.jetbrains.kotlin.incremental.destinationAsFile
|
import org.jetbrains.kotlin.incremental.destinationAsFile
|
||||||
import org.jetbrains.kotlin.gradle.utils.pathsAsStringRelativeTo
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
@@ -45,19 +45,24 @@ open class KaptGenerateStubsTask : KotlinCompile() {
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
lateinit var generatedSourcesDir: File
|
lateinit var generatedSourcesDir: File
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
|
@get:InputFiles
|
||||||
val kaptClasspath: FileCollection
|
val kaptClasspath: FileCollection
|
||||||
get() = project.files(*kaptClasspathConfigurations.toTypedArray())
|
get() = project.files(*kaptClasspathConfigurations.toTypedArray())
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal lateinit var kaptClasspathConfigurations: List<Configuration>
|
internal lateinit var kaptClasspathConfigurations: List<Configuration>
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles @Suppress("unused")
|
@get:Classpath
|
||||||
internal val kotlinTaskPluginClasspath get() = kotlinCompileTask.pluginClasspath
|
@get:InputFiles
|
||||||
|
@Suppress("unused")
|
||||||
|
internal val kotlinTaskPluginClasspath
|
||||||
|
get() = kotlinCompileTask.pluginClasspath
|
||||||
|
|
||||||
override fun source(vararg sources: Any?): SourceTask? {
|
override fun source(vararg sources: Any?): SourceTask? {
|
||||||
return super.source(sourceRootsContainer.add(sources))
|
return super.source(sourceRootsContainer.add(sources))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSource(sources: Any?) {
|
override fun setSource(sources: Any?) {
|
||||||
super.setSource(sourceRootsContainer.set(sources))
|
super.setSource(sourceRootsContainer.set(sources))
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-8
@@ -5,10 +5,10 @@ import org.gradle.api.artifacts.Configuration
|
|||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.ConventionTask
|
import org.gradle.api.internal.ConventionTask
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.cacheOnlyIfEnabledForKotlin
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.isBuildCacheSupported
|
||||||
import org.jetbrains.kotlin.gradle.utils.isJavaFile
|
import org.jetbrains.kotlin.gradle.utils.isJavaFile
|
||||||
import org.jetbrains.kotlin.gradle.utils.isParentOf
|
|
||||||
import org.jetbrains.kotlin.gradle.utils.toSortedPathsArray
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
@@ -29,12 +29,15 @@ abstract class KaptTask : ConventionTask() {
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
internal lateinit var stubsDir: File
|
internal lateinit var stubsDir: File
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
|
@get:InputFiles
|
||||||
val kaptClasspath: FileCollection
|
val kaptClasspath: FileCollection
|
||||||
get() = project.files(*kaptClasspathConfigurations.toTypedArray())
|
get() = project.files(*kaptClasspathConfigurations.toTypedArray())
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
val compilerClasspath: List<File> get() = kotlinCompileTask.computedCompilerClasspath
|
@get:InputFiles
|
||||||
|
val compilerClasspath: List<File>
|
||||||
|
get() = kotlinCompileTask.computedCompilerClasspath
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal lateinit var kaptClasspathConfigurations: List<Configuration>
|
internal lateinit var kaptClasspathConfigurations: List<Configuration>
|
||||||
@@ -51,14 +54,16 @@ abstract class KaptTask : ConventionTask() {
|
|||||||
@get:Nested
|
@get:Nested
|
||||||
internal val annotationProcessorOptionProviders: MutableList<Any> = mutableListOf()
|
internal val annotationProcessorOptionProviders: MutableList<Any> = mutableListOf()
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
|
@get:InputFiles
|
||||||
val classpath: FileCollection
|
val classpath: FileCollection
|
||||||
get() = kotlinCompileTask.classpath
|
get() = kotlinCompileTask.classpath
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
var useBuildCache: Boolean = false
|
var useBuildCache: Boolean = false
|
||||||
|
|
||||||
@get:InputFiles @get:PathSensitive(PathSensitivity.RELATIVE)
|
@get:InputFiles
|
||||||
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||||
val source: Collection<File>
|
val source: Collection<File>
|
||||||
get() {
|
get() {
|
||||||
val result = HashSet<File>()
|
val result = HashSet<File>()
|
||||||
|
|||||||
+2
-1
@@ -30,7 +30,8 @@ open class KaptWithKotlincTask : KaptTask(), CompilerArgumentAwareWithInput<K2JV
|
|||||||
@get:Classpath
|
@get:Classpath
|
||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
internal val kotlinTaskPluginClasspaths get() = kotlinCompileTask.pluginClasspath
|
internal val kotlinTaskPluginClasspaths
|
||||||
|
get() = kotlinCompileTask.pluginClasspath
|
||||||
|
|
||||||
@get:Classpath
|
@get:Classpath
|
||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
|
|||||||
+4
-1
@@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.internal
|
package org.jetbrains.kotlin.gradle.internal
|
||||||
|
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.Classpath
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputFiles
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.workers.IsolationMode
|
import org.gradle.workers.IsolationMode
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin.Companion.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME
|
import org.jetbrains.kotlin.gradle.internal.Kapt3KotlinGradleSubplugin.Companion.KAPT_WORKER_DEPENDENCIES_CONFIGURATION_NAME
|
||||||
|
|||||||
+1
-1
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.internal
|
package org.jetbrains.kotlin.gradle.internal
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.CompositeSubpluginOption
|
import org.jetbrains.kotlin.gradle.plugin.CompositeSubpluginOption
|
||||||
import org.jetbrains.kotlin.gradle.plugin.FilesSubpluginOption
|
import org.jetbrains.kotlin.gradle.plugin.FilesSubpluginOption
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|||||||
+2
-1
@@ -108,7 +108,8 @@ internal class KotlinGradleBuildServices private constructor(gradle: Gradle) : B
|
|||||||
log.lifecycle(FORCE_SYSTEM_GC_MESSAGE)
|
log.lifecycle(FORCE_SYSTEM_GC_MESSAGE)
|
||||||
val gcCountBefore = getGcCount()
|
val gcCountBefore = getGcCount()
|
||||||
System.gc()
|
System.gc()
|
||||||
while (getGcCount() == gcCountBefore) {}
|
while (getGcCount() == gcCountBefore) {
|
||||||
|
}
|
||||||
|
|
||||||
val rt = Runtime.getRuntime()
|
val rt = Runtime.getRuntime()
|
||||||
return (rt.totalMemory() - rt.freeMemory()) / 1024
|
return (rt.totalMemory() - rt.freeMemory()) / 1024
|
||||||
|
|||||||
+6
-6
@@ -76,8 +76,7 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
|||||||
configurationsForCommonModuleDependency(project).forEach { configuration ->
|
configurationsForCommonModuleDependency(project).forEach { configuration ->
|
||||||
configuration.dependencies.add(dep)
|
configuration.dependencies.add(dep)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw GradleException("$project '${config.name}' dependency is not a project: $dep")
|
throw GradleException("$project '${config.name}' dependency is not a project: $dep")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +103,8 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
|||||||
throw GradleException(
|
throw GradleException(
|
||||||
"Platform project $platformProject has an " +
|
"Platform project $platformProject has an " +
|
||||||
"'$EXPECTED_BY_CONFIG_NAME'${if (implementConfigurationIsUsed) "/'$IMPLEMENT_CONFIG_NAME'" else ""} " +
|
"'$EXPECTED_BY_CONFIG_NAME'${if (implementConfigurationIsUsed) "/'$IMPLEMENT_CONFIG_NAME'" else ""} " +
|
||||||
"dependency to non-common project $commonProject")
|
"dependency to non-common project $commonProject"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since the two projects may add source sets in arbitrary order, and both may do that after the plugin is applied,
|
// Since the two projects may add source sets in arbitrary order, and both may do that after the plugin is applied,
|
||||||
@@ -159,7 +159,8 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
|||||||
project.kotlinExtension.sourceSets
|
project.kotlinExtension.sourceSets
|
||||||
|
|
||||||
protected open fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
protected open fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
||||||
platformProject.whenEvaluated { // At the point when the source set in the platform module is created, the task does not exist
|
platformProject.whenEvaluated {
|
||||||
|
// At the point when the source set in the platform module is created, the task does not exist
|
||||||
val platformTask = platformProject.tasks
|
val platformTask = platformProject.tasks
|
||||||
.withType(AbstractKotlinCompile::class.java)
|
.withType(AbstractKotlinCompile::class.java)
|
||||||
.singleOrNull { it.sourceSetName == commonSourceSet.name } // TODO use strict check once this code is not run in K/N
|
.singleOrNull { it.sourceSetName == commonSourceSet.name } // TODO use strict check once this code is not run in K/N
|
||||||
@@ -203,8 +204,7 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
|
|||||||
internal fun <T> Project.whenEvaluated(fn: Project.() -> T) {
|
internal fun <T> Project.whenEvaluated(fn: Project.() -> T) {
|
||||||
if (state.executed) {
|
if (state.executed) {
|
||||||
fn()
|
fn()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
afterEvaluate { it.fn() }
|
afterEvaluate { it.fn() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-11
@@ -7,7 +7,6 @@ import groovy.lang.Closure
|
|||||||
import org.gradle.api.*
|
import org.gradle.api.*
|
||||||
import org.gradle.api.artifacts.ExternalDependency
|
import org.gradle.api.artifacts.ExternalDependency
|
||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.file.SourceDirectorySet
|
import org.gradle.api.file.SourceDirectorySet
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
@@ -18,7 +17,6 @@ import org.gradle.api.plugins.JavaPluginConvention
|
|||||||
import org.gradle.api.tasks.CompileClasspathNormalizer
|
import org.gradle.api.tasks.CompileClasspathNormalizer
|
||||||
import org.gradle.api.tasks.Delete
|
import org.gradle.api.tasks.Delete
|
||||||
import org.gradle.api.tasks.SourceSet
|
import org.gradle.api.tasks.SourceSet
|
||||||
import org.gradle.api.tasks.SourceSetOutput
|
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
import org.gradle.api.tasks.compile.JavaCompile
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
@@ -265,14 +263,16 @@ internal class Kotlin2JsSourceSetProcessor(
|
|||||||
|
|
||||||
val subpluginEnvironment: SubpluginEnvironment = SubpluginEnvironment.loadSubplugins(project, kotlinPluginVersion)
|
val subpluginEnvironment: SubpluginEnvironment = SubpluginEnvironment.loadSubplugins(project, kotlinPluginVersion)
|
||||||
val appliedPlugins = subpluginEnvironment.addSubpluginOptions(
|
val appliedPlugins = subpluginEnvironment.addSubpluginOptions(
|
||||||
project, kotlinTask, null, null, null, kotlinCompilation)
|
project, kotlinTask, null, null, null, kotlinCompilation
|
||||||
|
)
|
||||||
|
|
||||||
if (outputDir.isParentOf(project.rootDir))
|
if (outputDir.isParentOf(project.rootDir))
|
||||||
throw InvalidUserDataException(
|
throw InvalidUserDataException(
|
||||||
"The output directory '$outputDir' (defined by outputFile of $kotlinTask) contains or " +
|
"The output directory '$outputDir' (defined by outputFile of $kotlinTask) contains or " +
|
||||||
"matches the project root directory '${project.rootDir}'.\n" +
|
"matches the project root directory '${project.rootDir}'.\n" +
|
||||||
"Gradle will not be able to build the project because of the root directory lock.\n" +
|
"Gradle will not be able to build the project because of the root directory lock.\n" +
|
||||||
"To fix this, consider using the default outputFile location instead of providing it explicitly.")
|
"To fix this, consider using the default outputFile location instead of providing it explicitly."
|
||||||
|
)
|
||||||
|
|
||||||
kotlinTask.destinationDir = outputDir
|
kotlinTask.destinationDir = outputDir
|
||||||
|
|
||||||
@@ -334,7 +334,11 @@ internal abstract class AbstractKotlinPlugin(
|
|||||||
val registry: ToolingModelBuilderRegistry
|
val registry: ToolingModelBuilderRegistry
|
||||||
) : Plugin<Project> {
|
) : Plugin<Project> {
|
||||||
|
|
||||||
internal abstract fun buildSourceSetProcessor(project: Project, compilation: KotlinCompilation, kotlinPluginVersion: String): KotlinSourceSetProcessor<*>
|
internal abstract fun buildSourceSetProcessor(
|
||||||
|
project: Project,
|
||||||
|
compilation: KotlinCompilation,
|
||||||
|
kotlinPluginVersion: String
|
||||||
|
): KotlinSourceSetProcessor<*>
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.plugins.apply(JavaPlugin::class.java)
|
project.plugins.apply(JavaPlugin::class.java)
|
||||||
@@ -399,7 +403,8 @@ internal abstract class AbstractKotlinPlugin(
|
|||||||
val compilationsUnderConstruction = mutableMapOf<String, KotlinWithJavaCompilation>()
|
val compilationsUnderConstruction = mutableMapOf<String, KotlinWithJavaCompilation>()
|
||||||
|
|
||||||
javaSourceSets.all { javaSourceSet ->
|
javaSourceSets.all { javaSourceSet ->
|
||||||
val kotlinCompilation = compilationsUnderConstruction[javaSourceSet.name] ?: kotlinTarget.compilations.maybeCreate(javaSourceSet.name)
|
val kotlinCompilation =
|
||||||
|
compilationsUnderConstruction[javaSourceSet.name] ?: kotlinTarget.compilations.maybeCreate(javaSourceSet.name)
|
||||||
kotlinCompilation.javaSourceSet = javaSourceSet
|
kotlinCompilation.javaSourceSet = javaSourceSet
|
||||||
val kotlinSourceSet = project.kotlinExtension.sourceSets.maybeCreate(kotlinCompilation.name)
|
val kotlinSourceSet = project.kotlinExtension.sourceSets.maybeCreate(kotlinCompilation.name)
|
||||||
javaSourceSet.addConvention(kotlinSourceSetDslName, kotlinSourceSet)
|
javaSourceSet.addConvention(kotlinSourceSetDslName, kotlinSourceSet)
|
||||||
@@ -668,8 +673,10 @@ abstract class AbstractAndroidProjectHandler<V>(private val kotlinConfigurationT
|
|||||||
setUpDependencyResolution(variant, compilation)
|
setUpDependencyResolution(variant, compilation)
|
||||||
}
|
}
|
||||||
|
|
||||||
val androidPluginIds = listOf("android", "com.android.application", "android-library", "com.android.library",
|
val androidPluginIds = listOf(
|
||||||
"com.android.test", "com.android.feature", "com.android.dynamic-feature", "com.android.instantapp")
|
"android", "com.android.application", "android-library", "com.android.library",
|
||||||
|
"com.android.test", "com.android.feature", "com.android.dynamic-feature", "com.android.instantapp"
|
||||||
|
)
|
||||||
val plugin = androidPluginIds.asSequence()
|
val plugin = androidPluginIds.asSequence()
|
||||||
.mapNotNull { project.plugins.findPlugin(it) as? BasePlugin }
|
.mapNotNull { project.plugins.findPlugin(it) as? BasePlugin }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
@@ -751,7 +758,8 @@ abstract class AbstractAndroidProjectHandler<V>(private val kotlinConfigurationT
|
|||||||
val javaTask = getJavaTask(variantData)
|
val javaTask = getJavaTask(variantData)
|
||||||
|
|
||||||
val appliedPlugins = subpluginEnvironment.addSubpluginOptions(
|
val appliedPlugins = subpluginEnvironment.addSubpluginOptions(
|
||||||
project, kotlinTask, javaTask, wrapVariantDataForKapt(variantData), this, null)
|
project, kotlinTask, javaTask, wrapVariantDataForKapt(variantData), this, null
|
||||||
|
)
|
||||||
|
|
||||||
appliedPlugins.flatMap { it.getSubpluginKotlinTasks(project, kotlinTask) }
|
appliedPlugins.flatMap { it.getSubpluginKotlinTasks(project, kotlinTask) }
|
||||||
.forEach { configureSources(it, variantData, null) }
|
.forEach { configureSources(it, variantData, null) }
|
||||||
@@ -785,8 +793,7 @@ internal fun configureJavaTask(kotlinTask: KotlinCompile, javaTask: AbstractComp
|
|||||||
dir(kotlinTask.destinationDir)
|
dir(kotlinTask.destinationDir)
|
||||||
.withNormalizer(CompileClasspathNormalizer::class.java)
|
.withNormalizer(CompileClasspathNormalizer::class.java)
|
||||||
.withPropertyName("${kotlinTask.name}OutputClasses")
|
.withPropertyName("${kotlinTask.name}OutputClasses")
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
dirCompatible(kotlinTask.destinationDir)
|
dirCompatible(kotlinTask.destinationDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -152,8 +152,8 @@ fun Plugin<*>.loadKotlinVersionFromResource(log: Logger): String {
|
|||||||
log.kotlinDebug("Loading version information")
|
log.kotlinDebug("Loading version information")
|
||||||
val props = Properties()
|
val props = Properties()
|
||||||
val propFileName = "project.properties"
|
val propFileName = "project.properties"
|
||||||
val inputStream = javaClass.classLoader!!.getResourceAsStream(propFileName) ?:
|
val inputStream = javaClass.classLoader!!.getResourceAsStream(propFileName)
|
||||||
throw FileNotFoundException("property file '$propFileName' not found in the classpath")
|
?: throw FileNotFoundException("property file '$propFileName' not found in the classpath")
|
||||||
|
|
||||||
props.load(inputStream)
|
props.load(inputStream)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -77,8 +77,7 @@ internal class PropertiesProvider(private val project: Project) {
|
|||||||
private fun property(propName: String): String? =
|
private fun property(propName: String): String? =
|
||||||
if (project.hasProperty(propName)) {
|
if (project.hasProperty(propName)) {
|
||||||
project.property(propName) as? String
|
project.property(propName) as? String
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
localProperties.getProperty(propName)
|
localProperties.getProperty(propName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -121,7 +121,8 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
?: return // Otherwise, there is no runtime classpath
|
?: return // Otherwise, there is no runtime classpath
|
||||||
|
|
||||||
target.project.tasks.create(lowerCamelCaseName(target.targetName, testTaskNameSuffix), Test::class.java).apply {
|
target.project.tasks.create(lowerCamelCaseName(target.targetName, testTaskNameSuffix), Test::class.java).apply {
|
||||||
project.afterEvaluate { // use afterEvaluate to override the JavaPlugin defaults for Test tasks
|
project.afterEvaluate {
|
||||||
|
// use afterEvaluate to override the JavaPlugin defaults for Test tasks
|
||||||
conventionMapping.map("testClassesDirs") { testCompilation.output.classesDirs }
|
conventionMapping.map("testClassesDirs") { testCompilation.output.classesDirs }
|
||||||
conventionMapping.map("classpath") { testCompilation.runtimeDependencyFiles }
|
conventionMapping.map("classpath") { testCompilation.runtimeDependencyFiles }
|
||||||
description = "Runs the unit tests."
|
description = "Runs the unit tests."
|
||||||
@@ -653,7 +654,9 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
|
|
||||||
val compileOnlyDependencies = target.compilations.mapNotNull {
|
val compileOnlyDependencies = target.compilations.mapNotNull {
|
||||||
val dependencies = configurations.getByName(it.compileOnlyConfigurationName).allDependencies
|
val dependencies = configurations.getByName(it.compileOnlyConfigurationName).allDependencies
|
||||||
if (dependencies.isNotEmpty()) {it to dependencies} else null
|
if (dependencies.isNotEmpty()) {
|
||||||
|
it to dependencies
|
||||||
|
} else null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Dependency.stringCoordinates(): String = buildString {
|
fun Dependency.stringCoordinates(): String = buildString {
|
||||||
@@ -666,13 +669,15 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
with(target.project.logger) {
|
with(target.project.logger) {
|
||||||
warn("A compileOnly dependency is used in the Kotlin/Native target '${target.name}':")
|
warn("A compileOnly dependency is used in the Kotlin/Native target '${target.name}':")
|
||||||
compileOnlyDependencies.forEach {
|
compileOnlyDependencies.forEach {
|
||||||
warn("""
|
warn(
|
||||||
|
"""
|
||||||
Compilation: ${it.first.name}
|
Compilation: ${it.first.name}
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
${it.second.joinToString(separator = "\n") { it.stringCoordinates() }}
|
${it.second.joinToString(separator = "\n") { it.stringCoordinates() }}
|
||||||
|
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
warn("Such dependencies are not applicable for Kotlin/Native, consider changing the dependency type to 'implementation' or 'api'.")
|
warn("Such dependencies are not applicable for Kotlin/Native, consider changing the dependency type to 'implementation' or 'api'.")
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-7
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
import org.jetbrains.kotlin.gradle.utils.checkedReflection
|
import org.jetbrains.kotlin.gradle.utils.checkedReflection
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
internal class LegacyAndroidAndroidProjectHandler(kotlinConfigurationTools: KotlinConfigurationTools)
|
internal class LegacyAndroidAndroidProjectHandler(kotlinConfigurationTools: KotlinConfigurationTools) :
|
||||||
: AbstractAndroidProjectHandler<BaseVariantData<out BaseVariantOutputData>>(kotlinConfigurationTools) {
|
AbstractAndroidProjectHandler<BaseVariantData<out BaseVariantOutputData>>(kotlinConfigurationTools) {
|
||||||
|
|
||||||
override fun getSourceProviders(variantData: BaseVariantData<out BaseVariantOutputData>): Iterable<SourceProvider> =
|
override fun getSourceProviders(variantData: BaseVariantData<out BaseVariantOutputData>): Iterable<SourceProvider> =
|
||||||
variantData.sourceProviders
|
variantData.sourceProviders
|
||||||
@@ -93,15 +93,18 @@ internal class LegacyAndroidAndroidProjectHandler(kotlinConfigurationTools: Kotl
|
|||||||
if (AndroidGradleWrapper.isJackEnabled(variant)) {
|
if (AndroidGradleWrapper.isJackEnabled(variant)) {
|
||||||
throw ProjectConfigurationException(
|
throw ProjectConfigurationException(
|
||||||
"Kotlin Gradle plugin does not support the deprecated Jack toolchain.\n" +
|
"Kotlin Gradle plugin does not support the deprecated Jack toolchain.\n" +
|
||||||
"Disable Jack or revert to Kotlin Gradle plugin version 1.1.1.", null)
|
"Disable Jack or revert to Kotlin Gradle plugin version 1.1.1.", null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getJavaTask(variantData: BaseVariantData<out BaseVariantOutputData>): AbstractCompile? =
|
override fun getJavaTask(variantData: BaseVariantData<out BaseVariantOutputData>): AbstractCompile? =
|
||||||
AndroidGradleWrapper.getJavaTask(variantData)
|
AndroidGradleWrapper.getJavaTask(variantData)
|
||||||
|
|
||||||
override fun addJavaSourceDirectoryToVariantModel(variantData: BaseVariantData<out BaseVariantOutputData>,
|
override fun addJavaSourceDirectoryToVariantModel(
|
||||||
javaSourceDirectory: File) =
|
variantData: BaseVariantData<out BaseVariantOutputData>,
|
||||||
|
javaSourceDirectory: File
|
||||||
|
) =
|
||||||
variantData.addJavaSourceFoldersToModel(javaSourceDirectory)
|
variantData.addJavaSourceFoldersToModel(javaSourceDirectory)
|
||||||
|
|
||||||
override fun getTestedVariantData(variantData: BaseVariantData<*>): BaseVariantData<*>? =
|
override fun getTestedVariantData(variantData: BaseVariantData<*>): BaseVariantData<*>? =
|
||||||
@@ -114,8 +117,8 @@ internal class LegacyAndroidAndroidProjectHandler(kotlinConfigurationTools: Kotl
|
|||||||
private val BaseVariantData<*>.sourceProviders: List<SourceProvider>
|
private val BaseVariantData<*>.sourceProviders: List<SourceProvider>
|
||||||
get() = variantConfiguration.sortedSourceProviders
|
get() = variantConfiguration.sortedSourceProviders
|
||||||
|
|
||||||
private inner class KaptLegacyVariantData(variantData: BaseVariantData<out BaseVariantOutputData>)
|
private inner class KaptLegacyVariantData(variantData: BaseVariantData<out BaseVariantOutputData>) :
|
||||||
: KaptVariantData<BaseVariantData<out BaseVariantOutputData>>(variantData) {
|
KaptVariantData<BaseVariantData<out BaseVariantOutputData>>(variantData) {
|
||||||
|
|
||||||
override val name: String = variantData.name
|
override val name: String = variantData.name
|
||||||
override val sourceProviders: Iterable<SourceProvider> = getSourceProviders(variantData)
|
override val sourceProviders: Iterable<SourceProvider> = getSourceProviders(variantData)
|
||||||
|
|||||||
-1
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.gradle.plugin
|
|||||||
|
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.file.FileTree
|
|
||||||
import org.gradle.api.internal.HasConvention
|
import org.gradle.api.internal.HasConvention
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.gradle.api.plugins.ExtensionAware
|
import org.gradle.api.plugins.ExtensionAware
|
||||||
|
|||||||
+2
-1
@@ -98,7 +98,8 @@ private fun rewriteMppDependenciesToTargetModuleDependencies(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val resolvedCompileDependencies by lazy { // don't resolve if no project dependencies on MPP projects are found
|
val resolvedCompileDependencies by lazy {
|
||||||
|
// don't resolve if no project dependencies on MPP projects are found
|
||||||
targetCompileDependenciesConfiguration.resolvedConfiguration.lenientConfiguration.allModuleDependencies.associateBy {
|
targetCompileDependenciesConfiguration.resolvedConfiguration.lenientConfiguration.allModuleDependencies.associateBy {
|
||||||
Triple(it.moduleGroup, it.moduleName, it.moduleVersion)
|
Triple(it.moduleGroup, it.moduleName, it.moduleVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -43,7 +43,9 @@ class KotlinWithJavaCompilationOutput(
|
|||||||
|
|
||||||
override var resourcesDirProvider: Any
|
override var resourcesDirProvider: Any
|
||||||
get() = javaSourceSetOutput.resourcesDir
|
get() = javaSourceSetOutput.resourcesDir
|
||||||
set(value) { javaSourceSetOutput.setResourcesDir(value) }
|
set(value) {
|
||||||
|
javaSourceSetOutput.setResourcesDir(value)
|
||||||
|
}
|
||||||
|
|
||||||
override val classesDirs: ConfigurableFileCollection =
|
override val classesDirs: ConfigurableFileCollection =
|
||||||
if (isGradleVersionAtLeast(4, 0))
|
if (isGradleVersionAtLeast(4, 0))
|
||||||
|
|||||||
+5
-6
@@ -11,10 +11,8 @@ import org.gradle.api.NamedDomainObjectContainer
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.file.FileTree
|
|
||||||
import org.gradle.api.file.SourceDirectorySet
|
import org.gradle.api.file.SourceDirectorySet
|
||||||
import org.gradle.api.tasks.SourceSet
|
import org.gradle.api.tasks.SourceSet
|
||||||
import org.gradle.api.tasks.SourceSetOutput
|
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||||
@@ -26,7 +24,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
|||||||
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
|
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.IllegalArgumentException
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
@@ -327,7 +324,9 @@ class KotlinNativeCompilation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entryPoint: String? = null
|
var entryPoint: String? = null
|
||||||
fun entryPoint(value: String) { entryPoint = value }
|
fun entryPoint(value: String) {
|
||||||
|
entryPoint = value
|
||||||
|
}
|
||||||
|
|
||||||
// Interop DSL.
|
// Interop DSL.
|
||||||
val cinterops = project.container(DefaultCInteropSettings::class.java) { cinteropName ->
|
val cinterops = project.container(DefaultCInteropSettings::class.java) { cinteropName ->
|
||||||
@@ -350,8 +349,8 @@ class KotlinNativeCompilation(
|
|||||||
fun findLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeCompile? = binaryTasks[kind to buildType]
|
fun findLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeCompile? = binaryTasks[kind to buildType]
|
||||||
|
|
||||||
fun getLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeCompile =
|
fun getLinkTask(kind: NativeOutputKind, buildType: NativeBuildType): KotlinNativeCompile =
|
||||||
findLinkTask(kind, buildType) ?:
|
findLinkTask(kind, buildType)
|
||||||
throw IllegalArgumentException("Cannot find a link task for the binary kind '$kind' and the build type '$buildType'")
|
?: throw IllegalArgumentException("Cannot find a link task for the binary kind '$kind' and the build type '$buildType'")
|
||||||
|
|
||||||
fun findLinkTask(kind: String, buildType: String) =
|
fun findLinkTask(kind: String, buildType: String) =
|
||||||
findLinkTask(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
findLinkTask(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
||||||
|
|||||||
+2
-1
@@ -156,7 +156,8 @@ open class KotlinWithJavaTarget(
|
|||||||
get() = JavaPlugin.JAR_TASK_NAME
|
get() = JavaPlugin.JAR_TASK_NAME
|
||||||
|
|
||||||
override val compilations: NamedDomainObjectContainer<KotlinWithJavaCompilation> =
|
override val compilations: NamedDomainObjectContainer<KotlinWithJavaCompilation> =
|
||||||
project.container(KotlinWithJavaCompilation::class.java,
|
project.container(
|
||||||
|
KotlinWithJavaCompilation::class.java,
|
||||||
KotlinWithJavaCompilationFactory(project, this)
|
KotlinWithJavaCompilationFactory(project, this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-12
@@ -34,18 +34,17 @@ open class KotlinVariant(
|
|||||||
open class KotlinVariantWithCoordinates(
|
open class KotlinVariantWithCoordinates(
|
||||||
target: KotlinTarget
|
target: KotlinTarget
|
||||||
) : KotlinVariant(target),
|
) : KotlinVariant(target),
|
||||||
ComponentWithCoordinates /* Gradle 4.7+ API, don't use with older versions */
|
ComponentWithCoordinates /* Gradle 4.7+ API, don't use with older versions */ {
|
||||||
{
|
|
||||||
override fun getCoordinates() = object : ModuleVersionIdentifier {
|
override fun getCoordinates() = object : ModuleVersionIdentifier {
|
||||||
private val project get() = target.project
|
private val project get() = target.project
|
||||||
|
|
||||||
private val moduleName: String get() =
|
private val moduleName: String
|
||||||
publicationDelegate?.artifactId ?:
|
get() =
|
||||||
"${project.name}-${target.name.toLowerCase()}"
|
publicationDelegate?.artifactId ?: "${project.name}-${target.name.toLowerCase()}"
|
||||||
|
|
||||||
private val moduleGroup: String get() =
|
private val moduleGroup: String
|
||||||
publicationDelegate?.groupId ?:
|
get() =
|
||||||
project.group.toString()
|
publicationDelegate?.groupId ?: project.group.toString()
|
||||||
|
|
||||||
override fun getGroup() = moduleGroup
|
override fun getGroup() = moduleGroup
|
||||||
override fun getName() = moduleName
|
override fun getName() = moduleName
|
||||||
@@ -58,13 +57,13 @@ open class KotlinVariantWithCoordinates(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinVariantWithMetadataVariant(target: KotlinTarget, private val metadataTarget: KotlinTarget)
|
class KotlinVariantWithMetadataVariant(target: KotlinTarget, private val metadataTarget: KotlinTarget) :
|
||||||
: KotlinVariantWithCoordinates(target), ComponentWithVariants {
|
KotlinVariantWithCoordinates(target), ComponentWithVariants {
|
||||||
override fun getVariants() = setOf(metadataTarget.component)
|
override fun getVariants() = setOf(metadataTarget.component)
|
||||||
}
|
}
|
||||||
|
|
||||||
class KotlinVariantWithMetadataDependency(target: KotlinTarget, private val metadataTarget: KotlinTarget)
|
class KotlinVariantWithMetadataDependency(target: KotlinTarget, private val metadataTarget: KotlinTarget) :
|
||||||
: KotlinVariantWithCoordinates(target) {
|
KotlinVariantWithCoordinates(target) {
|
||||||
override fun getUsages(): Set<UsageContext> = target.createUsageContexts().mapTo(mutableSetOf()) { usageContext ->
|
override fun getUsages(): Set<UsageContext> = target.createUsageContexts().mapTo(mutableSetOf()) { usageContext ->
|
||||||
UsageContextWithAdditionalDependencies(usageContext, setOf(metadataDependency()))
|
UsageContextWithAdditionalDependencies(usageContext, setOf(metadataDependency()))
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -63,7 +63,8 @@ class DefaultKotlinSourceSet(
|
|||||||
|
|
||||||
override val resources: SourceDirectorySet = createDefaultSourceDirectorySet(displayName + " resources", fileResolver)
|
override val resources: SourceDirectorySet = createDefaultSourceDirectorySet(displayName + " resources", fileResolver)
|
||||||
|
|
||||||
override fun kotlin(configureClosure: Closure<Any?>): SourceDirectorySet = kotlin.apply { ConfigureUtil.configure(configureClosure, this) }
|
override fun kotlin(configureClosure: Closure<Any?>): SourceDirectorySet =
|
||||||
|
kotlin.apply { ConfigureUtil.configure(configureClosure, this) }
|
||||||
|
|
||||||
override fun languageSettings(configureClosure: Closure<Any?>): LanguageSettingsBuilder = languageSettings.apply {
|
override fun languageSettings(configureClosure: Closure<Any?>): LanguageSettingsBuilder = languageSettings.apply {
|
||||||
ConfigureUtil.configure(configureClosure, this)
|
ConfigureUtil.configure(configureClosure, this)
|
||||||
|
|||||||
+1
-1
@@ -12,12 +12,12 @@ import org.gradle.api.artifacts.Configuration
|
|||||||
import org.gradle.api.plugins.JavaPluginConvention
|
import org.gradle.api.plugins.JavaPluginConvention
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.scripting.ScriptingExtension
|
import org.jetbrains.kotlin.gradle.scripting.ScriptingExtension
|
||||||
import org.jetbrains.kotlin.gradle.tasks.GradleMessageCollector
|
import org.jetbrains.kotlin.gradle.tasks.GradleMessageCollector
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
import org.jetbrains.kotlin.script.KotlinScriptDefinition
|
import org.jetbrains.kotlin.script.KotlinScriptDefinition
|
||||||
import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
|
|
||||||
import org.jetbrains.kotlin.scripting.compiler.plugin.ScriptDefinitionsFromClasspathDiscoverySource
|
import org.jetbrains.kotlin.scripting.compiler.plugin.ScriptDefinitionsFromClasspathDiscoverySource
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -34,8 +34,7 @@ internal fun <T : Task> T.cacheOnlyIfEnabledForKotlin() {
|
|||||||
// The `cacheIf` method may be missing if the Gradle version is too low:
|
// The `cacheIf` method may be missing if the Gradle version is too low:
|
||||||
try {
|
try {
|
||||||
outputsCompatible.cacheIf { isBuildCacheEnabledForKotlin() }
|
outputsCompatible.cacheIf { isBuildCacheEnabledForKotlin() }
|
||||||
}
|
} catch (_: NoSuchMethodError) {
|
||||||
catch (_: NoSuchMethodError) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle.tasks
|
package org.jetbrains.kotlin.gradle.tasks
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class CompilerPluginOptions {
|
class CompilerPluginOptions {
|
||||||
private val mutableArguments = arrayListOf<String>()
|
private val mutableArguments = arrayListOf<String>()
|
||||||
|
|||||||
+4
-2
@@ -75,8 +75,10 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
|
|||||||
|
|
||||||
val log = GradleKotlinLogger(project.logger)
|
val log = GradleKotlinLogger(project.logger)
|
||||||
val allArgs = argsArray + outputDirArgs + inputFiles
|
val allArgs = argsArray + outputDirArgs + inputFiles
|
||||||
val exitCode = runToolInSeparateProcess(allArgs, K2JSDce::class.java.name, computedCompilerClasspath,
|
val exitCode = runToolInSeparateProcess(
|
||||||
log, createLoggingMessageCollector(log))
|
allArgs, K2JSDce::class.java.name, computedCompilerClasspath,
|
||||||
|
log, createLoggingMessageCollector(log)
|
||||||
|
)
|
||||||
throwGradleExceptionIfError(exitCode)
|
throwGradleExceptionIfError(exitCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-3
@@ -164,10 +164,13 @@ open class KotlinNativeCompile : AbstractCompile() {
|
|||||||
// Delegate for compilations's extra options.
|
// Delegate for compilations's extra options.
|
||||||
override var freeCompilerArgs: List<String>
|
override var freeCompilerArgs: List<String>
|
||||||
get() = compilation.extraOpts
|
get() = compilation.extraOpts
|
||||||
set(value) { compilation.extraOpts = value.toMutableList() }
|
set(value) {
|
||||||
|
compilation.extraOpts = value.toMutableList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal val kotlinOptions: KotlinCommonToolOptions = NativeCompilerOpts()
|
@Internal
|
||||||
|
val kotlinOptions: KotlinCommonToolOptions = NativeCompilerOpts()
|
||||||
|
|
||||||
fun kotlinOptions(fn: KotlinCommonToolOptions.() -> Unit) {
|
fun kotlinOptions(fn: KotlinCommonToolOptions.() -> Unit) {
|
||||||
kotlinOptions.fn()
|
kotlinOptions.fn()
|
||||||
@@ -206,7 +209,8 @@ open class KotlinNativeCompile : AbstractCompile() {
|
|||||||
val compilerPluginCommandLine
|
val compilerPluginCommandLine
|
||||||
@Input get() = compilerPluginOptions.arguments
|
@Input get() = compilerPluginOptions.arguments
|
||||||
|
|
||||||
@Optional @InputFiles
|
@Optional
|
||||||
|
@InputFiles
|
||||||
var compilerPluginClasspath: FileCollection? = null
|
var compilerPluginClasspath: FileCollection? = null
|
||||||
|
|
||||||
val serializedCompilerArguments: List<String>
|
val serializedCompilerArguments: List<String>
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,8 @@ internal sealed class SourceRoots(val kotlinSourceFiles: List<File>) {
|
|||||||
fun create(taskSource: FileTree, sourceRoots: FilteringSourceRootsContainer, sourceFilesExtensions: List<String>): ForJvm {
|
fun create(taskSource: FileTree, sourceRoots: FilteringSourceRootsContainer, sourceFilesExtensions: List<String>): ForJvm {
|
||||||
val kotlinSourceFiles = (taskSource as Iterable<File>).filter { it.isKotlinFile(sourceFilesExtensions) }
|
val kotlinSourceFiles = (taskSource as Iterable<File>).filter { it.isKotlinFile(sourceFilesExtensions) }
|
||||||
val javaSourceRoots = findRootsForSources(
|
val javaSourceRoots = findRootsForSources(
|
||||||
sourceRoots.sourceRoots, taskSource.filter(File::isJavaFile))
|
sourceRoots.sourceRoots, taskSource.filter(File::isJavaFile)
|
||||||
|
)
|
||||||
return ForJvm(kotlinSourceFiles, javaSourceRoots)
|
return ForJvm(kotlinSourceFiles, javaSourceRoots)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-6
@@ -108,8 +108,7 @@ internal open class SyncOutputTask : DefaultTask() {
|
|||||||
logger.kotlinDebug { "Incremental copying files from $sourceDirs to $javaOutputDir" }
|
logger.kotlinDebug { "Incremental copying files from $sourceDirs to $javaOutputDir" }
|
||||||
inputs.outOfDate { processIncrementally(it) }
|
inputs.outOfDate { processIncrementally(it) }
|
||||||
inputs.removed { processIncrementally(it) }
|
inputs.removed { processIncrementally(it) }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
logger.kotlinDebug { "Non-incremental copying files from $sourceDirs to $javaOutputDir" }
|
logger.kotlinDebug { "Non-incremental copying files from $sourceDirs to $javaOutputDir" }
|
||||||
processNonIncrementally()
|
processNonIncrementally()
|
||||||
}
|
}
|
||||||
@@ -143,8 +142,7 @@ internal open class SyncOutputTask : DefaultTask() {
|
|||||||
if (input.isRemoved) {
|
if (input.isRemoved) {
|
||||||
// file was removed in kotlin dir, remove from java as well
|
// file was removed in kotlin dir, remove from java as well
|
||||||
remove(fileInJavaDir)
|
remove(fileInJavaDir)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// copy modified or added file from kotlin to java
|
// copy modified or added file from kotlin to java
|
||||||
copy(fileInKotlinDir, fileInJavaDir)
|
copy(fileInKotlinDir, fileInJavaDir)
|
||||||
}
|
}
|
||||||
@@ -203,8 +201,7 @@ private fun saveTimestamps(snapshotFile: File, timestamps: Map<File, Long>, file
|
|||||||
if (!snapshotFile.exists()) {
|
if (!snapshotFile.exists()) {
|
||||||
snapshotFile.parentFile.mkdirs()
|
snapshotFile.parentFile.mkdirs()
|
||||||
snapshotFile.createNewFile()
|
snapshotFile.createNewFile()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
snapshotFile.delete()
|
snapshotFile.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -81,7 +81,8 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments>() : AbstractCo
|
|||||||
@get:Input
|
@get:Input
|
||||||
internal var useFallbackCompilerSearch: Boolean = false
|
internal var useFallbackCompilerSearch: Boolean = false
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
|
@get:InputFiles
|
||||||
internal val computedCompilerClasspath: List<File>
|
internal val computedCompilerClasspath: List<File>
|
||||||
get() = compilerClasspath?.takeIf { it.isNotEmpty() }
|
get() = compilerClasspath?.takeIf { it.isNotEmpty() }
|
||||||
?: compilerJarFile?.let {
|
?: compilerJarFile?.let {
|
||||||
@@ -129,7 +130,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal val buildHistoryFile: File get() = File(taskBuildDirectory, "build-history.bin")
|
internal val buildHistoryFile: File
|
||||||
|
get() = File(taskBuildDirectory, "build-history.bin")
|
||||||
|
|
||||||
@get:Input
|
@get:Input
|
||||||
internal var useModuleDetection: Boolean = false
|
internal var useModuleDetection: Boolean = false
|
||||||
@@ -146,7 +148,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
internal val pluginOptions = CompilerPluginOptions()
|
internal val pluginOptions = CompilerPluginOptions()
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath
|
||||||
|
@get:InputFiles
|
||||||
protected val additionalClasspath = arrayListOf<File>()
|
protected val additionalClasspath = arrayListOf<File>()
|
||||||
|
|
||||||
@get:Internal // classpath already participates in the checks
|
@get:Internal // classpath already participates in the checks
|
||||||
@@ -413,8 +416,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
|
|
||||||
disableMultiModuleICIfNeeded()
|
disableMultiModuleICIfNeeded()
|
||||||
processCompilerExitCode(exitCode)
|
processCompilerExitCode(exitCode)
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
cleanupOnError()
|
cleanupOnError()
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -156,8 +156,7 @@ private fun findPotentialModuleJars(project: Project, moduleId: String): Iterabl
|
|||||||
|
|
||||||
if (compilerEmbeddable != null) {
|
if (compilerEmbeddable != null) {
|
||||||
return compilerEmbeddable.moduleArtifacts.map { it.file }
|
return compilerEmbeddable.moduleArtifacts.map { it.file }
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
allFiles.addAll(configuration.files)
|
allFiles.addAll(configuration.files)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,11 +178,9 @@ private fun File.hasEntry(entryToFind: String): Boolean {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return zip.getEntry(entryToFind) != null
|
return zip.getEntry(entryToFind) != null
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e: Exception) {
|
|
||||||
return false
|
return false
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
zip.close()
|
zip.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -2,21 +2,18 @@ package org.jetbrains.kotlin.gradle.tasks
|
|||||||
|
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.utils.outputsCompatible
|
import org.jetbrains.kotlin.gradle.utils.outputsCompatible
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.reflect.KProperty1
|
|
||||||
import kotlin.reflect.full.findAnnotation
|
|
||||||
import kotlin.reflect.full.memberProperties
|
|
||||||
|
|
||||||
fun throwGradleExceptionIfError(exitCode: ExitCode) {
|
fun throwGradleExceptionIfError(exitCode: ExitCode) {
|
||||||
when (exitCode) {
|
when (exitCode) {
|
||||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
||||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
||||||
ExitCode.SCRIPT_EXECUTION_ERROR -> throw GradleException("Script execution error. See log for more details")
|
ExitCode.SCRIPT_EXECUTION_ERROR -> throw GradleException("Script execution error. See log for more details")
|
||||||
ExitCode.OK -> {}
|
ExitCode.OK -> {
|
||||||
|
}
|
||||||
else -> throw IllegalStateException("Unexpected exit code: $exitCode")
|
else -> throw IllegalStateException("Unexpected exit code: $exitCode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -10,7 +10,8 @@ import org.gradle.api.artifacts.repositories.ArtifactRepository
|
|||||||
import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout
|
import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout
|
||||||
import org.gradle.api.file.FileTree
|
import org.gradle.api.file.FileTree
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.jetbrains.kotlin.compilerRunner.*
|
import org.jetbrains.kotlin.compilerRunner.KonanCompilerRunner
|
||||||
|
import org.jetbrains.kotlin.compilerRunner.konanVersion
|
||||||
import org.jetbrains.kotlin.konan.KonanVersion
|
import org.jetbrains.kotlin.konan.KonanVersion
|
||||||
import org.jetbrains.kotlin.konan.KonanVersionImpl
|
import org.jetbrains.kotlin.konan.KonanVersionImpl
|
||||||
import org.jetbrains.kotlin.konan.MetaVersion
|
import org.jetbrains.kotlin.konan.MetaVersion
|
||||||
|
|||||||
+1
-2
@@ -30,8 +30,7 @@ internal data class ParsedGradleVersion(val major: Int, val minor: Int) : Compar
|
|||||||
private fun String.parseIntOrNull(): Int? =
|
private fun String.parseIntOrNull(): Int? =
|
||||||
try {
|
try {
|
||||||
toInt()
|
toInt()
|
||||||
}
|
} catch (e: NumberFormatException) {
|
||||||
catch (e: NumberFormatException) {
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-6
@@ -33,14 +33,11 @@ internal fun Class<*>.getDeclaredFieldInHierarchy(name: String): Field? {
|
|||||||
internal inline fun <T> checkedReflection(block: () -> T, onReflectionException: (Exception) -> T): T {
|
internal inline fun <T> checkedReflection(block: () -> T, onReflectionException: (Exception) -> T): T {
|
||||||
return try {
|
return try {
|
||||||
block()
|
block()
|
||||||
}
|
} catch (e: InvocationTargetException) {
|
||||||
catch (e: InvocationTargetException) {
|
|
||||||
throw e.targetException
|
throw e.targetException
|
||||||
}
|
} catch (e: ReflectiveOperationException) {
|
||||||
catch (e: ReflectiveOperationException) {
|
|
||||||
onReflectionException(e)
|
onReflectionException(e)
|
||||||
}
|
} catch (e: IllegalArgumentException) {
|
||||||
catch (e: IllegalArgumentException) {
|
|
||||||
onReflectionException(e)
|
onReflectionException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -13,7 +13,8 @@ class KotlinJvmOptionsTest {
|
|||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xdump-declarations-to", "declarationsPath",
|
"-Xdump-declarations-to", "declarationsPath",
|
||||||
"-script-templates", "a,b,c")
|
"-script-templates", "a,b,c"
|
||||||
|
)
|
||||||
|
|
||||||
val arguments = K2JVMCompilerArguments()
|
val arguments = K2JVMCompilerArguments()
|
||||||
options.updateArguments(arguments)
|
options.updateArguments(arguments)
|
||||||
|
|||||||
Reference in New Issue
Block a user