diff --git a/README.md b/README.md index a66ee6e..25b6945 100644 --- a/README.md +++ b/README.md @@ -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") } ``` + - -| 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 | +--> [badge-latest-release]: https://img.shields.io/badge/latest--release-1.2.1-blue.svg?style=flat diff --git a/build-logic/.gitignore b/build-logic/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/build-logic/.gitignore @@ -0,0 +1 @@ +/build diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 0000000..6832bca --- /dev/null +++ b/build-logic/build.gradle.kts @@ -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) +} diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 0000000..3f15d58 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -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")) + } + } +} diff --git a/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt new file mode 100644 index 0000000..57998b9 --- /dev/null +++ b/build-logic/src/main/kotlin/-KmpConfigurationExtension.kt @@ -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 +) { + 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) + } +} diff --git a/build-logic/src/main/kotlin/bom-include.gradle.kts b/build-logic/src/main/kotlin/bom-include.gradle.kts new file mode 100644 index 0000000..ed7bed3 --- /dev/null +++ b/build-logic/src/main/kotlin/bom-include.gradle.kts @@ -0,0 +1 @@ +// include project in BOM diff --git a/build-logic/src/main/kotlin/configuration.gradle.kts b/build-logic/src/main/kotlin/configuration.gradle.kts new file mode 100644 index 0000000..4064a86 --- /dev/null +++ b/build-logic/src/main/kotlin/configuration.gradle.kts @@ -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 { + testLogging { + exceptionFormat = TestExceptionFormat.FULL + events(STARTED, PASSED, SKIPPED, FAILED) + showStandardStreams = true + } +} diff --git a/build-logic/src/main/kotlin/publication.gradle.kts b/build-logic/src/main/kotlin/publication.gradle.kts new file mode 100644 index 0000000..bebbda4 --- /dev/null +++ b/build-logic/src/main/kotlin/publication.gradle.kts @@ -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("signing") { + useGpgCmd() + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 9d5aa10..720c6c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 { @@ -49,29 +34,14 @@ allprojects { mavenCentral() } - tasks.withType { - testLogging { - exceptionFormat = TestExceptionFormat.FULL - events(STARTED, PASSED, SKIPPED, FAILED) - showStandardStreams = true - } - } - } plugins.withType { the().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) { diff --git a/encoding-bom/.gitignore b/encoding-bom/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/encoding-bom/build.gradle.kts b/encoding-bom/build.gradle.kts new file mode 100644 index 0000000..e988140 --- /dev/null +++ b/encoding-bom/build.gradle.kts @@ -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)) + } + } + } +} diff --git a/encoding-bom/gradle.properties b/encoding-bom/gradle.properties new file mode 100644 index 0000000..7a41666 --- /dev/null +++ b/encoding-bom/gradle.properties @@ -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 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 26f666a..79ca448 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/library/encoding-base16/build.gradle.kts b/library/encoding-base16/build.gradle.kts index e20b75e..6cf6ed0 100644 --- a/library/encoding-base16/build.gradle.kts +++ b/library/encoding-base16/build.gradle.kts @@ -13,60 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") + id("bom-include") } kmpConfiguration { - 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() - + configureShared(publish = true) { common { - pluginIds(libs.plugins.publish.get().pluginId) - sourceSetMain { dependencies { api(project(":library:encoding-core")) } } - sourceSetTest { dependencies { - implementation(kotlin("test")) implementation(project(":library:encoding-test")) } } } - - kotlin { - explicitApi() - - extensions.configure("signing") { - useGpgCmd() - } - } } } diff --git a/library/encoding-base32/build.gradle.kts b/library/encoding-base32/build.gradle.kts index e20b75e..6cf6ed0 100644 --- a/library/encoding-base32/build.gradle.kts +++ b/library/encoding-base32/build.gradle.kts @@ -13,60 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") + id("bom-include") } kmpConfiguration { - 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() - + configureShared(publish = true) { common { - pluginIds(libs.plugins.publish.get().pluginId) - sourceSetMain { dependencies { api(project(":library:encoding-core")) } } - sourceSetTest { dependencies { - implementation(kotlin("test")) implementation(project(":library:encoding-test")) } } } - - kotlin { - explicitApi() - - extensions.configure("signing") { - useGpgCmd() - } - } } } diff --git a/library/encoding-base64/build.gradle.kts b/library/encoding-base64/build.gradle.kts index e20b75e..6cf6ed0 100644 --- a/library/encoding-base64/build.gradle.kts +++ b/library/encoding-base64/build.gradle.kts @@ -13,60 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") + id("bom-include") } kmpConfiguration { - 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() - + configureShared(publish = true) { common { - pluginIds(libs.plugins.publish.get().pluginId) - sourceSetMain { dependencies { api(project(":library:encoding-core")) } } - sourceSetTest { dependencies { - implementation(kotlin("test")) implementation(project(":library:encoding-test")) } } } - - kotlin { - explicitApi() - - extensions.configure("signing") { - useGpgCmd() - } - } } } diff --git a/library/encoding-core/build.gradle.kts b/library/encoding-core/build.gradle.kts index 7d50817..8691859 100644 --- a/library/encoding-core/build.gradle.kts +++ b/library/encoding-core/build.gradle.kts @@ -13,53 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") + id("bom-include") } kmpConfiguration { - 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 { - pluginIds(libs.plugins.publish.get().pluginId) - - sourceSetTest { - dependencies { - implementation(kotlin("test")) - } - } - } - - kotlin { - explicitApi() - - extensions.configure("signing") { - useGpgCmd() - } - } - } + configureShared(publish = true) {} } diff --git a/library/encoding-test/build.gradle.kts b/library/encoding-test/build.gradle.kts index c00e850..bcc2341 100644 --- a/library/encoding-test/build.gradle.kts +++ b/library/encoding-test/build.gradle.kts @@ -13,37 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") } kmpConfiguration { - 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() - + configureShared(explicitApi = false) { common { sourceSetMain { dependencies { diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 9e5da2f..6b889c9 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -15,9 +15,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") } kmpConfiguration { diff --git a/sample/src/commonMain/kotlin/Main.kt b/sample/src/commonMain/kotlin/Main.kt index eed4641..36d10a9 100644 --- a/sample/src/commonMain/kotlin/Main.kt +++ b/sample/src/commonMain/kotlin/Main.kt @@ -70,7 +70,7 @@ fun main() { val base64 = bytes.encodeToString(base64DefaultEncoderDecoder) val base64UrlSafe = bytes.encodeToString(base64UrlSafeEncoderDecoder) - println("Hello World Encodes to:") + println("'Hello World!' Encodes to:") println(" Base16 (hex): $base16") println(" Base32 Crockford[checkSymbol = *, hyphenInterval = 5]: $crockford") diff --git a/settings.gradle.kts b/settings.gradle.kts index ba892fb..126432e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,14 @@ rootProject.name = "encoding" +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +includeBuild("build-logic") + @Suppress("PrivatePropertyName") private val CHECK_PUBLICATION: String? by settings @@ -16,5 +25,6 @@ if (CHECK_PUBLICATION != null) { include(":library:$name") } + include(":encoding-bom") include(":sample") } diff --git a/tools/check-publication/build.gradle.kts b/tools/check-publication/build.gradle.kts index cc46cef..edfa8a1 100644 --- a/tools/check-publication/build.gradle.kts +++ b/tools/check-publication/build.gradle.kts @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -@Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.configuration) + id("configuration") } repositories { @@ -36,38 +35,15 @@ repositories { } kmpConfiguration { - 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() - + configureShared(explicitApi = false) { common { sourceSetMain { dependencies { - implementation("${group}:encoding-base16:${version}") - implementation("${group}:encoding-base32:${version}") - implementation("${group}:encoding-base64:${version}") - implementation("${group}:encoding-core:${version}") + implementation(platform("$group:encoding-bom:$version")) + implementation("$group:encoding-base16") + implementation("$group:encoding-base32") + implementation("$group:encoding-base64") + implementation("$group:encoding-core") } } }