mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 03:17:03 +05:30
build: convert to Gradle Kotlin DSL
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
9839bf4014
commit
1e2fef884f
19 changed files with 514 additions and 230 deletions
98
buildSrc/src/main/java/BaseProjectConfig.kt
Normal file
98
buildSrc/src/main/java/BaseProjectConfig.kt
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
import com.android.build.gradle.TestedExtension
|
||||
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Delete
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
import org.gradle.api.tasks.wrapper.Wrapper
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
/**
|
||||
* Configure root project.
|
||||
* Note that classpath dependencies still need to be defined in the `buildscript` block in the top-level build.gradle.kts file.
|
||||
*/
|
||||
internal fun Project.configureForRootProject() {
|
||||
// register task for cleaning the build directory in the root project
|
||||
tasks.register("clean", Delete::class.java) {
|
||||
delete(rootProject.buildDir)
|
||||
}
|
||||
tasks.withType<Wrapper> {
|
||||
gradleVersion = "6.7"
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
distributionSha256Sum = "0080de8491f0918e4f529a6db6820fa0b9e818ee2386117f4394f95feb1d5583"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure all projects including the root project
|
||||
*/
|
||||
internal fun Project.configureForAllProjects() {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { setUrl("https://jitpack.io") }
|
||||
}
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
|
||||
languageVersion = "1.4"
|
||||
}
|
||||
}
|
||||
tasks.withType<Test> {
|
||||
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
|
||||
testLogging {
|
||||
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Apply configuration options for Android Application projects.
|
||||
*/
|
||||
@Suppress("UnstableApiUsage")
|
||||
internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project: Project) {
|
||||
project.tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = freeCompilerArgs + listOf(
|
||||
"-Xopt-in=kotlin.RequiresOptIn",
|
||||
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
|
||||
"-Xopt-in=androidx.compose.material.ExperimentalMaterialApi"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply baseline configurations for all Android projects (Application and Library).
|
||||
*/
|
||||
@Suppress("UnstableApiUsage")
|
||||
internal fun TestedExtension.configureCommonAndroidOptions() {
|
||||
compileSdkVersion(30)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(23)
|
||||
targetSdkVersion(30)
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude("**/*.version")
|
||||
exclude("**/*.txt")
|
||||
exclude("**/*.kotlin_module")
|
||||
exclude("**/plugin.properties")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
testOptions.animationsDisabled = true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue