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

org.jetbrains.kotlin.gradle.model.builder.KotlinAndroidExtensionModelBuilder.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-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.
 */

package org.jetbrains.kotlin.gradle.model.builder

import org.gradle.api.Project
import org.gradle.tooling.provider.model.ToolingModelBuilder
import org.jetbrains.kotlin.gradle.internal.AndroidExtensionsExtension
import org.jetbrains.kotlin.gradle.model.KotlinAndroidExtension
import org.jetbrains.kotlin.gradle.model.impl.KotlinAndroidExtensionImpl

/**
 * [ToolingModelBuilder] for [KotlinAndroidExtension] models.
 * This model builder is registered for Kapt Gradle sub-plugin.
 */
class KotlinAndroidExtensionModelBuilder : ToolingModelBuilder {

    override fun canBuild(modelName: String): Boolean {
        return modelName == KotlinAndroidExtension::class.java.name
    }

    override fun buildAll(modelName: String, project: Project): Any {
        require(canBuild(modelName)) { "buildAll(\"$modelName\") has been called while canBeBuild is false" }
        val extension = project.extensions.getByType(AndroidExtensionsExtension::class.java)
        return KotlinAndroidExtensionImpl(project.name, extension.isExperimental, extension.defaultCacheImplementation.optionName)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy