-
\ No newline at end of file
+
diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml
index 524f428..800dcd0 100644
--- a/.idea/externalDependencies.xml
+++ b/.idea/externalDependencies.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be9848a..c61456d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,11 +16,30 @@ android {
### :warning: BREAKING CHANGES
+- **common:** Deprecate `redmadrobot.jvmTarget` with deprecation level `Error`.
+ Use [JVM Toolchains](https://kotl.in/gradle/jvm/toolchain) instead to specify JVM target.
+ Kotlin, Android Gradle Plugin, detekt and many other tools have support for this mechanism,
+ In most cases, adding this into your `build.gradle.kts` should be enough:
+ ```kotlin
+ kotlin {
+ jvmToolchain(17)
+ }
+ ```
+ You can also configure [automatic toolchains downloading](https://docs.gradle.org/current/userguide/toolchains.html#sub:download_repositories).
+- **common:** Disable [automatic repositories adding](https://github.com/RedMadRobot/gradle-infrastructure#automatically-added-repositories) by default.
+ If you rely on this feature, consider declaring required repositories explicitly, or enable it in `gradle.properties`:
+ ```properties
+ redmadrobot.add.repositories=true
+ ```
- **android:** Default `targetSdk` changed from `33` to `34`
+- **android:** Do not add `LOCK_ORIENTATION` and `CRASH_REPORTS_ENABLED` variables to `BuildConfig` implicitly
### Other Changes
+- **android:** Use `ANDROID_BUILD_TOOLS_VERSION` env variable for `buildToolsVersion` if the option is not configured (#132)
+- **android:** Add the option `redmadrobot.android.ndkVersion` to specify NDK version for all android modules
- **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`.
It is recommended to use `kotlin.compilerOptions { ... }` to configure compilation instead.
- Update Gradle to `8.8`
diff --git a/README.md b/README.md
index 4335169..cf74bb8 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@
Small plugins to reduce boilerplate in Gradle build scripts.
-> :warning: It is designed to use with Gradle Kotlin DSL and can't be used from Groovy DSL.
+> [!IMPORTANT]
+> These plugins are designed to be used with Gradle Kotlin DSL only.
---
@@ -24,7 +25,7 @@ Small plugins to reduce boilerplate in Gradle build scripts.
- [Configuration](#configuration)
- [Align version of all Kotlin libraries](#align-version-of-all-kotlin-libraries)
- [Warnings as errors](#warnings-as-errors)
- - [Share sources between build types](#share-sources-between-build-types)
+ - [Share sources between build variants](#share-sources-between-build-variants)
- [Enable Detekt checks only on changed files](#enable-detekt-checks-only-on-changed-files)
- [Configure JUnit test execution options](#configure-junit-test-execution-options)
- [Automatically added repositories](#automatically-added-repositories)
@@ -109,15 +110,36 @@ android {
## Plugins
-[![](https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggQlRcbnN1YmdyYXBoIGluZnJhc3RydWN0dXJlLWFuZHJvaWRcbiAgICBhbmRyb2lkLWNvbmZpZ1tjb20ucmVkbWFkcm9ib3QuYW5kcm9pZC1jb25maWddXG4gICAgY29tLnJlZG1hZHJvYm90LmFwcGxpY2F0aW9uIC0tPiBhbmRyb2lkLWNvbmZpZ1xuICAgIGNvbS5yZWRtYWRyb2JvdC5hbmRyb2lkLWxpYnJhcnkgLS0-IGFuZHJvaWQtY29uZmlnXG5lbmRcblxuc3ViZ3JhcGggaW5mcmFzdHJ1Y3R1cmUtZGV0ZWt0XG4gICAgY29tLnJlZG1hZHJvYm90LmRldGVrdFxuZW5kXG5cbnN1YmdyYXBoIGluZnJhc3RydWN0dXJlLWtvdGxpblxuICAgIGtvdGxpbi1jb25maWdbY29tLnJlZG1hZHJvYm90LmtvdGxpbi1jb25maWddXG4gICAgY29tLnJlZG1hZHJvYm90LmtvdGxpbi1saWJyYXJ5IC0tPiBrb3RsaW4tY29uZmlnXG5lbmRcblxuc3ViZ3JhcGggaW5mcmFzdHJ1Y3R1cmUtcHVibGlzaFxuICAgIHB1Ymxpc2gtY29uZmlnW2NvbS5yZWRtYWRyb2JvdC5wdWJsaXNoLWNvbmZpZ11cbiAgICBjb20ucmVkbWFkcm9ib3QucHVibGlzaCAtLT4gcHVibGlzaC1jb25maWdcbmVuZFxuXG5hbmRyb2lkLWNvbmZpZyAtLT4ga290bGluLWNvbmZpZyIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In0sInVwZGF0ZUVkaXRvciI6dHJ1ZSwiYXV0b1N5bmMiOnRydWUsInVwZGF0ZURpYWdyYW0iOnRydWV9)](https://mermaid-js.github.io/mermaid-live-editor/edit/#eyJjb2RlIjoiZ3JhcGggQlRcbnN1YmdyYXBoIGluZnJhc3RydWN0dXJlLWFuZHJvaWRcbiAgICBhbmRyb2lkLWNvbmZpZ1tjb20ucmVkbWFkcm9ib3QuYW5kcm9pZC1jb25maWddXG4gICAgY29tLnJlZG1hZHJvYm90LmFwcGxpY2F0aW9uIC0tPiBhbmRyb2lkLWNvbmZpZ1xuICAgIGNvbS5yZWRtYWRyb2JvdC5hbmRyb2lkLWxpYnJhcnkgLS0-IGFuZHJvaWQtY29uZmlnXG5lbmRcblxuc3ViZ3JhcGggaW5mcmFzdHJ1Y3R1cmUtZGV0ZWt0XG4gICAgY29tLnJlZG1hZHJvYm90LmRldGVrdFxuZW5kXG5cbnN1YmdyYXBoIGluZnJhc3RydWN0dXJlLWtvdGxpblxuICAgIGtvdGxpbi1jb25maWdbY29tLnJlZG1hZHJvYm90LmtvdGxpbi1jb25maWddXG4gICAgY29tLnJlZG1hZHJvYm90LmtvdGxpbi1saWJyYXJ5IC0tPiBrb3RsaW4tY29uZmlnXG5lbmRcblxuc3ViZ3JhcGggaW5mcmFzdHJ1Y3R1cmUtcHVibGlzaFxuICAgIHB1Ymxpc2gtY29uZmlnW2NvbS5yZWRtYWRyb2JvdC5wdWJsaXNoLWNvbmZpZ11cbiAgICBjb20ucmVkbWFkcm9ib3QucHVibGlzaCAtLT4gcHVibGlzaC1jb25maWdcbmVuZFxuXG5hbmRyb2lkLWNvbmZpZyAtLT4ga290bGluLWNvbmZpZyIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkZWZhdWx0XCJcbn0iLCJ1cGRhdGVFZGl0b3IiOnRydWUsImF1dG9TeW5jIjp0cnVlLCJ1cGRhdGVEaWFncmFtIjp0cnVlfQ)
+```mermaid
+graph BT
+subgraph infrastructure-android
+ android-config[com.redmadrobot.android-config]
+ com.redmadrobot.application --> android-config
+ com.redmadrobot.android-library --> android-config
+end
+
+subgraph infrastructure-detekt
+ com.redmadrobot.detekt
+end
+
+subgraph infrastructure-kotlin
+ kotlin-config[com.redmadrobot.kotlin-config]
+ com.redmadrobot.kotlin-library --> kotlin-config
+end
+
+subgraph infrastructure-publish
+ publish-config[com.redmadrobot.publish-config]
+ com.redmadrobot.publish --> publish-config
+end
+
+android-config --> kotlin-config
+```
### kotlin-library
Common configurations for pure Kotlin libraries.
- Applies plugin `kotlin`
-- Specifies `jvmTarget` 11
-- Adds repository `mavenCentral` (see [Automatically added repositories](#automatically-added-repositories))
- Enables [explicit API mode][explicit-api]
### publish
@@ -206,7 +228,6 @@ publishing.publications.getByName(PUBLICATION_NAME) {
### detekt
-- Adds repository `mavenCentral` (see [Automatically added repositories](#automatically-added-repositories))
- Applies `detekt` plugin with `detekt-formatting`
- Configures additional tasks:
- `detektAll` - Runs Detekt over the whole codebase
@@ -224,25 +245,24 @@ publishing.publications.getByName(PUBLICATION_NAME) {
Common configurations for Android libraries and application.
-Both:
-- Specifies `jvmTarget` and `compatibility` 11
+[Both][BaseAndroidPlugin]:
- Specifies default compile, min and target SDK
-- Disables `aidl`, `renderScript` and `shaders` [build-features]
-- Adds repositories `mavenCentral` and `google` (see [Automatically added repositories](#automatically-added-repositories))
+- Disables `shaders` [build-features] by default
- Applies [android-cache-fix-gradle-plugin](https://github.com/gradle/android-cache-fix-gradle-plugin)
+- Configures Android Lint with [defaults][lint-options]
+- [Filters tests][testTaskFilter] to be run on `test` task according to the config.
+ By default, keeps only tests for build type `release`.
-Library:
+[Library][AndroidLibraryPlugin]:
- Applies plugin `com.android.library`
- Adds all proguard files from `proguard` folder as `consumerProguardFiles`
-- Disables `buildConfig`, `androidResources` and `resValues` [build-features]
+- Disables `androidResources` and `resValues` [build-features] by default
- Enables [explicit API mode][explicit-api]
-Application:
+[Application][AndroidApplicationPlugin]:
- Applies plugin `com.android.application`
- Adds all proguard files from `proguard` folder
- Configures `debug`, `qa` and `release` build types
-- Adds `LOCK_ORIENTATION` and `CRASH_REPORTS_ENABLED` BuildConfig variables which `false` only for `debug` build type
-- Configures Android Lint [default options][lint-options]
#### QA build type name configuration
@@ -294,15 +314,71 @@ See [compatibility table](#compatibility) to check what versions are compatible
### Configuration
-You can configure the plugins with an extension named `redmadrobot`.
-Look for available properties with description in [RedmadrobotExtension].
+You can configure the plugins via the `redmadrobot` extension.
+Here are listed all available options, with their default values:
-The extension should be configured in root project.
```kotlin
-// root project build.gradle.kts
-
redmadrobot {
- configsDir = file("path/to/configs/")
+ /* Common options */
+ // Directory with configs for static analyzers and other tools.
+ configsDir = file("config/")
+
+ // Directory with reports of static analyzers and other tools.
+ reportsDir = file("build/reports/")
+
+ /* `kotlin-config` options */
+ test {
+ // Specifies that JUnit Platform (JUnit 5) should be used to execute tests.
+ useJunitPlatform()
+
+ // Specifies that JUnit 4 should be used to execute tests.
+ useJunit()
+ }
+
+ /* `android-config` options */
+ android {
+ // minSdk to be used in all android modules.
+ minSdk = 23
+
+ // targetSdk to be used in all android modules.
+ targetSdk = 34
+
+ // compileSdk to be used in all android modules
+ compileSdk = "34"
+
+ // Build Tools version to be used in all android modules.
+ buildToolsVersion = System.getenv("ANDROID_BUILD_TOOLS_VERSION")
+
+ // NDK version to be used in all android modules.
+ ndkVersion = System.getenv("ANDROID_NDK_VERSION")
+
+ // Filter for test tasks that should be run on ':test'.
+ testTasksFilter = { taskProvider -> taskProvider.name.endsWith("ReleaseUnitTest") }
+
+ // Overrides of test configuration for android projects
+ test { /* ... */ }
+ }
+
+ /* `detekt` options */
+ detekt {
+ // Enable Detekt checks only for modified files
+ // (Disabled by default)
+ checkOnlyDiffWithBranch(branch = "main") {
+ fileExtensions = setOf(".kt", ".kts")
+ }
+ }
+
+ /* `publish-config` options */
+ publishing {
+ // Enables artifacts signing before publication.
+ signArtifacts = false
+
+ // Use gpg-agent to sign artifacts. Has effect only if signArtifacts is `true`.
+ useGpgAgent = true
+
+ // Configures POM file for this project and its subprojects.
+ pom { /* ... */ }
+ }
}
```
@@ -343,18 +419,19 @@ You can change it by defining the `warningsAsErrors` project property.
[Read more about Gradle project properties][project-properties]
-### Share sources between build types
+### Share sources between build variants
+
+You can share sources between two build variants.
+For example, you need to use debug panel in both "debug" and "QA" builds, and don't want to duplicate code for each of these build types.
+You can do it in one line with [addSharedSourceSetRoot] extension-function:
-You can share sources between two build types.
-For example, you need to use debug panel in both debug and QA builds, and don't want to write similar duplicating code for each of these build types.
-You can do it with one line with [addSharedSourceSetRoot] extension-function:
```kotlin
android {
// We need to share sources between debug and QA builds
- addSharedSourceSetRoot(BUILD_TYPE_DEBUG, BUILD_TYPE_QA)
+ sourceSet.addSharedSourceSetRoot(BUILD_TYPE_DEBUG, BUILD_TYPE_QA)
- // We can specify name for the source set root if need
- addSharedSourceSetRoot(BUILD_TYPE_DEBUG, BUILD_TYPE_QA, name = "debugPanel")
+ // We can specify a name for the source set root if needed
+ sourceSet.addSharedSourceSetRoot(BUILD_TYPE_DEBUG, BUILD_TYPE_QA, name = "debugPanel")
}
```
@@ -424,16 +501,20 @@ redmadrobot {
### Automatically added repositories
-Infrastructure plugins automatically add repositories required to make project work:
+> [!WARNING]
+> This feature is deprecated and is disabled by default since v0.19
+> Currently you can enable this behavior, though this option may be deleted at some point.
+
+Infrastructure plugins can automatically add required repositories:
- **kotlin** plugin adds `mavenCentral` repo
- **detekt** plugin adds `mavenCentral` repo
- **android** plugins add `mavenCentral` and `google` repos
-In the case you don't want these repositories to be added automatically, you can disable this behavior via flag in `gradle.properties`:
+This feature should be enabled by flag in `gradle.properties`:
```properties
-redmadrobot.add.repositories=false
+redmadrobot.add.repositories=true
```
## Samples
@@ -497,7 +578,7 @@ Execution failed for task ':app:stripDebugDebugSymbols'.
It is because NDK version on CI differs from a requested version.
You can change requested version by setting `android.ndkVersion`.
-Plugins `com.redmadrobot.android-library` and `com.redmadrobot.application` by default apply NDK version from env variable `ANDROID_NDK_VERSION` if it set.
+Plugins `com.redmadrobot.android-library` and `com.redmadrobot.application` by default apply NDK version from env variable `ANDROID_NDK_VERSION` if it is set.
### `Could not resolve` or `Could not find` dependencies
@@ -537,11 +618,14 @@ For major changes, please open an issue first to discuss what you would like to
[MIT][license]
[samples]: samples/
-[RedmadrobotExtension]: infrastructure/src/main/kotlin/extension/RedmadrobotExtension.kt
[MavenPom]: infrastructure/src/main/kotlin/dsl/MavenPom.kt
[predicates]: infrastructure/src/main/kotlin/dsl/PublishingPredicates.kt
[addSharedSourceSetRoot]: infrastructure-android/src/main/kotlin/dsl/SourceSets.kt
-[lint-options]: https://github.com/RedMadRobot/gradle-infrastructure/blob/2e96c04cbb9d15ca508d1d4b4a8b1e2da4bab6af/infrastructure/src/main/kotlin/AndroidApplicationPlugin.kt#L63-L72
+[lint-options]: infrastructure-android/src/main/kotlin/android/BaseAndroidPlugin.kt#L76-L80
+[testTaskFilter]: infrastructure-android/src/main/kotlin/android/AndroidOptions.kt#L28-L35
+[BaseAndroidPlugin]: infrastructure-android/src/main/kotlin/android/BaseAndroidPlugin.kt
+[AndroidLibraryPlugin]: infrastructure-android/src/main/kotlin/android/AndroidLibraryPlugin.kt
+[AndroidApplicationPlugin]: infrastructure-android/src/main/kotlin/android/AndroidApplicationPlugin.kt
[infrastructure]: #
[itemsadapter]: https://github.com/RedMadRobot/itemsadapter
diff --git a/build.gradle.kts b/build.gradle.kts
index 23a62af..84e9439 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,7 +1,4 @@
-import com.redmadrobot.build.dsl.developer
-import com.redmadrobot.build.dsl.isRunningOnCi
-import com.redmadrobot.build.dsl.mit
-import com.redmadrobot.build.dsl.setGitHubProject
+import com.redmadrobot.build.dsl.*
plugins {
id("com.redmadrobot.detekt")
diff --git a/infrastructure-android/src/main/kotlin/android/AndroidApplicationPlugin.kt b/infrastructure-android/src/main/kotlin/android/AndroidApplicationPlugin.kt
index cb958e2..721481d 100644
--- a/infrastructure-android/src/main/kotlin/android/AndroidApplicationPlugin.kt
+++ b/infrastructure-android/src/main/kotlin/android/AndroidApplicationPlugin.kt
@@ -11,11 +11,7 @@ import com.redmadrobot.build.android.internal.android
import com.redmadrobot.build.android.internal.androidComponents
import com.redmadrobot.build.android.internal.projectProguardFiles
import com.redmadrobot.build.android.task.MakeDebuggableTask
-import com.redmadrobot.build.dsl.BUILD_TYPE_DEBUG
-import com.redmadrobot.build.dsl.BUILD_TYPE_QA
-import com.redmadrobot.build.dsl.BUILD_TYPE_RELEASE
-import com.redmadrobot.build.dsl.finalizeQaBuildType
-import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
+import com.redmadrobot.build.dsl.*
import org.gradle.api.Project
import org.gradle.api.tasks.TaskContainer
import org.gradle.kotlin.dsl.register
@@ -26,12 +22,9 @@ import org.gradle.kotlin.dsl.register
*
* Tied to `com.redmadrobot.application` plugin ID.
*/
-public class AndroidApplicationPlugin : BaseAndroidPlugin() {
-
- @InternalGradleInfrastructureApi
- override fun Project.configure() {
- applyBaseAndroidPlugin("com.android.application")
+public class AndroidApplicationPlugin : BaseAndroidPlugin("com.android.application") {
+ override fun Project.configure(configPlugin: AndroidConfigPlugin) {
configureApp()
androidComponents {
onVariants(selector().withBuildType(BUILD_TYPE_QA)) { it.makeDebuggable(tasks) }
@@ -44,9 +37,6 @@ private fun Project.configureApp() = android {
defaultConfig {
// Collect proguard rules from 'proguard' dir
setProguardFiles(projectProguardFiles() + getDefaultProguardFile("proguard-android-optimize.txt"))
-
- buildConfigField("boolean", VAR_LOCK_ORIENTATION, "true")
- buildConfigField("boolean", VAR_CRASH_REPORTS_ENABLED, "true")
}
finalizeQaBuildType()
@@ -56,9 +46,6 @@ private fun Project.configureApp() = android {
isDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
-
- buildConfigField("boolean", VAR_LOCK_ORIENTATION, "false")
- buildConfigField("boolean", VAR_CRASH_REPORTS_ENABLED, "false")
}
release {
@@ -73,10 +60,6 @@ private fun Project.configureApp() = android {
applicationIdSuffix = ".$BUILD_TYPE_QA"
matchingFallbacks += listOf(BUILD_TYPE_DEBUG, BUILD_TYPE_RELEASE)
signingConfig = signingConfigs.findByName(BUILD_TYPE_DEBUG)
-
- // We can not use isDebuggable = true here, so set DEBUG field ourselves.
- // See `makeDebuggable` for more information
- buildConfigField(type = "boolean", name = "DEBUG", value = "true")
}
}
}
@@ -108,9 +91,14 @@ private fun ApplicationExtension.finalizeApp(
xmlOutput = staticAnalyzerSpec.reportsDir.file("lint-results.xml").get().asFile
htmlOutput = staticAnalyzerSpec.reportsDir.file("lint-results.html").get().asFile
}
-}
-// Constants
-
-private const val VAR_LOCK_ORIENTATION = "LOCK_ORIENTATION"
-private const val VAR_CRASH_REPORTS_ENABLED = "CRASH_REPORTS_ENABLED"
+ buildTypes {
+ if (buildFeatures.buildConfig == true) {
+ qa {
+ // We can not use isDebuggable = true here, so set DEBUG field ourselves.
+ // See `makeDebuggable` for more information
+ buildConfigField(type = "boolean", name = "DEBUG", value = "true")
+ }
+ }
+ }
+}
diff --git a/infrastructure-android/src/main/kotlin/android/AndroidConfigPlugin.kt b/infrastructure-android/src/main/kotlin/android/AndroidConfigPlugin.kt
index 73670da..ee5dc91 100644
--- a/infrastructure-android/src/main/kotlin/android/AndroidConfigPlugin.kt
+++ b/infrastructure-android/src/main/kotlin/android/AndroidConfigPlugin.kt
@@ -5,10 +5,8 @@ import com.redmadrobot.build.StaticAnalyzerSpec
import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.internal.hasPlugin
import com.redmadrobot.build.kotlin.KotlinConfigPlugin
-import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.internal.plugins.PluginRegistry
-import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.apply
import javax.inject.Inject
@@ -25,9 +23,6 @@ public open class AndroidConfigPlugin @Inject constructor(
internal lateinit var androidOptions: AndroidOptionsImpl
private set
- internal val jvmTarget: Provider
- get() = redmadrobotExtension.jvmTarget
-
internal val staticAnalyzerSpec: StaticAnalyzerSpec
get() = redmadrobotExtension
diff --git a/infrastructure-android/src/main/kotlin/android/AndroidLibraryPlugin.kt b/infrastructure-android/src/main/kotlin/android/AndroidLibraryPlugin.kt
index f720df5..de8592e 100644
--- a/infrastructure-android/src/main/kotlin/android/AndroidLibraryPlugin.kt
+++ b/infrastructure-android/src/main/kotlin/android/AndroidLibraryPlugin.kt
@@ -5,9 +5,8 @@ package com.redmadrobot.build.android
import com.android.build.api.dsl.LibraryExtension
import com.redmadrobot.build.android.internal.android
import com.redmadrobot.build.android.internal.projectProguardFiles
-import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
-import com.redmadrobot.build.kotlin.internal.kotlin
import org.gradle.api.Project
+import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
/**
* Plugin that applies default configurations for Android library project.
@@ -15,12 +14,9 @@ import org.gradle.api.Project
*
* Tied to `com.redmadrobot.android-library` plugin ID.
*/
-public class AndroidLibraryPlugin : BaseAndroidPlugin() {
-
- @InternalGradleInfrastructureApi
- override fun Project.configure() {
- applyBaseAndroidPlugin("com.android.library")
+public class AndroidLibraryPlugin : BaseAndroidPlugin("com.android.library") {
+ override fun Project.configure(configPlugin: AndroidConfigPlugin) {
android {
defaultConfig {
// Add all files from 'proguard' dir
@@ -28,13 +24,12 @@ public class AndroidLibraryPlugin : BaseAndroidPlugin() {
}
buildFeatures {
- buildConfig = false
resValues = false
androidResources = false
}
}
// Enable Explicit API mode for libraries by default
- kotlin.explicitApi()
+ kotlinExtension.explicitApi()
}
}
diff --git a/infrastructure-android/src/main/kotlin/android/AndroidOptions.kt b/infrastructure-android/src/main/kotlin/android/AndroidOptions.kt
index 9aadc38..8869869 100644
--- a/infrastructure-android/src/main/kotlin/android/AndroidOptions.kt
+++ b/infrastructure-android/src/main/kotlin/android/AndroidOptions.kt
@@ -6,25 +6,39 @@ 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
- /** 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
/**
- * 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
/**
- * 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
+ /**
+ * NDK to be used in all android modules.
+ * By default, uses the version from the environment variable `ANDROID_NDK_VERSION` if it is set.
+ */
+ public val ndkVersion: Property
+
/**
* Filters test tasks that should be run on ':test'.
* It is useful if you don't want to run tests for all build variants when run 'test' task.
diff --git a/infrastructure-android/src/main/kotlin/android/AndroidOptionsImpl.kt b/infrastructure-android/src/main/kotlin/android/AndroidOptionsImpl.kt
index 06eec9b..a57dd4c 100644
--- a/infrastructure-android/src/main/kotlin/android/AndroidOptionsImpl.kt
+++ b/infrastructure-android/src/main/kotlin/android/AndroidOptionsImpl.kt
@@ -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 {
+internal abstract class AndroidOptionsImpl @Inject constructor(
+ providers: ProviderFactory,
+) : AndroidOptions, WithDefaults {
private val testOptions: TestOptionsImpl
private var areTestDefaultsSet = false
@@ -25,6 +29,10 @@ internal abstract class AndroidOptionsImpl : AndroidOptions, WithDefaults taskProvider.name.endsWith("ReleaseUnitTest") }
@@ -43,6 +51,7 @@ internal abstract class AndroidOptionsImpl : AndroidOptions, WithDefaults {
+
+ override fun apply(target: Project) {
+ with(target) {
+ val configPlugin = plugins.apply(AndroidConfigPlugin::class)
+ applyBaseAndroidPlugin(androidPluginId, configPlugin)
+ configure(configPlugin)
+ }
+ }
- @InternalGradleInfrastructureApi
- protected val configPlugin: AndroidConfigPlugin
- get() = project.plugins.getPlugin(AndroidConfigPlugin::class)
+ internal abstract fun Project.configure(configPlugin: AndroidConfigPlugin)
- /** Should be called from [configure] in implementation. */
- @InternalGradleInfrastructureApi
- protected fun Project.applyBaseAndroidPlugin(pluginId: String) {
- val configPlugin = plugins.apply(AndroidConfigPlugin::class)
+ @OptIn(InternalGradleInfrastructureApi::class)
+ private fun Project.applyBaseAndroidPlugin(pluginId: String, configPlugin: AndroidConfigPlugin) {
apply {
plugin(pluginId)
plugin("kotlin-android")
@@ -41,13 +43,12 @@ public abstract class BaseAndroidPlugin internal constructor() : InfrastructureP
plugin("org.gradle.android.cache-fix")
}
- configureKotlin(configPlugin.jvmTarget)
+ configureKotlin()
configureAndroid()
androidComponents {
finalizeDsl { extension ->
extension.applyAndroidOptions(
options = configPlugin.androidOptions,
- jvmTarget = configPlugin.jvmTarget,
staticAnalyzerSpec = configPlugin.staticAnalyzerSpec,
)
filterTestTaskDependencies(configPlugin.androidOptions)
@@ -59,13 +60,7 @@ public abstract class BaseAndroidPlugin internal constructor() : InfrastructureP
}
private fun Project.configureAndroid() = android {
- // Set NDK version from env variable if exists
- val requestedNdkVersion = System.getenv("ANDROID_NDK_VERSION")
- if (requestedNdkVersion != null) ndkVersion = requestedNdkVersion
-
buildFeatures {
- aidl = false
- renderScript = false
shaders = false
}
@@ -79,21 +74,16 @@ private fun Project.configureAndroid() = android {
@OptIn(InternalGradleInfrastructureApi::class)
private fun CommonExtension.applyAndroidOptions(
options: AndroidOptions,
- jvmTarget: Provider,
staticAnalyzerSpec: StaticAnalyzerSpec,
) {
setCompileSdkVersion(options.compileSdk.get())
options.buildToolsVersion.ifPresent { buildToolsVersion = it }
+ options.ndkVersion.ifPresent { ndkVersion = it }
defaultConfig {
minSdk = options.minSdk.get()
}
- compileOptions {
- sourceCompatibility = jvmTarget.get()
- targetCompatibility = jvmTarget.get()
- }
-
testOptions {
unitTests.all { it.setTestOptions(options.test) }
}
diff --git a/infrastructure-common/src/main/kotlin/RedmadrobotExtension.kt b/infrastructure-common/src/main/kotlin/RedmadrobotExtension.kt
index dc9fe0b..bdaabef 100644
--- a/infrastructure-common/src/main/kotlin/RedmadrobotExtension.kt
+++ b/infrastructure-common/src/main/kotlin/RedmadrobotExtension.kt
@@ -8,8 +8,12 @@ public interface RedmadrobotExtension : StaticAnalyzerSpec {
/**
* JVM version to be used as a target by Kotlin and Java compilers.
- * By default, used Java 11.
+ * Use [JVM Toolchains](https://kotl.in/gradle/jvm/toolchain) instead.
*/
+ @Deprecated(
+ "Use JVM Toolchains instead. See https://kotl.in/gradle/jvm/toolchain",
+ level = DeprecationLevel.ERROR
+ )
public val jvmTarget: Property
public companion object {
diff --git a/infrastructure-common/src/main/kotlin/RedmadrobotExtensionImpl.kt b/infrastructure-common/src/main/kotlin/RedmadrobotExtensionImpl.kt
index 82ce64c..2323b94 100644
--- a/infrastructure-common/src/main/kotlin/RedmadrobotExtensionImpl.kt
+++ b/infrastructure-common/src/main/kotlin/RedmadrobotExtensionImpl.kt
@@ -1,7 +1,6 @@
package com.redmadrobot.build
import com.redmadrobot.build.internal.findByName
-import org.gradle.api.JavaVersion
import org.gradle.api.file.ProjectLayout
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.plugins.ExtensionContainer
@@ -13,9 +12,6 @@ internal abstract class RedmadrobotExtensionImpl @Inject constructor(
) : RedmadrobotExtension, ExtensionAware, WithDefaults {
init {
- jvmTarget
- .convention(JavaVersion.VERSION_11)
- .finalizeValueOnRead()
configsDir
.convention(layout.projectDirectory.dir(StaticAnalyzerSpec.DEFAULT_CONFIGS_DIR))
.finalizeValueOnRead()
@@ -25,7 +21,6 @@ internal abstract class RedmadrobotExtensionImpl @Inject constructor(
}
override fun setDefaults(defaults: RedmadrobotExtensionImpl) {
- jvmTarget.convention(defaults.jvmTarget)
configsDir.convention(defaults.configsDir)
reportsDir.convention(defaults.reportsDir)
}
diff --git a/infrastructure-common/src/main/kotlin/StaticAnalyzerSpec.kt b/infrastructure-common/src/main/kotlin/StaticAnalyzerSpec.kt
index ce9766d..cdc9fb7 100644
--- a/infrastructure-common/src/main/kotlin/StaticAnalyzerSpec.kt
+++ b/infrastructure-common/src/main/kotlin/StaticAnalyzerSpec.kt
@@ -5,10 +5,10 @@ import org.gradle.api.file.DirectoryProperty
/** Options used for static analyzers' configurations. */
public interface StaticAnalyzerSpec {
- /** Directory where stored configs for static analyzers. */
+ /** Directory with configs for static analyzers and other tools. */
public val configsDir: DirectoryProperty
- /** Directory where will be stored static analyzers reports. */
+ /** Directory with reports of static analyzers and other tools. */
public val reportsDir: DirectoryProperty
public companion object {
diff --git a/infrastructure-common/src/main/kotlin/internal/ProjectOptions.kt b/infrastructure-common/src/main/kotlin/internal/ProjectOptions.kt
index 29c079c..8669c41 100644
--- a/infrastructure-common/src/main/kotlin/internal/ProjectOptions.kt
+++ b/infrastructure-common/src/main/kotlin/internal/ProjectOptions.kt
@@ -6,6 +6,6 @@ import org.gradle.kotlin.dsl.repositories
@InternalGradleInfrastructureApi
public fun Project.addRepositoriesIfNeed(block: RepositoryHandler.() -> Unit) {
- val addRepositories = findBooleanProperty("redmadrobot.add.repositories") != false
+ val addRepositories = findBooleanProperty("redmadrobot.add.repositories") == true
if (addRepositories) repositories(block)
}
diff --git a/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinConfigPlugin.kt b/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinConfigPlugin.kt
index aaac4cc..3fbfb23 100644
--- a/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinConfigPlugin.kt
+++ b/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinConfigPlugin.kt
@@ -3,10 +3,8 @@ package com.redmadrobot.build.kotlin
import com.redmadrobot.build.InfrastructurePlugin
import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.internal.hasPlugin
-import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.internal.plugins.PluginRegistry
-import org.gradle.api.provider.Provider
import javax.inject.Inject
/**
@@ -23,9 +21,6 @@ public open class KotlinConfigPlugin @Inject constructor(
public lateinit var testOptions: TestOptionsImpl
private set
- internal val jvmTarget: Provider
- get() = redmadrobotExtension.jvmTarget
-
@InternalGradleInfrastructureApi
override fun Project.configure() {
check(pluginRegistry.hasPlugin("kotlin")) {
diff --git a/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinLibraryPlugin.kt b/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinLibraryPlugin.kt
index cc06512..db7db84 100644
--- a/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinLibraryPlugin.kt
+++ b/infrastructure-kotlin/src/main/kotlin/kotlin/KotlinLibraryPlugin.kt
@@ -1,16 +1,15 @@
package com.redmadrobot.build.kotlin
-import com.redmadrobot.build.InfrastructurePlugin
import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.internal.addRepositoriesIfNeed
import com.redmadrobot.build.kotlin.internal.configureKotlin
-import com.redmadrobot.build.kotlin.internal.java
-import com.redmadrobot.build.kotlin.internal.kotlin
import com.redmadrobot.build.kotlin.internal.setTestOptions
+import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.withType
+import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
/**
* Plugin that applies default configurations for Kotlin library project.
@@ -18,26 +17,23 @@ import org.gradle.kotlin.dsl.withType
*
* Tied to `com.redmadrobot.kotlin-library` plugin ID.
*/
-public class KotlinLibraryPlugin : InfrastructurePlugin() {
+public class KotlinLibraryPlugin : Plugin {
- @InternalGradleInfrastructureApi
- override fun Project.configure() {
+ override fun apply(target: Project) {
+ target.configure()
+ }
+
+ @OptIn(InternalGradleInfrastructureApi::class)
+ private fun Project.configure() {
apply(plugin = "kotlin")
val configPlugin = plugins.apply(KotlinConfigPlugin::class)
// Enable Explicit API mode for libraries by default
- kotlin.explicitApi()
+ kotlinExtension.explicitApi()
- configureKotlin(configPlugin.jvmTarget)
+ configureKotlin()
configureKotlinTest(configPlugin.testOptions)
configureRepositories()
-
- afterEvaluate {
- java {
- targetCompatibility = configPlugin.jvmTarget.get()
- sourceCompatibility = configPlugin.jvmTarget.get()
- }
- }
}
}
diff --git a/infrastructure-kotlin/src/main/kotlin/kotlin/TestOptions.kt b/infrastructure-kotlin/src/main/kotlin/kotlin/TestOptions.kt
index d20ae5a..733d090 100644
--- a/infrastructure-kotlin/src/main/kotlin/kotlin/TestOptions.kt
+++ b/infrastructure-kotlin/src/main/kotlin/kotlin/TestOptions.kt
@@ -7,12 +7,15 @@ import org.gradle.api.tasks.testing.junitplatform.JUnitPlatformOptions
/** Options used to configure tests. */
public interface TestOptions {
- /** Flag for using Junit Jupiter Platform. Use functions [useJunit] or [useJunitPlatform]. */
+ /**
+ * Flag for using Junit Jupiter Platform.
+ * Use functions [useJunitPlatform] and [useJunit] to change it.
+ */
public val useJunitPlatform: Provider
- /** Specifies that JUnit Platform (JUnit 5) should be used to execute the tests. */
+ /** Specifies that JUnit Platform (JUnit 5) should be used to execute tests. */
public fun useJunitPlatform(configure: JUnitPlatformOptions.() -> Unit = {})
- /** Specifies that JUnit should be used to execute the tests. */
+ /** Specifies that JUnit 4 should be used to execute tests. */
public fun useJunit(configure: JUnitOptions.() -> Unit = {})
}
diff --git a/infrastructure-kotlin/src/main/kotlin/kotlin/internal/Kotlin.kt b/infrastructure-kotlin/src/main/kotlin/kotlin/internal/Kotlin.kt
index 056c2a7..92f4a63 100644
--- a/infrastructure-kotlin/src/main/kotlin/kotlin/internal/Kotlin.kt
+++ b/infrastructure-kotlin/src/main/kotlin/kotlin/internal/Kotlin.kt
@@ -1,21 +1,16 @@
package com.redmadrobot.build.kotlin.internal
-import com.redmadrobot.build.InfrastructurePlugin
import com.redmadrobot.build.dsl.isRunningOnCi
import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.internal.findBooleanProperty
-import org.gradle.api.JavaVersion
import org.gradle.api.Project
-import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.*
-import org.jetbrains.kotlin.gradle.dsl.JvmTarget
@InternalGradleInfrastructureApi
-public fun InfrastructurePlugin.configureKotlin(jvmTargetProperty: Provider) {
- val warningsAsErrors = project.getWarningsAsErrorsProperty()
- project.kotlinCompile {
+public fun Project.configureKotlin() {
+ val warningsAsErrors = getWarningsAsErrorsProperty()
+ kotlinCompile {
compilerOptions {
- jvmTarget = JvmTarget.fromTarget(jvmTargetProperty.get().toString())
allWarningsAsErrors = warningsAsErrors
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
diff --git a/infrastructure-kotlin/src/main/kotlin/kotlin/internal/KotlinAccessors.kt b/infrastructure-kotlin/src/main/kotlin/kotlin/internal/KotlinAccessors.kt
index 7512416..f8df7fe 100644
--- a/infrastructure-kotlin/src/main/kotlin/kotlin/internal/KotlinAccessors.kt
+++ b/infrastructure-kotlin/src/main/kotlin/kotlin/internal/KotlinAccessors.kt
@@ -1,23 +1,14 @@
package com.redmadrobot.build.kotlin.internal
-import com.redmadrobot.build.InfrastructurePlugin
-import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
-import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.withType
-import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
internal fun Project.java(configure: JavaPluginExtension.() -> Unit) {
extensions.configure("java", configure)
}
-@InternalGradleInfrastructureApi
-public val InfrastructurePlugin.kotlin: KotlinProjectExtension get() = project.kotlin
-
-internal val Project.kotlin: KotlinProjectExtension get() = extensions.getByName("kotlin")
-
internal inline fun Project.kotlinCompile(crossinline configure: KotlinJvmCompile.() -> Unit) {
tasks.withType().configureEach { configure() }
}
diff --git a/infrastructure-publish/src/main/kotlin/publish/PublishPlugin.kt b/infrastructure-publish/src/main/kotlin/publish/PublishPlugin.kt
index dccd60e..c9628fa 100644
--- a/infrastructure-publish/src/main/kotlin/publish/PublishPlugin.kt
+++ b/infrastructure-publish/src/main/kotlin/publish/PublishPlugin.kt
@@ -1,13 +1,12 @@
package com.redmadrobot.build.publish
import com.android.build.api.dsl.LibraryExtension
-import com.redmadrobot.build.InfrastructurePlugin
import com.redmadrobot.build.dsl.isReleaseVersion
-import com.redmadrobot.build.internal.InternalGradleInfrastructureApi
import com.redmadrobot.build.publish.internal.isPluginAutomatedPublishing
import com.redmadrobot.build.publish.internal.java
import com.redmadrobot.build.publish.internal.publishing
import com.redmadrobot.build.publish.internal.signing
+import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.*
@@ -18,10 +17,13 @@ import org.gradle.plugins.signing.Sign
*
* Tied to `com.redmadrobot.publish` plugin ID.
*/
-public open class PublishPlugin : InfrastructurePlugin() {
+public open class PublishPlugin : Plugin {
- @InternalGradleInfrastructureApi
- override fun Project.configure() {
+ override fun apply(target: Project) {
+ target.configure()
+ }
+
+ private fun Project.configure() {
apply(plugin = "maven-publish")
val configPlugin = plugins.apply(PublishConfigPlugin::class)
diff --git a/samples/android-application-multi/app/build.gradle.kts b/samples/android-application-multi/app/build.gradle.kts
index 13b8fd5..db4d75e 100644
--- a/samples/android-application-multi/app/build.gradle.kts
+++ b/samples/android-application-multi/app/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
id("com.redmadrobot.application")
+ convention.jvm
}
// Plugin "com.redmadrobot.application" configures build types, SDK versions, proguard and so on.
@@ -15,11 +16,6 @@ android {
// For example, specify instrumentation tests runner.
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
-
- // TODO: Remove after removal of implicitly added BuildConfig fields
- buildFeatures {
- buildConfig = true
- }
}
dependencies {
diff --git a/samples/android-application-multi/build.gradle.kts b/samples/android-application-multi/build.gradle.kts
index 161ac04..c665efb 100644
--- a/samples/android-application-multi/build.gradle.kts
+++ b/samples/android-application-multi/build.gradle.kts
@@ -1,8 +1,5 @@
plugins {
- // Specify needed versions of AGP and KGP
- id("com.android.application") version "8.5.0" apply false
- kotlin("android") version "2.0.0" apply false
-
+ // Versions of AGP and KGP are specified in buildSrc module
id("com.redmadrobot.android-config") version "0.19-SNAPSHOT"
}
diff --git a/samples/android-application-multi/buildSrc/build.gradle.kts b/samples/android-application-multi/buildSrc/build.gradle.kts
new file mode 100644
index 0000000..c74557d
--- /dev/null
+++ b/samples/android-application-multi/buildSrc/build.gradle.kts
@@ -0,0 +1,8 @@
+plugins {
+ `kotlin-dsl`
+}
+
+dependencies {
+ implementation(kotlin("gradle-plugin", version = "2.0.0"))
+ implementation("com.android.tools.build:gradle:8.5.0")
+}
diff --git a/samples/android-application-multi/buildSrc/settings.gradle.kts b/samples/android-application-multi/buildSrc/settings.gradle.kts
new file mode 100644
index 0000000..e1e9b53
--- /dev/null
+++ b/samples/android-application-multi/buildSrc/settings.gradle.kts
@@ -0,0 +1,18 @@
+@file:Suppress("UnstableApiUsage")
+
+dependencyResolutionManagement {
+ repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
+
+ repositories {
+ mavenCentral()
+ google {
+ content {
+ includeGroupAndSubgroups("com.android")
+ includeGroupAndSubgroups("com.google")
+ includeGroupAndSubgroups("androidx")
+ }
+ }
+ }
+}
+
+rootProject.name = "buildSrc"
diff --git a/samples/android-application-multi/buildSrc/src/main/kotlin/convention.jvm.gradle.kts b/samples/android-application-multi/buildSrc/src/main/kotlin/convention.jvm.gradle.kts
new file mode 100644
index 0000000..95cc1e3
--- /dev/null
+++ b/samples/android-application-multi/buildSrc/src/main/kotlin/convention.jvm.gradle.kts
@@ -0,0 +1,4 @@
+import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
+
+// Align JVM target across all modules
+kotlinExtension.jvmToolchain(17)
diff --git a/samples/android-application-multi/module1/build.gradle.kts b/samples/android-application-multi/module1/build.gradle.kts
index edc112e..19162ee 100644
--- a/samples/android-application-multi/module1/build.gradle.kts
+++ b/samples/android-application-multi/module1/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
id("com.redmadrobot.android-library")
+ convention.jvm
}
android {
diff --git a/samples/android-application-multi/module2/build.gradle.kts b/samples/android-application-multi/module2/build.gradle.kts
index 92cfa63..92c8b08 100644
--- a/samples/android-application-multi/module2/build.gradle.kts
+++ b/samples/android-application-multi/module2/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
id("com.redmadrobot.android-library")
+ convention.jvm
}
// Explicit API is enabled by default, but we can disable it if needed
diff --git a/samples/android-application-multi/settings.gradle.kts b/samples/android-application-multi/settings.gradle.kts
index 9a3c7ee..b362da8 100644
--- a/samples/android-application-multi/settings.gradle.kts
+++ b/samples/android-application-multi/settings.gradle.kts
@@ -1,10 +1,34 @@
+@file:Suppress("UnstableApiUsage")
+
pluginManagement {
repositories {
// If we use SNAPSHOT version of infrastructure,
// we should publish it to mavenLocal first
mavenLocal()
gradlePluginPortal()
- google()
+ google {
+ content {
+ includeGroupAndSubgroups("com.android")
+ includeGroupAndSubgroups("com.google")
+ includeGroupAndSubgroups("androidx")
+ }
+ }
+ }
+}
+
+// Configure repositories for all subprojects in one place
+dependencyResolutionManagement {
+ repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
+
+ repositories {
+ google {
+ content {
+ includeGroupAndSubgroups("com.android")
+ includeGroupAndSubgroups("com.google")
+ includeGroupAndSubgroups("androidx")
+ }
+ }
+ mavenCentral()
}
}
diff --git a/samples/android-application/app/build.gradle.kts b/samples/android-application/app/build.gradle.kts
index c5c0e39..b64a153 100644
--- a/samples/android-application/app/build.gradle.kts
+++ b/samples/android-application/app/build.gradle.kts
@@ -1,6 +1,4 @@
-import com.redmadrobot.build.dsl.BUILD_TYPE_DEBUG
-import com.redmadrobot.build.dsl.BUILD_TYPE_QA
-import com.redmadrobot.build.dsl.addSharedSourceSetRoot
+import com.redmadrobot.build.dsl.*
plugins {
id("com.redmadrobot.application")
@@ -20,11 +18,6 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
- // TODO: Remove after removal of implicitly added BuildConfig fields
- buildFeatures {
- buildConfig = true
- }
-
// If we need to share sources between two build types,
// we can add shared source set root.
// In this case will be created directory "debugQa"
@@ -32,6 +25,10 @@ android {
sourceSets.addSharedSourceSetRoot(BUILD_TYPE_DEBUG, BUILD_TYPE_QA)
}
+kotlin {
+ jvmToolchain(17)
+}
+
dependencies {
// Align Kotlin version across all dependencies
implementation(platform(kotlin("bom", version = "2.0.0")))
diff --git a/samples/android-application/settings.gradle.kts b/samples/android-application/settings.gradle.kts
index b08db50..38c2078 100644
--- a/samples/android-application/settings.gradle.kts
+++ b/samples/android-application/settings.gradle.kts
@@ -1,10 +1,34 @@
+@file:Suppress("UnstableApiUsage")
+
pluginManagement {
repositories {
// If we use SNAPSHOT version of infrastructure,
// we should publish it to mavenLocal first
mavenLocal()
gradlePluginPortal()
- google()
+ google {
+ content {
+ includeGroupAndSubgroups("com.android")
+ includeGroupAndSubgroups("com.google")
+ includeGroupAndSubgroups("androidx")
+ }
+ }
+ }
+}
+
+// Configure repositories for all subprojects in one place
+dependencyResolutionManagement {
+ repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
+
+ repositories {
+ google {
+ content {
+ includeGroupAndSubgroups("com.android")
+ includeGroupAndSubgroups("com.google")
+ includeGroupAndSubgroups("androidx")
+ }
+ }
+ mavenCentral()
}
}