-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: AntsyLich <[email protected]>
- Loading branch information
Showing
19 changed files
with
218 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(androidx.gradle) | ||
implementation(kotlinx.gradle) | ||
implementation(kotlinx.compose.compiler.gradle) | ||
implementation(gradleApi()) | ||
|
||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) | ||
implementation(files(androidx.javaClass.superclass.protectionDomain.codeSource.location)) | ||
implementation(files(compose.javaClass.superclass.protectionDomain.codeSource.location)) | ||
implementation(files(kotlinx.javaClass.superclass.protectionDomain.codeSource.location)) | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
google() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
create("androidx") { | ||
from(files("../gradle/androidx.versions.toml")) | ||
} | ||
create("compose") { | ||
from(files("../gradle/compose.versions.toml")) | ||
} | ||
create("kotlinx") { | ||
from(files("../gradle/kotlinx.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "yokai-buildSrc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import org.gradle.api.JavaVersion as GradleJavaVersion | ||
|
||
object AndroidConfig { | ||
const val compileSdk = 35 | ||
const val minSdk = 23 | ||
const val targetSdk = 35 | ||
const val ndk = "27.2.12479018" | ||
const val COMPILE_SDK = 35 | ||
const val MIN_SDK = 23 | ||
const val TARGET_SDK = 35 | ||
const val NDK = "27.2.12479018" | ||
val JavaVersion = GradleJavaVersion.VERSION_17 | ||
} |
10 changes: 10 additions & 0 deletions
10
buildSrc/src/main/kotlin/yokai.android.application.compose.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import yokai.build.configureCompose | ||
|
||
plugins { | ||
id("com.android.application") | ||
kotlin("android") | ||
} | ||
|
||
android { | ||
configureCompose(this) | ||
} |
15 changes: 15 additions & 0 deletions
15
buildSrc/src/main/kotlin/yokai.android.application.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import yokai.build.configureAndroid | ||
import yokai.build.configureTest | ||
|
||
plugins { | ||
id("com.android.application") | ||
kotlin("android") | ||
} | ||
|
||
android { | ||
defaultConfig { | ||
targetSdk = AndroidConfig.TARGET_SDK | ||
} | ||
configureAndroid(this) | ||
configureTest() | ||
} |
9 changes: 9 additions & 0 deletions
9
buildSrc/src/main/kotlin/yokai.android.library.compose.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import yokai.build.configureCompose | ||
|
||
plugins { | ||
id("com.android.library") | ||
} | ||
|
||
android { | ||
configureCompose(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import yokai.build.configureAndroid | ||
import yokai.build.configureTest | ||
|
||
plugins { | ||
id("com.android.library") | ||
} | ||
|
||
android { | ||
configureAndroid(this) | ||
configureTest() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,98 @@ | ||
package yokai.build | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.accessors.dm.LibrariesForAndroidx | ||
import org.gradle.accessors.dm.LibrariesForCompose | ||
import org.gradle.accessors.dm.LibrariesForKotlinx | ||
import org.gradle.accessors.dm.LibrariesForLibs | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.testing.Test | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.provideDelegate | ||
import org.gradle.kotlin.dsl.the | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension | ||
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import java.io.File | ||
|
||
val Project.androidx get() = the<LibrariesForAndroidx>() | ||
val Project.compose get() = the<LibrariesForCompose>() | ||
val Project.kotlinx get() = the<LibrariesForKotlinx>() | ||
val Project.libs get() = the<LibrariesForLibs>() | ||
|
||
val Project.generatedBuildDir: File get() = project.layout.buildDirectory.asFile.get().resolve("generated/yokai") | ||
|
||
internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *, *, *, *>) { | ||
commonExtension.apply { | ||
compileSdk = AndroidConfig.COMPILE_SDK | ||
defaultConfig { | ||
minSdk = AndroidConfig.MIN_SDK | ||
ndk { | ||
version = AndroidConfig.NDK | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = AndroidConfig.JavaVersion | ||
targetCompatibility = AndroidConfig.JavaVersion | ||
isCoreLibraryDesugaringEnabled = true | ||
} | ||
} | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = AndroidConfig.JavaVersion.toString() | ||
// freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" | ||
// freeCompilerArgs += "-Xcontext-receivers" | ||
// Treat all Kotlin warnings as errors (disabled by default) | ||
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties | ||
// val warningsAsErrors: String? by project | ||
// allWarningsAsErrors = warningsAsErrors.toBoolean() | ||
} | ||
} | ||
dependencies { | ||
"coreLibraryDesugaring"(libs.desugar) | ||
} | ||
} | ||
|
||
internal fun Project.configureCompose(commonExtension: CommonExtension<*, *, *, *, *, *>) { | ||
pluginManager.apply(kotlinx.plugins.compose.compiler.get().pluginId) | ||
|
||
commonExtension.apply { | ||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
dependencies { | ||
"implementation"(platform(compose.bom)) | ||
} | ||
} | ||
|
||
extensions.configure<ComposeCompilerGradlePluginExtension> { | ||
featureFlags.set(setOf(ComposeFeatureFlag.OptimizeNonSkippingGroups)) | ||
|
||
val enableMetrics = project.providers.gradleProperty("enableComposeCompilerMetrics").orNull.toBoolean() | ||
val enableReports = project.providers.gradleProperty("enableComposeCompilerReports").orNull.toBoolean() | ||
|
||
val rootBuildDir = rootProject.layout.buildDirectory.asFile.get() | ||
val relativePath = projectDir.relativeTo(rootDir) | ||
|
||
if (enableMetrics) { | ||
rootBuildDir.resolve("compose-metrics").resolve(relativePath).let(metricsDestination::set) | ||
} | ||
|
||
if (enableReports) { | ||
rootBuildDir.resolve("compose-reports").resolve(relativePath).let(reportsDestination::set) | ||
} | ||
} | ||
} | ||
|
||
internal fun Project.configureTest() { | ||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
testLogging { | ||
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.