Skip to content

Commit 9f16fb8

Browse files
committed
update build configuration
1 parent 2b37dfd commit 9f16fb8

10 files changed

+97
-71
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2+
import nl.littlerobots.vcu.plugin.versionCatalogUpdate
13
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
24
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
35
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -9,15 +11,10 @@ plugins {
911
alias(libs.plugins.version.catalog.update)
1012
alias(libs.plugins.dokka)
1113
alias(libs.plugins.dependencyAnalysis)
12-
}
13-
14-
buildscript {
15-
dependencies {
16-
classpath(libs.android.gradle)
17-
classpath(libs.kotlin.gradle)
18-
classpath(libs.version.gradle)
19-
classpath(libs.detekt.gradle)
20-
}
14+
// plugins already on a classpath (conventions)
15+
// alias(libs.plugins.androidApplication) apply false
16+
// alias(libs.plugins.androidLibrary) apply false
17+
// alias(libs.plugins.kotlinMultiplatform) apply false
2118
}
2219

2320
allprojects {
@@ -27,7 +24,7 @@ allprojects {
2724
compilerOptions {
2825
jvmTarget.set(Config.jvmTarget)
2926
languageVersion.set(Config.kotlinVersion)
30-
freeCompilerArgs.addAll(Config.compilerArgs)
27+
freeCompilerArgs.apply { addAll(Config.jvmCompilerArgs) }
3128
optIn.addAll(Config.optIns.map { "-opt-in=$it" })
3229
}
3330
}
@@ -65,10 +62,8 @@ doctor {
6562
}
6663

6764
dependencyAnalysis {
68-
issues {
69-
all {
70-
ignoreKtx(true)
71-
}
65+
structure {
66+
ignoreKtx(true)
7267
}
7368
}
7469

@@ -124,7 +119,7 @@ tasks {
124119
autoCorrect = false
125120
}
126121

127-
withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask>().configureEach {
122+
withType<DependencyUpdatesTask>().configureEach {
128123
outputFormatter = "json"
129124

130125
fun stabilityLevel(version: String): Int {

buildSrc/src/main/kotlin/Config.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ feature-rich.
4545
addAll(compilerArgs)
4646
add("-Xjvm-default=all") // enable all jvm optimizations
4747
add("-Xcontext-receivers")
48+
add("-Xstring-concat=inline")
4849
addAll(optIns.map { "-opt-in=$it" })
4950
}
5051

5152
val jvmTarget = JvmTarget.JVM_11
5253
val javaVersion = JavaVersion.VERSION_11
5354
val kotlinVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
5455
const val compileSdk = 34
55-
const val minSdk = 21
5656
const val targetSdk = compileSdk
57+
const val minSdk = 21
5758
const val appMinSdk = 26
5859
const val publishingVariant = "release"
5960

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

6970
val stabilityLevels = listOf("preview", "eap", "alpha", "beta", "m", "cr", "rc")
70-
7171
object Detekt {
7272

7373
const val configFile = "detekt.yml"

buildSrc/src/main/kotlin/ConfigureAndroid.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ fun Project.configureAndroid(
88
commonExtension: CommonExtension<*, *, *, *, *, *>,
99
) = commonExtension.apply {
1010
compileSdk = Config.compileSdk
11+
val libs by versionCatalog
12+
1113
defaultConfig {
1214
minSdk = Config.minSdk
1315
testInstrumentationRunner = Config.testRunner
@@ -44,12 +46,11 @@ fun Project.configureAndroid(
4446
}
4547

4648
packaging {
47-
resources {
48-
excludes += setOf(
49-
"DebugProbesKt.bin",
50-
"/META-INF/{AL2.0,LGPL2.1}",
51-
)
52-
}
49+
resources.excludes += listOf(
50+
"/META-INF/{AL2.0,LGPL2.1}",
51+
"DebugProbesKt.bin",
52+
"META-INF/versions/9/previous-compilation-data.bin"
53+
)
5354
}
5455

5556
testOptions {
@@ -65,7 +66,7 @@ fun Project.configureAndroid(
6566
}
6667
}
6768
}
68-
val libs by versionCatalog
69+
6970
composeOptions {
7071
kotlinCompilerExtensionVersion = libs.requireVersion("compose-compiler")
7172
useLiveLiterals = true

buildSrc/src/main/kotlin/ConfigureMultiplatform.kt

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,66 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
77

88
fun Project.configureMultiplatform(
99
ext: KotlinMultiplatformExtension,
10+
jvm: Boolean = true,
11+
android: Boolean = true,
12+
linux: Boolean = true,
13+
iOs: Boolean = true,
14+
js: Boolean = true,
15+
tvOs: Boolean = true,
16+
macOs: Boolean = true,
17+
watchOs: Boolean = true
1018
) = ext.apply {
1119
val libs by versionCatalog
1220
explicitApi()
13-
1421
applyDefaultHierarchyTemplate()
22+
withSourcesJar(true)
1523

16-
linuxX64()
17-
linuxArm64()
18-
mingwX64()
19-
20-
js(IR) {
21-
browser()
22-
nodejs()
23-
binaries.library()
24+
if (linux) {
25+
linuxX64()
26+
linuxArm64()
27+
mingwX64()
2428
}
2529

26-
androidTarget {
27-
publishLibraryVariants("release")
30+
if (js) {
31+
js(IR) {
32+
browser()
33+
nodejs()
34+
binaries.library()
35+
}
2836
}
2937

30-
jvm {
31-
compilations.all {
32-
kotlinOptions {
33-
jvmTarget = Config.jvmTarget.target
34-
freeCompilerArgs += Config.jvmCompilerArgs
35-
}
38+
if (android) {
39+
androidTarget {
40+
publishAllLibraryVariants()
3641
}
3742
}
3843

39-
listOf(
40-
iosX64(),
41-
iosArm64(),
42-
iosSimulatorArm64(),
43-
macosArm64(),
44-
macosX64(),
45-
tvosX64(),
46-
tvosArm64(),
47-
tvosSimulatorArm64(),
48-
watchosX64(),
49-
watchosArm64(),
50-
watchosDeviceArm64(),
51-
watchosSimulatorArm64(),
52-
).forEach {
44+
if (jvm) {
45+
jvm()
46+
}
47+
48+
sequence {
49+
if (iOs) {
50+
yield(iosX64())
51+
yield(iosArm64())
52+
yield(iosSimulatorArm64())
53+
}
54+
if (macOs) {
55+
yield(macosArm64())
56+
yield(macosX64())
57+
}
58+
if (tvOs) {
59+
yield(tvosX64())
60+
yield(tvosArm64())
61+
yield(tvosSimulatorArm64())
62+
}
63+
if (watchOs) {
64+
yield(watchosX64())
65+
yield(watchosArm64())
66+
yield(watchosDeviceArm64())
67+
yield(watchosSimulatorArm64())
68+
}
69+
}.forEach {
5370
it.binaries.framework {
5471
binaryOption("bundleId", Config.artifactId)
5572
binaryOption("bundleVersion", Config.versionName)
@@ -58,9 +75,11 @@ fun Project.configureMultiplatform(
5875
}
5976

6077
sourceSets.apply {
61-
val jvmTest by getting {
62-
dependencies {
63-
implementation(libs.requireLib("kotest-junit"))
78+
if (jvm) {
79+
val jvmTest by getting {
80+
dependencies {
81+
implementation(libs.requireLib("kotest-junit"))
82+
}
6483
}
6584
}
6685
all {

buildSrc/src/main/kotlin/pro.respawn.android-library.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ android {
1414
publishAndroid(this)
1515

1616
kotlinOptions {
17-
freeCompilerArgs += Config.jvmCompilerArgs
1817
jvmTarget = Config.jvmTarget.target
1918
languageVersion = Config.kotlinVersion.version
2019
}

buildSrc/src/main/kotlin/pro.respawn.shared-library.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import org.gradle.kotlin.dsl.kotlin
22
import org.gradle.kotlin.dsl.signing
33

44
plugins {
5-
// id(libs.plugins.atomicfu.id)
65
kotlin("multiplatform")
76
id("com.android.library")
87
id("maven-publish")

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ android.disableResourceValidation=true
1818
android.nonFinalResIds=true
1919
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
2020
kotlin.native.ignoreIncorrectDependencies=true
21-
# TODO: Set to true after https://github.com/Kotlin/kotlinx-atomicfu/issues/250
22-
kotlinx.atomicfu.enableJvmIrTransformation=false
23-
systemProp.org.gradle.unsafe.kotlin.assignment=true

settings.gradle.kts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
2+
13
pluginManagement {
24
repositories {
35
google()
46
gradlePluginPortal()
57
mavenCentral()
8+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
69
}
7-
}
810

9-
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
10-
11-
buildscript {
12-
repositories {
13-
google()
14-
gradlePluginPortal()
15-
mavenCentral()
11+
// TODO: https://github.com/Kotlin/kotlinx-atomicfu/issues/56
12+
resolutionStrategy {
13+
eachPlugin {
14+
val module = when (requested.id.id) {
15+
"kotlinx-atomicfu" -> "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}"
16+
else -> null
17+
}
18+
if (module != null) {
19+
useModule(module)
20+
}
21+
}
1622
}
1723
}
1824

0 commit comments

Comments
 (0)