Skip to content

Commit e066a71

Browse files
authored
Update gradle-kmp-configuration-plugin (composite build support) (#19)
1 parent 4bcb538 commit e066a71

13 files changed

+206
-197
lines changed

build-logic/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

build-logic/build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2023 Matthew Nelson
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
plugins {
17+
`kotlin-dsl`
18+
}
19+
20+
dependencies {
21+
implementation(libs.gradle.kotlin)
22+
implementation(libs.gradle.maven.publish)
23+
implementation(libs.gradle.kmp.configuration)
24+
}

build-logic/settings.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2023 Matthew Nelson
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
@file:Suppress("UnstableApiUsage")
17+
18+
rootProject.name = "build-logic"
19+
20+
dependencyResolutionManagement {
21+
repositories {
22+
mavenCentral()
23+
gradlePluginPortal()
24+
}
25+
26+
versionCatalogs {
27+
create("libs") {
28+
from(files("../gradle/libs.versions.toml"))
29+
}
30+
}
31+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2023 Matthew Nelson
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
17+
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
18+
import org.gradle.api.Action
19+
import org.gradle.api.JavaVersion
20+
21+
fun KmpConfigurationExtension.configureShared(
22+
publish: Boolean = false,
23+
action: Action<KmpConfigurationContainerDsl>
24+
) {
25+
configure {
26+
jvm {
27+
target { withJava() }
28+
29+
kotlinJvmTarget = JavaVersion.VERSION_1_8
30+
compileSourceCompatibility = JavaVersion.VERSION_1_8
31+
compileTargetCompatibility = JavaVersion.VERSION_1_8
32+
}
33+
34+
js()
35+
// wasm()
36+
wasmNativeAll()
37+
38+
androidNativeAll()
39+
40+
iosAll()
41+
macosAll()
42+
tvosAll()
43+
watchosAll()
44+
45+
linuxAll()
46+
mingwAll()
47+
48+
common {
49+
if (publish) {
50+
pluginIds("publication")
51+
}
52+
53+
sourceSetTest {
54+
dependencies {
55+
implementation(kotlin("test"))
56+
}
57+
}
58+
}
59+
60+
kotlin {
61+
explicitApi()
62+
}
63+
64+
action.execute(this)
65+
}
66+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2023 Matthew Nelson
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
17+
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
18+
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
19+
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
20+
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
21+
22+
plugins {
23+
id("io.matthewnelson.kmp.configuration")
24+
}
25+
26+
tasks.withType<Test> {
27+
testLogging {
28+
exceptionFormat = TestExceptionFormat.FULL
29+
events(STARTED, PASSED, SKIPPED, FAILED)
30+
showStandardStreams = true
31+
}
32+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import org.gradle.plugins.signing.SigningExtension
2+
3+
/*
4+
* Copyright (c) 2023 Matthew Nelson
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
**/
18+
plugins {
19+
id("com.vanniktech.maven.publish")
20+
}
21+
22+
if (!version.toString().endsWith("-SNAPSHOT")) {
23+
extensions.configure<SigningExtension>("signing") {
24+
useGpgCmd()
25+
}
26+
}

build.gradle.kts

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,14 @@
1414
* limitations under the License.
1515
**/
1616
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
17-
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
18-
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
19-
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
20-
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
21-
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
2217
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
2318
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
2419

25-
buildscript {
26-
27-
repositories {
28-
mavenCentral()
29-
gradlePluginPortal()
30-
}
31-
32-
dependencies {
33-
classpath(libs.gradle.kotlin)
34-
classpath(libs.gradle.maven.publish)
35-
classpath(libs.gradle.versions)
36-
37-
// NOTE: Do not place your application dependencies here; they belong
38-
// in the individual module build.gradle.kts files
39-
}
20+
@Suppress("DSL_SCOPE_VIOLATION")
21+
plugins {
22+
alias(libs.plugins.multiplatform) apply(false)
23+
alias(libs.plugins.binaryCompat)
24+
alias(libs.plugins.gradleVersions)
4025
}
4126

4227
allprojects {
@@ -48,30 +33,14 @@ allprojects {
4833
repositories {
4934
mavenCentral()
5035
}
51-
52-
tasks.withType<Test> {
53-
testLogging {
54-
exceptionFormat = TestExceptionFormat.FULL
55-
events(STARTED, PASSED, SKIPPED, FAILED)
56-
showStandardStreams = true
57-
}
58-
}
59-
6036
}
6137

6238
plugins.withType<YarnPlugin> {
6339
the<YarnRootExtension>().lockFileDirectory = rootDir.resolve(".kotlin-js-store")
6440
}
6541

66-
plugins {
67-
@Suppress("DSL_SCOPE_VIOLATION")
68-
alias(libs.plugins.binaryCompat)
69-
}
70-
71-
plugins.apply(libs.plugins.gradleVersions.get().pluginId)
72-
73-
@Suppress("LocalVariableName")
7442
apiValidation {
43+
@Suppress("LocalVariableName")
7544
val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION") as? String
7645

7746
if (CHECK_PUBLICATION != null) {

gradle/libs.versions.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
[versions]
22
binaryCompat = "0.13.0"
3-
configuration = "0.1.0-beta01"
3+
configuration = "0.1.0-beta02"
44
gradleVersions = "0.46.0"
55
kotlin = "1.8.10"
66
publish = "0.24.0"
77

88
[libraries]
9+
gradle-kmp-configuration = { module = "io.matthewnelson:gradle-kmp-configuration-plugin", version.ref = "configuration" }
910
gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
1011
gradle-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "publish" }
11-
gradle-versions = { module = "com.github.ben-manes:gradle-versions-plugin", version.ref = "gradleVersions" }
1212

1313
[plugins]
1414
binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompat" }
15-
publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" }
16-
configuration = { id = "io.matthewnelson.kmp.configuration", version.ref = "configuration" }
15+
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
1716
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }

library/common/build.gradle.kts

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
**/
16-
@Suppress("DSL_SCOPE_VIOLATION")
1716
plugins {
18-
alias(libs.plugins.configuration)
17+
id("configuration")
1918
}
2019

2120
kmpConfiguration {
22-
configure {
23-
jvm {
24-
target {
25-
withJava()
26-
}
27-
28-
kotlinJvmTarget = JavaVersion.VERSION_1_8
29-
compileSourceCompatibility = JavaVersion.VERSION_1_8
30-
compileTargetCompatibility = JavaVersion.VERSION_1_8
31-
}
32-
33-
js()
34-
// wasm()
35-
wasmNativeAll()
36-
37-
androidNativeAll()
38-
39-
iosAll()
40-
macosAll()
41-
tvosAll()
42-
watchosAll()
43-
44-
linuxAll()
45-
mingwAll()
46-
47-
common {
48-
pluginIds(libs.plugins.publish.get().pluginId)
49-
}
50-
51-
kotlin {
52-
explicitApi()
53-
54-
if (!version.toString().endsWith("-SNAPSHOT")) {
55-
extensions.configure<SigningExtension>("signing") {
56-
useGpgCmd()
57-
}
58-
}
59-
}
60-
}
21+
configureShared(publish = true) {}
6122
}

library/digest/build.gradle.kts

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
**/
16-
@Suppress("DSL_SCOPE_VIOLATION")
1716
plugins {
18-
alias(libs.plugins.configuration)
17+
id("configuration")
1918
}
2019

2120
kmpConfiguration {
22-
configure {
23-
jvm {
24-
target {
25-
withJava()
26-
}
27-
28-
kotlinJvmTarget = JavaVersion.VERSION_1_8
29-
compileSourceCompatibility = JavaVersion.VERSION_1_8
30-
compileTargetCompatibility = JavaVersion.VERSION_1_8
31-
}
32-
33-
js()
34-
// wasm()
35-
wasmNativeAll()
36-
37-
androidNativeAll()
38-
39-
iosAll()
40-
macosAll()
41-
tvosAll()
42-
watchosAll()
43-
44-
linuxAll()
45-
mingwAll()
46-
21+
configureShared(publish = true) {
4722
common {
48-
pluginIds(libs.plugins.publish.get().pluginId)
49-
5023
sourceSetMain {
5124
dependencies {
5225
api(project(":library:common"))
5326
}
5427
}
55-
sourceSetTest {
56-
dependencies {
57-
implementation(kotlin("test"))
58-
}
59-
}
60-
}
61-
62-
kotlin {
63-
explicitApi()
64-
65-
if (!version.toString().endsWith("-SNAPSHOT")) {
66-
extensions.configure<SigningExtension>("signing") {
67-
useGpgCmd()
68-
}
69-
}
7028
}
7129
}
7230
}

0 commit comments

Comments
 (0)