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

org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmAndroidCompilation.kt Maven / Gradle / Ivy

There is a newer version: 2.0.20-RC
Show newest version
 /*
 * Copyright 2010-2018 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.
 */

@file:Suppress("PackageDirectoryMismatch") // Old package for compatibility
package org.jetbrains.kotlin.gradle.plugin.mpp

import com.android.build.gradle.api.BaseVariant
import org.gradle.api.file.FileCollection
import org.gradle.api.provider.Property
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.getTestedVariantData

 class KotlinJvmAndroidCompilation(
     target: KotlinAndroidTarget,
     name: String
 ) : AbstractKotlinCompilationToRunnableFiles(target, name) {

     lateinit internal var androidVariant: BaseVariant

     override val compileKotlinTask: org.jetbrains.kotlin.gradle.tasks.KotlinCompile
         get() = super.compileKotlinTask as org.jetbrains.kotlin.gradle.tasks.KotlinCompile

     @Suppress("UnstableApiUsage")
     internal val testedVariantArtifacts: Property = target.project.objects.property(FileCollection::class.java)

     override val friendArtifacts: FileCollection get() = target.project.files(super.friendArtifacts, testedVariantArtifacts)

     override fun addAssociateCompilationDependencies(other: KotlinCompilation<*>) {
         if ((other as? KotlinJvmAndroidCompilation)?.androidVariant != getTestedVariantData(androidVariant)) {
             super.addAssociateCompilationDependencies(other)
         } // otherwise, do nothing: the Android Gradle plugin adds these dependencies for us, we don't need to add them to the classpath
     }

     override val relatedConfigurationNames: List
         get() = super.relatedConfigurationNames + listOf(
             "${androidVariant.name}ApiElements",
             "${androidVariant.name}RuntimeElements",
             androidVariant.compileConfiguration.name,
             androidVariant.runtimeConfiguration.name
         )
 }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy