Skip to content

Commit

Permalink
update build configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Dec 12, 2023
1 parent 2b37dfd commit 9f16fb8
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 10 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import nl.littlerobots.vcu.plugin.versionCatalogUpdate
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -9,15 +11,10 @@ plugins {
alias(libs.plugins.version.catalog.update)
alias(libs.plugins.dokka)
alias(libs.plugins.dependencyAnalysis)
}

buildscript {
dependencies {
classpath(libs.android.gradle)
classpath(libs.kotlin.gradle)
classpath(libs.version.gradle)
classpath(libs.detekt.gradle)
}
// plugins already on a classpath (conventions)
// alias(libs.plugins.androidApplication) apply false
// alias(libs.plugins.androidLibrary) apply false
// alias(libs.plugins.kotlinMultiplatform) apply false
}

allprojects {
Expand All @@ -27,7 +24,7 @@ allprojects {
compilerOptions {
jvmTarget.set(Config.jvmTarget)
languageVersion.set(Config.kotlinVersion)
freeCompilerArgs.addAll(Config.compilerArgs)
freeCompilerArgs.apply { addAll(Config.jvmCompilerArgs) }
optIn.addAll(Config.optIns.map { "-opt-in=$it" })
}
}
Expand Down Expand Up @@ -65,10 +62,8 @@ doctor {
}

dependencyAnalysis {
issues {
all {
ignoreKtx(true)
}
structure {
ignoreKtx(true)
}
}

Expand Down Expand Up @@ -124,7 +119,7 @@ tasks {
autoCorrect = false
}

withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask>().configureEach {
withType<DependencyUpdatesTask>().configureEach {
outputFormatter = "json"

fun stabilityLevel(version: String): Int {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ feature-rich.
addAll(compilerArgs)
add("-Xjvm-default=all") // enable all jvm optimizations
add("-Xcontext-receivers")
add("-Xstring-concat=inline")
addAll(optIns.map { "-opt-in=$it" })
}

val jvmTarget = JvmTarget.JVM_11
val javaVersion = JavaVersion.VERSION_11
val kotlinVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
const val compileSdk = 34
const val minSdk = 21
const val targetSdk = compileSdk
const val minSdk = 21
const val appMinSdk = 26
const val publishingVariant = "release"

Expand All @@ -67,7 +68,6 @@ feature-rich.
const val consumerProguardFile = "consumer-rules.pro"

val stabilityLevels = listOf("preview", "eap", "alpha", "beta", "m", "cr", "rc")

object Detekt {

const val configFile = "detekt.yml"
Expand Down
15 changes: 8 additions & 7 deletions buildSrc/src/main/kotlin/ConfigureAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ fun Project.configureAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
) = commonExtension.apply {
compileSdk = Config.compileSdk
val libs by versionCatalog

defaultConfig {
minSdk = Config.minSdk
testInstrumentationRunner = Config.testRunner
Expand Down Expand Up @@ -44,12 +46,11 @@ fun Project.configureAndroid(
}

packaging {
resources {
excludes += setOf(
"DebugProbesKt.bin",
"/META-INF/{AL2.0,LGPL2.1}",
)
}
resources.excludes += listOf(
"/META-INF/{AL2.0,LGPL2.1}",
"DebugProbesKt.bin",
"META-INF/versions/9/previous-compilation-data.bin"
)
}

testOptions {
Expand All @@ -65,7 +66,7 @@ fun Project.configureAndroid(
}
}
}
val libs by versionCatalog

composeOptions {
kotlinCompilerExtensionVersion = libs.requireVersion("compose-compiler")
useLiveLiterals = true
Expand Down
87 changes: 53 additions & 34 deletions buildSrc/src/main/kotlin/ConfigureMultiplatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,66 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

fun Project.configureMultiplatform(
ext: KotlinMultiplatformExtension,
jvm: Boolean = true,
android: Boolean = true,
linux: Boolean = true,
iOs: Boolean = true,
js: Boolean = true,
tvOs: Boolean = true,
macOs: Boolean = true,
watchOs: Boolean = true
) = ext.apply {
val libs by versionCatalog
explicitApi()

applyDefaultHierarchyTemplate()
withSourcesJar(true)

linuxX64()
linuxArm64()
mingwX64()

js(IR) {
browser()
nodejs()
binaries.library()
if (linux) {
linuxX64()
linuxArm64()
mingwX64()
}

androidTarget {
publishLibraryVariants("release")
if (js) {
js(IR) {
browser()
nodejs()
binaries.library()
}
}

jvm {
compilations.all {
kotlinOptions {
jvmTarget = Config.jvmTarget.target
freeCompilerArgs += Config.jvmCompilerArgs
}
if (android) {
androidTarget {
publishAllLibraryVariants()
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosArm64(),
macosX64(),
tvosX64(),
tvosArm64(),
tvosSimulatorArm64(),
watchosX64(),
watchosArm64(),
watchosDeviceArm64(),
watchosSimulatorArm64(),
).forEach {
if (jvm) {
jvm()
}

sequence {
if (iOs) {
yield(iosX64())
yield(iosArm64())
yield(iosSimulatorArm64())
}
if (macOs) {
yield(macosArm64())
yield(macosX64())
}
if (tvOs) {
yield(tvosX64())
yield(tvosArm64())
yield(tvosSimulatorArm64())
}
if (watchOs) {
yield(watchosX64())
yield(watchosArm64())
yield(watchosDeviceArm64())
yield(watchosSimulatorArm64())
}
}.forEach {
it.binaries.framework {
binaryOption("bundleId", Config.artifactId)
binaryOption("bundleVersion", Config.versionName)
Expand All @@ -58,9 +75,11 @@ fun Project.configureMultiplatform(
}

sourceSets.apply {
val jvmTest by getting {
dependencies {
implementation(libs.requireLib("kotest-junit"))
if (jvm) {
val jvmTest by getting {
dependencies {
implementation(libs.requireLib("kotest-junit"))
}
}
}
all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ android {
publishAndroid(this)

kotlinOptions {
freeCompilerArgs += Config.jvmCompilerArgs
jvmTarget = Config.jvmTarget.target
languageVersion = Config.kotlinVersion.version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import org.gradle.kotlin.dsl.kotlin
import org.gradle.kotlin.dsl.signing

plugins {
// id(libs.plugins.atomicfu.id)
kotlin("multiplatform")
id("com.android.library")
id("maven-publish")
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ android.disableResourceValidation=true
android.nonFinalResIds=true
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.native.ignoreIncorrectDependencies=true
# TODO: Set to true after https://github.com/Kotlin/kotlinx-atomicfu/issues/250
kotlinx.atomicfu.enableJvmIrTransformation=false
systemProp.org.gradle.unsafe.kotlin.assignment=true
22 changes: 14 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

buildscript {
repositories {
google()
gradlePluginPortal()
mavenCentral()
// TODO: https://github.com/Kotlin/kotlinx-atomicfu/issues/56
resolutionStrategy {
eachPlugin {
val module = when (requested.id.id) {
"kotlinx-atomicfu" -> "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}"
else -> null
}
if (module != null) {
useModule(module)
}
}
}
}

Expand Down

0 comments on commit 9f16fb8

Please sign in to comment.