1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.build 18 19 import org.gradle.api.Project 20 import org.gradle.api.provider.Provider 21 import org.jetbrains.kotlin.gradle.dsl.KotlinVersion 22 23 /** Public-facing interface for the `androidx` configuration DSL. */ 24 interface AndroidXConfiguration { 25 /** 26 * Target Kotlin API version passed to the Kotlin compiler. 27 * 28 * Specified using `kotlinTarget` in the `androidx` DSL. 29 */ 30 val kotlinApiVersion: Provider<KotlinVersion> 31 32 /** 33 * Version of the Kotlin BOM used to resolve dependencies in the `org.jetbrains.kotlin` group. 34 * 35 * Specified using `kotlinTarget` in the `androidx` DSL. 36 */ 37 val kotlinBomVersion: Provider<String> 38 } 39 40 enum class KotlinTarget(val apiVersion: KotlinVersion, val catalogVersion: String) { 41 KOTLIN_1_8(KotlinVersion.KOTLIN_1_8, "kotlin18"), 42 KOTLIN_1_9(KotlinVersion.KOTLIN_1_9, "kotlin19"), 43 KOTLIN_2_0(KotlinVersion.KOTLIN_2_0, "kotlin20"), 44 KOTLIN_2_1(KotlinVersion.KOTLIN_2_1, "kotlin21"), 45 DEFAULT(KOTLIN_2_0); 46 47 constructor( 48 kotlinTarget: KotlinTarget 49 ) : this(kotlinTarget.apiVersion, kotlinTarget.catalogVersion) 50 } 51 52 val Project.androidXConfiguration: AndroidXConfiguration 53 get() = extensions.findByType(AndroidXConfiguration::class.java)!! 54