All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.gradle.tasks.GradleCompileTaskProvider.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.gradle.tasks

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.logging.Logger
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Provider
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Internal
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.Companion.normalizeForFlagFile
import org.jetbrains.kotlin.gradle.incremental.IncrementalModuleInfoProvider
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
import org.jetbrains.kotlin.gradle.utils.*
import org.jetbrains.kotlin.gradle.utils.kotlinErrorsDir
import org.jetbrains.kotlin.gradle.utils.kotlinSessionsDir
import org.jetbrains.kotlin.gradle.utils.property
import java.io.File
import javax.inject.Inject

abstract class GradleCompileTaskProvider @Inject constructor(
    objectFactory: ObjectFactory,
    projectLayout: ProjectLayout,
    task: Task,
    project: Project,
    incrementalModuleInfoProvider: Provider
) {

    @get:Internal
    val path: Provider = objectFactory.property(task.path)

    @get:Internal
    val logger: Provider = objectFactory.property(task.logger)

    @get:Internal
    val buildDir: DirectoryProperty = projectLayout.buildDirectory

    @get:Internal
    val projectDir: Provider = objectFactory
        .property(project.rootProject.projectDir)

    @get:Internal
    val sessionsDir: Provider = objectFactory
        .property(project.kotlinSessionsDir)

    @get:Internal
    val projectName: Provider = objectFactory
        .property(project.rootProject.name.normalizeForFlagFile())

    @get:Internal
    val buildModulesInfo: Provider = objectFactory
        .property(incrementalModuleInfoProvider)

    @get:Internal
    val errorsFiles: SetProperty = objectFactory
        .setPropertyWithValue(
            setOfNotNull(
                project.kotlinErrorsDir
                    .errorFile,
                if (!project.kotlinPropertiesProvider.kotlinProjectPersistentDirGradleDisableWrite) {
                    project.rootDir
                        .resolve(".gradle/kotlin/errors/")
                        .errorFile
                } else null,
            )
        )
        .chainedDisallowChanges()
}

private val File.errorFile get() = resolve("errors-${System.currentTimeMillis()}.log")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy