Skip to content

Commit 7802a41

Browse files
committed
chore: new kotlin DSL changes
1 parent 369f0ac commit 7802a41

File tree

5 files changed

+61
-34
lines changed

5 files changed

+61
-34
lines changed

gradle/build-logic/src/main/kotlin/common/Multiplatform.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package common
22

33
import org.gradle.api.GradleException
44
import org.gradle.api.Project
5+
import org.gradle.api.file.DuplicatesStrategy
56
import org.gradle.kotlin.dsl.*
67
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
78
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
@@ -100,13 +101,16 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
100101
// val test by testRuns.existing
101102
testRuns.configureEach { executionTask.configure { configureJavaTest() } }
102103

103-
// binaries {
104-
// executable {
105-
// mainClass = libs.versions.app.mainclass
106-
// applicationDefaultJvmArgs = jvmRunArgs
107-
// applicationDistribution.duplicatesStrategy = DuplicatesStrategy.WARN
108-
// }
109-
// }
104+
// Configure application executable only it's enabled
105+
if (isKmpExecEnabled) {
106+
binaries {
107+
executable {
108+
mainClass = libs.versions.app.mainclass
109+
applicationDefaultJvmArgs = jvmRunArgs
110+
applicationDistribution.duplicatesStrategy = DuplicatesStrategy.WARN
111+
}
112+
}
113+
}
110114

111115
// Register a task to execute a class using jvm runtime dependencies.
112116
// compilations.getByName("test") {

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.gradle.api.tasks.testing.logging.*
2525
import org.gradle.internal.os.OperatingSystem
2626
import org.gradle.jvm.toolchain.*
2727
import org.gradle.kotlin.dsl.*
28+
import org.gradle.kotlin.dsl.extra
2829
import org.jetbrains.kotlin.gradle.dsl.*
2930
import org.jetbrains.kotlin.gradle.plugin.*
3031
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
@@ -52,6 +53,9 @@ val Project.isRootProject
5253
val Project.sharedProjectName
5354
get() = "shared"
5455

56+
val Project.buildLogicProjectName
57+
get() = "build-logic"
58+
5559
val Project.isSharedProject
5660
get() = name == sharedProjectName
5761

@@ -71,6 +75,9 @@ val Project.isSnapshotVersion
7175
val Project.runsOnCI
7276
get() = providers.environmentVariable("CI").isPresent
7377

78+
val Project.isKmpExecEnabled
79+
get() = extra.has("enableKmpExec") && extra["enableKmpExec"] as Boolean
80+
7481
/** Java version properties. */
7582
val Project.javaVersion
7683
get() = libs.versions.java.asProvider().map { JavaVersion.toVersion(it) }

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.common.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import common.*
22
import org.gradle.kotlin.dsl.*
33

4-
plugins { application }
5-
64
@Suppress("UNUSED_VARIABLE")
75
tasks {
8-
run.invoke { args(true) }
9-
10-
// val versionCatalog = the<VersionCatalogsExtension>().named("libs")
116
val copyTemplates by
127
registering(Copy::class) {
138
description = "Generate template classes"
@@ -37,6 +32,8 @@ tasks {
3732
// inputs.property("buildversions", props.hashCode())
3833
}
3934

35+
// val versionCatalog = the<VersionCatalogsExtension>().named("libs")
36+
4037
// Add the generated templates to the source set to enable the task.
4138
// sourceSets { main { java.srcDirs(copyTemplates) } }
4239
}

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.root.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ tasks {
138138

139139
// Auto-format all source files
140140
pluginManager.withPlugin("com.diffplug.spotless") {
141-
processResources {
142-
// dependsOn(":spotlessApply")
143-
}
141+
// tasks.withType<ProcessResources>().configureEach { dependsOn(":spotlessApply") }
144142
}
145143

146144
// Run the checkBestPractices check for build-logic included builds.
147145
register("checkBuildLogicBestPractices") {
148146
description = "Run the checkBestPractices check for build-logic included builds!"
149147
group = BasePlugin.BUILD_GROUP
150-
dependsOn(gradle.includedBuild("build-logic").task(":checkBestPractices"))
148+
149+
dependsOn(
150+
gradle.includedBuilds
151+
.filter { it.name == buildLogicProjectName }
152+
.mapNotNull { it.task(":checkBestPractices") })
151153
}
152154

153155
register<Copy>("setUpGitHooks") {

gradle/kotlin-js-store/package-lock.json

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

0 commit comments

Comments
 (0)