File tree Expand file tree Collapse file tree 5 files changed +61
-34
lines changed
build-logic/src/main/kotlin Expand file tree Collapse file tree 5 files changed +61
-34
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package common
2
2
3
3
import org.gradle.api.GradleException
4
4
import org.gradle.api.Project
5
+ import org.gradle.api.file.DuplicatesStrategy
5
6
import org.gradle.kotlin.dsl.*
6
7
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
7
8
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
@@ -100,13 +101,16 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
100
101
// val test by testRuns.existing
101
102
testRuns.configureEach { executionTask.configure { configureJavaTest() } }
102
103
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
+ }
110
114
111
115
// Register a task to execute a class using jvm runtime dependencies.
112
116
// compilations.getByName("test") {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import org.gradle.api.tasks.testing.logging.*
25
25
import org.gradle.internal.os.OperatingSystem
26
26
import org.gradle.jvm.toolchain.*
27
27
import org.gradle.kotlin.dsl.*
28
+ import org.gradle.kotlin.dsl.extra
28
29
import org.jetbrains.kotlin.gradle.dsl.*
29
30
import org.jetbrains.kotlin.gradle.plugin.*
30
31
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
@@ -52,6 +53,9 @@ val Project.isRootProject
52
53
val Project .sharedProjectName
53
54
get() = " shared"
54
55
56
+ val Project .buildLogicProjectName
57
+ get() = " build-logic"
58
+
55
59
val Project .isSharedProject
56
60
get() = name == sharedProjectName
57
61
@@ -71,6 +75,9 @@ val Project.isSnapshotVersion
71
75
val Project .runsOnCI
72
76
get() = providers.environmentVariable(" CI" ).isPresent
73
77
78
+ val Project .isKmpExecEnabled
79
+ get() = extra.has(" enableKmpExec" ) && extra[" enableKmpExec" ] as Boolean
80
+
74
81
/* * Java version properties. */
75
82
val Project .javaVersion
76
83
get() = libs.versions.java.asProvider().map { JavaVersion .toVersion(it) }
Original file line number Diff line number Diff line change 1
1
import common.*
2
2
import org.gradle.kotlin.dsl.*
3
3
4
- plugins { application }
5
-
6
4
@Suppress(" UNUSED_VARIABLE" )
7
5
tasks {
8
- run.invoke { args(true ) }
9
-
10
- // val versionCatalog = the<VersionCatalogsExtension>().named("libs")
11
6
val copyTemplates by
12
7
registering(Copy ::class ) {
13
8
description = " Generate template classes"
@@ -37,6 +32,8 @@ tasks {
37
32
// inputs.property("buildversions", props.hashCode())
38
33
}
39
34
35
+ // val versionCatalog = the<VersionCatalogsExtension>().named("libs")
36
+
40
37
// Add the generated templates to the source set to enable the task.
41
38
// sourceSets { main { java.srcDirs(copyTemplates) } }
42
39
}
Original file line number Diff line number Diff line change @@ -138,16 +138,18 @@ tasks {
138
138
139
139
// Auto-format all source files
140
140
pluginManager.withPlugin(" com.diffplug.spotless" ) {
141
- processResources {
142
- // dependsOn(":spotlessApply")
143
- }
141
+ // tasks.withType<ProcessResources>().configureEach { dependsOn(":spotlessApply") }
144
142
}
145
143
146
144
// Run the checkBestPractices check for build-logic included builds.
147
145
register(" checkBuildLogicBestPractices" ) {
148
146
description = " Run the checkBestPractices check for build-logic included builds!"
149
147
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" ) })
151
153
}
152
154
153
155
register<Copy >(" setUpGitHooks" ) {
You can’t perform that action at this time.
0 commit comments