Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework gradle configuration to use composite builds #106

Merged
merged 5 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 16 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,44 +240,32 @@ dependencies {
implementation("io.matthewnelson.kotlin-components:encoding-base16:$encoding")
implementation("io.matthewnelson.kotlin-components:encoding-base32:$encoding")
implementation("io.matthewnelson.kotlin-components:encoding-base64:$encoding")
// Alternatively, if you only want the abstractions to create your own EncoderDecoder(s)

// Only necessary if you just want the abstractions to create your own EncoderDecoder(s)
implementation("io.matthewnelson.kotlin-components:encoding-core:$encoding")
}
```

<!-- TAG_VERSION -->
<!-- TODO: Uncomment next release
Alternatively, you can use the BOM.

```groovy
// build.gradle
```kotlin
// build.gradle.kts
dependencies {
def encoding = "1.2.1"
implementation "io.matthewnelson.kotlin-components:encoding-base16:$encoding"
implementation "io.matthewnelson.kotlin-components:encoding-base32:$encoding"
implementation "io.matthewnelson.kotlin-components:encoding-base64:$encoding"
// define the BOM and its version
implementation(platform("io.matthewnelson.kotlin-components:encoding-bom:1.2.1"))

// define artifacts without version
implementation("io.matthewnelson.kotlin-components:encoding-base16")
implementation("io.matthewnelson.kotlin-components:encoding-base32")
implementation("io.matthewnelson.kotlin-components:encoding-base64")

// Alternatively, if you only want the abstractions to create your own EncoderDecoder(s)
implementation "io.matthewnelson.kotlin-components:encoding-core:$encoding"
// Only necessary if you just want the abstractions to create your own EncoderDecoder(s)
implementation("io.matthewnelson.kotlin-components:encoding-core")
}
```

### Kotlin Version Compatibility

**Note:** as of `1.1.0`, the experimental memory model for KotlinNative is enabled.

<!-- TAG_VERSION -->

| encoding | kotlin |
|:--------:|:------:|
| 1.2.1 | 1.8.0 |
| 1.2.0 | 1.8.0 |
| 1.1.5 | 1.8.0 |
| 1.1.4 | 1.7.20 |
| 1.1.3 | 1.6.21 |
| 1.1.2 | 1.6.21 |
| 1.1.1 | 1.6.21 |
| 1.1.0 | 1.6.10 |
| 1.0.3 | 1.5.31 |
-->

<!-- TAG_VERSION -->
[badge-latest-release]: https://img.shields.io/badge/latest--release-1.2.1-blue.svg?style=flat
Expand Down
1 change: 1 addition & 0 deletions build-logic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
24 changes: 24 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.gradle.kotlin)
implementation(libs.gradle.maven.publish)
implementation(libs.gradle.kmp.configuration)
}
31 changes: 31 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
@file:Suppress("UnstableApiUsage")

rootProject.name = "build-logic"

dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
63 changes: 63 additions & 0 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
import org.gradle.api.Action
import org.gradle.api.JavaVersion

fun KmpConfigurationExtension.configureShared(
publish: Boolean = false,
explicitApi: Boolean = true,
action: Action<KmpConfigurationContainerDsl>
) {
configure {
jvm {
target { withJava() }

kotlinJvmTarget = JavaVersion.VERSION_1_8
compileSourceCompatibility = JavaVersion.VERSION_1_8
compileTargetCompatibility = JavaVersion.VERSION_1_8
}

js()
// wasm()
wasmNativeAll()

androidNativeAll()

iosAll()
macosAll()
tvosAll()
watchosAll()

linuxAll()
mingwAll()

common {
if (publish) { pluginIds("publication") }

sourceSetTest {
dependencies {
implementation(kotlin("test"))
}
}
}

if (explicitApi) { kotlin { explicitApi() } }

action.execute(this)
}
}
1 change: 1 addition & 0 deletions build-logic/src/main/kotlin/bom-include.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// include project in BOM
32 changes: 32 additions & 0 deletions build-logic/src/main/kotlin/configuration.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED

plugins {
id("io.matthewnelson.kmp.configuration")
}

tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events(STARTED, PASSED, SKIPPED, FAILED)
showStandardStreams = true
}
}
26 changes: 26 additions & 0 deletions build-logic/src/main/kotlin/publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.gradle.plugins.signing.SigningExtension

/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
plugins {
id("com.vanniktech.maven.publish")
}

if (!version.toString().endsWith("-SNAPSHOT")) {
extensions.configure<SigningExtension>("signing") {
useGpgCmd()
}
}
42 changes: 6 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,14 @@
* limitations under the License.
**/
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension

buildscript {

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath(libs.gradle.kotlin)
classpath(libs.gradle.maven.publish)
classpath(libs.gradle.versions)

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
}
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.multiplatform) apply(false)
alias(libs.plugins.binaryCompat)
alias(libs.plugins.gradleVersions)
}

allprojects {
Expand All @@ -49,29 +34,14 @@ allprojects {
mavenCentral()
}

tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events(STARTED, PASSED, SKIPPED, FAILED)
showStandardStreams = true
}
}

}

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

plugins {
@Suppress("DSL_SCOPE_VIOLATION")
alias(libs.plugins.binaryCompat)
}

plugins.apply(libs.plugins.gradleVersions.get().pluginId)

@Suppress("LocalVariableName")
apiValidation {
@Suppress("LocalVariableName")
val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION") as? String

if (CHECK_PUBLICATION != null) {
Expand Down
Empty file added encoding-bom/.gitignore
Empty file.
32 changes: 32 additions & 0 deletions encoding-bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
plugins {
id("publication")
id("java-platform")
}

dependencies {
constraints {
rootProject.subprojects.forEach {
if (
it.path.startsWith(":library:")
&& evaluationDependsOn(it.path).plugins.hasPlugin("bom-include")
) {
api(project(it.path))
}
}
}
}
16 changes: 16 additions & 0 deletions encoding-bom/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2023 Matthew Nelson
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
POM_ARTIFACT_ID=encoding-bom
POM_NAME=encoding-bom
POM_DESCRIPTION=Bill of materials for encoding library
7 changes: 3 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[versions]
binaryCompat = "0.13.0"
configuration = "0.1.0-beta01"
configuration = "0.1.0-beta02"
gradleVersions = "0.46.0"
kotlin = "1.8.10"
publish = "0.24.0"

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

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