Skip to content

Commit

Permalink
android: Use ANDROID_BUILD_TOOLS_VERSION env variable for `buildToo…
Browse files Browse the repository at this point in the history
…lsVersion`

Closes #132
  • Loading branch information
osipxd committed Jul 10, 2024
1 parent 70b8218 commit 937148a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {

### Other Changes

- **android:** Use `ANDROID_BUILD_TOOLS_VERSION` env variable for `buildToolsVersion` if the option is not configured (#132)
- **android:** Remove the workaround for Explicit API enabling as the issue has been [fixed](https://youtrack.jetbrains.com/issue/KT-37652) in Kotlin 1.9
- **android:** Remove disabling of build features `aidl`, `renderScript` and `buildConfig` as they are already disabled by default in new versions of AGP
- **kotlin:** Deprecate accessor `kotlinCompile`.
Expand Down
18 changes: 13 additions & 5 deletions infrastructure-android/src/main/kotlin/android/AndroidOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ import org.gradle.api.tasks.TaskProvider
/** Options for android projects. */
public interface AndroidOptions {

/** Minimal Android SDK to use across all android modules. */
/**
* Minimal Android SDK to be used in all android modules.
* By default, SDK 23 is used.
*/
public val minSdk: Property<Int>

/** Target Android SDK to use across all android modules. */
/**
* Target Android SDK to be used in all android modules.
* By default, SDK 34 is used.
*/
public val targetSdk: Property<Int>

/**
* Compile Android SDK to use across all android modules.
* Compile Android SDK to be used in all android modules.
* It can be version number ("33") or version code ("T").
* Uses [targetSdk] as compile SDK if not configured.
*/
public val compileSdk: Property<String>

/**
* Build Tools version to use across all android modules.
* Uses default version for current Android Gradle Plugin if not configured.
* Build Tools version to be used in all android modules.
*
* By default, uses the version from environment variable `ANDROID_BUILD_TOOLS_VERSION`,
* or default version for current Android Gradle Plugin if the variable is not present.
*/
public val buildToolsVersion: Property<String>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.kotlin.TestOptions
import com.redmadrobot.build.kotlin.TestOptionsImpl
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.ProviderFactory
import org.gradle.kotlin.dsl.create
import javax.inject.Inject

@OptIn(InternalGradleInfrastructureApi::class)
@Suppress("LeakingThis")
internal abstract class AndroidOptionsImpl : AndroidOptions, WithDefaults<AndroidOptionsImpl> {
internal abstract class AndroidOptionsImpl @Inject constructor(
providers: ProviderFactory,
) : AndroidOptions, WithDefaults<AndroidOptionsImpl> {

private val testOptions: TestOptionsImpl
private var areTestDefaultsSet = false
Expand All @@ -25,6 +29,7 @@ internal abstract class AndroidOptionsImpl : AndroidOptions, WithDefaults<Androi
.convention(targetSdk.map(Int::toString))
.finalizeValueOnRead()
buildToolsVersion
.convention(providers.environmentVariable("ANDROID_BUILD_TOOLS_VERSION"))
.finalizeValueOnRead()
testTasksFilter
.convention { taskProvider -> taskProvider.name.endsWith("ReleaseUnitTest") }
Expand Down

0 comments on commit 937148a

Please sign in to comment.