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

org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * Copyright 2010-2019 JetBrains s.r.o. 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.plugin.mpp

import org.gradle.api.Action
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptionsDefault
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
import org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetConfigurator
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
import org.jetbrains.kotlin.gradle.utils.newInstance
import javax.inject.Inject

abstract class KotlinMetadataTarget @Inject constructor(
    project: Project,
) : KotlinOnlyTarget>(project, KotlinPlatformType.common) {

    override val artifactsTaskName: String
        // The IDE import looks at this task name to determine the artifact and register the path to the artifact;
        // in HMPP, since the project resolves to the all-metadata JAR, the IDE import needs to work with that JAR, too
        get() = if (project.isKotlinGranularMetadataEnabled) KotlinMetadataTargetConfigurator.ALL_METADATA_JAR_NAME else super.artifactsTaskName

    internal val legacyArtifactsTaskName: String
        get() = super.artifactsTaskName

    override val kotlinComponents: Set by lazy {
        /*
        Metadata Target does not have a KotlinTargetComponent on it's own.
        Responsibility is shifted to the root KotlinSoftwareComponent
        */
        emptySet()
    }

    @Suppress("RedundantVisibilityModifier")
    @ExperimentalKotlinGradlePluginApi
    internal override val compilerOptions: KotlinCommonCompilerOptions = project.objects
        .newInstance()

    @ExperimentalKotlinGradlePluginApi
    internal fun compilerOptions(configure: KotlinCommonCompilerOptions.() -> Unit) {
        configure(compilerOptions)
    }

    @ExperimentalKotlinGradlePluginApi
    internal fun compilerOptions(configure: Action) {
        configure.execute(compilerOptions)
    }

    companion object {
        const val METADATA_TARGET_NAME = "metadata"
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy