evaluate and use buildDir as late as possible
(cherry picked from commit a2c7f80) (cherry picked from commit 5643fa1)
This commit is contained in:
committed by
Sergey Igushkin
parent
351f810797
commit
b2cdb0d63d
+2
-2
@@ -72,8 +72,8 @@ internal class KotlinGradleBuildServices private constructor(gradle: Gradle): Bu
|
|||||||
private val log = Logging.getLogger(this.javaClass)
|
private val log = Logging.getLogger(this.javaClass)
|
||||||
private val cleanup = CompilerServicesCleanup()
|
private val cleanup = CompilerServicesCleanup()
|
||||||
private var startMemory: Long? = null
|
private var startMemory: Long? = null
|
||||||
private val workingDir = File(gradle.rootProject.buildDir, "kotlin-build").apply { mkdirs() }
|
private val workingDir: File by lazy { File(gradle.rootProject.buildDir, "kotlin-build").apply { mkdirs() } }
|
||||||
private val buildCacheStorage = BuildCacheStorage(workingDir)
|
private val buildCacheStorage: BuildCacheStorage by lazy { BuildCacheStorage(workingDir) }
|
||||||
private val shouldReportMemoryUsage = System.getProperty(SHOULD_REPORT_MEMORY_USAGE_PROPERTY) != null
|
private val shouldReportMemoryUsage = System.getProperty(SHOULD_REPORT_MEMORY_USAGE_PROPERTY) != null
|
||||||
|
|
||||||
internal val artifactDifferenceRegistryProvider: ArtifactDifferenceRegistryProvider
|
internal val artifactDifferenceRegistryProvider: ArtifactDifferenceRegistryProvider
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
|
|||||||
val kotlinCompile = doCreateTask(project, name)
|
val kotlinCompile = doCreateTask(project, name)
|
||||||
kotlinCompile.description = taskDescription
|
kotlinCompile.description = taskDescription
|
||||||
kotlinCompile.mapClasspath { sourceSet.compileClasspath }
|
kotlinCompile.mapClasspath { sourceSet.compileClasspath }
|
||||||
kotlinCompile.destinationDir = defaultKotlinDestinationDir
|
kotlinCompile.setDestinationDir { defaultKotlinDestinationDir }
|
||||||
sourceSet.output.tryAddClassesDir { project.files(kotlinTask.destinationDir).builtBy(kotlinTask) }
|
sourceSet.output.tryAddClassesDir { project.files(kotlinTask.destinationDir).builtBy(kotlinTask) }
|
||||||
return kotlinCompile
|
return kotlinCompile
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -97,6 +97,20 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
System.setProperty("kotlin.incremental.compilation.experimental", value.toString())
|
System.setProperty("kotlin.incremental.compilation.experimental", value.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private lateinit var destinationDirProvider: Lazy<File>
|
||||||
|
|
||||||
|
override fun getDestinationDir(): File {
|
||||||
|
return destinationDirProvider.value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setDestinationDir(provider: () -> File) {
|
||||||
|
destinationDirProvider = lazy(provider)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setDestinationDir(destinationDir: File) {
|
||||||
|
destinationDirProvider = lazyOf(destinationDir)
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
incremental = true //to execute the setter as well
|
incremental = true //to execute the setter as well
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user