From 3fa81690b976d6132c8e9d028a572c4ba2718638 Mon Sep 17 00:00:00 2001 From: Michael Bull Date: Sun, 3 Mar 2024 14:04:24 +0000 Subject: [PATCH] Lift subproject to root --- build.gradle.kts | 177 ++++++++++++++++++ buildSrc/build.gradle.kts | 7 - buildSrc/settings.gradle.kts | 19 -- .../main/kotlin/kotlin-conventions.gradle.kts | 94 ---------- .../kotlin/publish-conventions.gradle.kts | 85 --------- gradle/libs.versions.toml | 3 - kotlin-itertools/build.gradle.kts | 5 - settings.gradle.kts | 4 - .../michaelbull/itertools/Combinations.kt | 0 .../michaelbull/itertools/Permutations.kt | 0 .../github/michaelbull/itertools/Product.kt | 0 .../michaelbull/itertools/CombinationsTest.kt | 0 .../michaelbull/itertools/PermutationsTest.kt | 0 .../michaelbull/itertools/ProductTest.kt | 1 - 14 files changed, 177 insertions(+), 218 deletions(-) delete mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/settings.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/publish-conventions.gradle.kts delete mode 100644 kotlin-itertools/build.gradle.kts rename {kotlin-itertools/src => src}/commonMain/kotlin/com/github/michaelbull/itertools/Combinations.kt (100%) rename {kotlin-itertools/src => src}/commonMain/kotlin/com/github/michaelbull/itertools/Permutations.kt (100%) rename {kotlin-itertools/src => src}/commonMain/kotlin/com/github/michaelbull/itertools/Product.kt (100%) rename {kotlin-itertools/src => src}/commonTest/kotlin/com/github/michaelbull/itertools/CombinationsTest.kt (100%) rename {kotlin-itertools/src => src}/commonTest/kotlin/com/github/michaelbull/itertools/PermutationsTest.kt (100%) rename {kotlin-itertools/src => src}/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt (98%) diff --git a/build.gradle.kts b/build.gradle.kts index 3d3dc0f..aed300f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,14 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask plugins { + alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.versions) + `maven-publish` + signing } tasks.withType { @@ -14,3 +20,174 @@ tasks.withType { } } } + +kotlin { + explicitApi() + + jvmToolchain(8) + + jvm() + + js(IR) { + browser() + nodejs() + } + + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + binaries.executable() + nodejs() + } + + /* https://kotlinlang.org/docs/native-target-support.html#tier-1 */ + + macosX64() + macosArm64() + iosSimulatorArm64() + iosX64() + + /* https://kotlinlang.org/docs/native-target-support.html#tier-2 */ + + linuxX64() + linuxArm64() + + watchosSimulatorArm64() + watchosX64() + watchosArm32() + watchosArm64() + + tvosSimulatorArm64() + tvosX64() + tvosArm64() + + iosArm64() + + /* https://kotlinlang.org/docs/native-target-support.html#tier-3 */ + + androidNativeArm32() + androidNativeArm64() + androidNativeX86() + androidNativeX64() + + mingwX64() + watchosDeviceArm64() + + sourceSets { + all { + languageSettings.apply { + optIn("kotlin.contracts.ExperimentalContracts") + } + } + + commonTest { + dependencies { + implementation(kotlin("test")) + } + } + + jvmTest { + dependencies { + implementation(kotlin("test-junit")) + } + } + + jsTest { + dependencies { + implementation(kotlin("test-js")) + } + } + } +} + +tasks.withType { + from(rootDir.resolve("LICENSE")) { + into("META-INF") + } +} + +/* https://youtrack.jetbrains.com/issue/KT-63014/Running-tests-with-wasmJs-in-1.9.20-requires-Chrome-Canary#focus=Comments-27-8321383.0-0 */ +rootProject.the().apply { + nodeVersion = "21.0.0-v8-canary202309143a48826a08" + nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" +} + +rootProject.tasks.withType { + args.add("--ignore-engines") +} + +publishing { + repositories { + maven { + if (project.version.toString().endsWith("SNAPSHOT")) { + setUrl("https://oss.sonatype.org/content/repositories/snapshots") + } else { + setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2") + } + + credentials { + val ossrhUsername: String? by project + val ossrhPassword: String? by project + + username = ossrhUsername + password = ossrhPassword + } + } + } + + publications.withType { + val targetName = this@withType.name + + artifact(tasks.register("${targetName}JavadocJar", Jar::class) { + group = LifecycleBasePlugin.BUILD_GROUP + description = "Assembles a jar archive containing the Javadoc API documentation of target '$targetName'." + archiveClassifier.set("javadoc") + archiveAppendix.set(targetName) + }) + + pom { + name.set(project.name) + description.set(project.description) + url.set("https://github.com/michaelbull/kotlin-itertools") + inceptionYear.set("2024") + + licenses { + license { + name.set("ISC License") + url.set("https://opensource.org/licenses/isc-license.txt") + } + } + + developers { + developer { + name.set("Michael Bull") + url.set("https://www.michael-bull.com") + } + } + + scm { + connection.set("scm:git:https://github.com/michaelbull/kotlin-itertools") + developerConnection.set("scm:git:git@github.com:michaelbull/kotlin-itertools.git") + url.set("https://github.com/michaelbull/kotlin-itertools") + } + + issueManagement { + system.set("GitHub Issues") + url.set("https://github.com/michaelbull/kotlin-itertools/issues") + } + + ciManagement { + system.set("GitHub Actions") + url.set("https://github.com/michaelbull/kotlin-itertools/actions") + } + } + } +} + +signing { + val signingKeyId: String? by project // must be the last 8 digits of the key + val signingKey: String? by project + val signingPassword: String? by project + + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign(publishing.publications) +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 75c0eb2..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - `kotlin-dsl` -} - -dependencies { - implementation(libs.kotlin.gradle.plugin) -} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts deleted file mode 100644 index 17f9791..0000000 --- a/buildSrc/settings.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } -} - -dependencyResolutionManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } - - versionCatalogs { - create("libs") { - from(files("../gradle/libs.versions.toml")) - } - } -} diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts deleted file mode 100644 index f901508..0000000 --- a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts +++ /dev/null @@ -1,94 +0,0 @@ -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl -import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension -import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask - -plugins { - kotlin("multiplatform") -} - -kotlin { - explicitApi() - - jvmToolchain(8) - - jvm() - - js(IR) { - browser() - nodejs() - } - - androidNativeArm32() - androidNativeArm64() - androidNativeX64() - androidNativeX86() - - linuxArm64() - linuxX64() - - mingwX64() - - macosArm64() - macosX64() - - iosArm64() - iosSimulatorArm64() - iosX64() - - tvosArm64() - tvosSimulatorArm64() - tvosX64() - - watchosArm32() - watchosArm64() - watchosSimulatorArm64() - watchosX64() - - @OptIn(ExperimentalWasmDsl::class) - wasmJs { - binaries.executable() - nodejs() - } - - sourceSets { - all { - languageSettings.apply { - optIn("kotlin.contracts.ExperimentalContracts") - } - } - - commonTest { - dependencies { - implementation(kotlin("test")) - } - } - - jvmTest { - dependencies { - implementation(kotlin("test-junit")) - } - } - - jsTest { - dependencies { - implementation(kotlin("test-js")) - } - } - } -} - -tasks.withType { - from(rootDir.resolve("LICENSE")) { - into("META-INF") - } -} - -/* https://youtrack.jetbrains.com/issue/KT-63014/Running-tests-with-wasmJs-in-1.9.20-requires-Chrome-Canary#focus=Comments-27-8321383.0-0 */ -rootProject.the().apply { - nodeVersion = "21.0.0-v8-canary202309143a48826a08" - nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" -} - -rootProject.tasks.withType().configureEach { - args.add("--ignore-engines") -} diff --git a/buildSrc/src/main/kotlin/publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/publish-conventions.gradle.kts deleted file mode 100644 index dbdf515..0000000 --- a/buildSrc/src/main/kotlin/publish-conventions.gradle.kts +++ /dev/null @@ -1,85 +0,0 @@ -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.`maven-publish` - -plugins { - `maven-publish` - signing -} - -publishing { - repositories { - maven { - if (project.version.toString().endsWith("SNAPSHOT")) { - setUrl("https://oss.sonatype.org/content/repositories/snapshots") - } else { - setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2") - } - - credentials { - val ossrhUsername: String? by project - val ossrhPassword: String? by project - - username = ossrhUsername - password = ossrhPassword - } - } - } - - publications.withType { - val targetName = this@withType.name - - artifact(tasks.register("${targetName}JavadocJar", Jar::class) { - group = LifecycleBasePlugin.BUILD_GROUP - description = "Assembles a jar archive containing the Javadoc API documentation of target '$targetName'." - archiveClassifier.set("javadoc") - archiveAppendix.set(targetName) - }) - - pom { - name.set(project.name) - description.set(project.description) - url.set("https://github.com/michaelbull/kotlin-itertools") - inceptionYear.set("2024") - - licenses { - license { - name.set("ISC License") - url.set("https://opensource.org/licenses/isc-license.txt") - } - } - - developers { - developer { - name.set("Michael Bull") - url.set("https://www.michael-bull.com") - } - } - - scm { - connection.set("scm:git:https://github.com/michaelbull/kotlin-itertools") - developerConnection.set("scm:git:git@github.com:michaelbull/kotlin-itertools.git") - url.set("https://github.com/michaelbull/kotlin-itertools") - } - - issueManagement { - system.set("GitHub Issues") - url.set("https://github.com/michaelbull/kotlin-itertools/issues") - } - - ciManagement { - system.set("GitHub Actions") - url.set("https://github.com/michaelbull/kotlin-itertools/actions") - } - } - } -} - -signing { - val signingKeyId: String? by project // must be the last 8 digits of the key - val signingKey: String? by project - val signingPassword: String? by project - - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) - sign(publishing.publications) -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3cc021c..8680eec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,9 +2,6 @@ kotlin = "1.9.22" versions-plugin = "0.51.0" -[libraries] -kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } - [plugins] kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } versions = { id = "com.github.ben-manes.versions", version.ref = "versions-plugin" } diff --git a/kotlin-itertools/build.gradle.kts b/kotlin-itertools/build.gradle.kts deleted file mode 100644 index ec6a3de..0000000 --- a/kotlin-itertools/build.gradle.kts +++ /dev/null @@ -1,5 +0,0 @@ -plugins { - `maven-publish` - id("kotlin-conventions") - id("publish-conventions") -} diff --git a/settings.gradle.kts b/settings.gradle.kts index aff4d18..0142726 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,7 +16,3 @@ dependencyResolutionManagement { } rootProject.name = "kotlin-itertools" - -include( - "kotlin-itertools", -) diff --git a/kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Combinations.kt b/src/commonMain/kotlin/com/github/michaelbull/itertools/Combinations.kt similarity index 100% rename from kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Combinations.kt rename to src/commonMain/kotlin/com/github/michaelbull/itertools/Combinations.kt diff --git a/kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Permutations.kt b/src/commonMain/kotlin/com/github/michaelbull/itertools/Permutations.kt similarity index 100% rename from kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Permutations.kt rename to src/commonMain/kotlin/com/github/michaelbull/itertools/Permutations.kt diff --git a/kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Product.kt b/src/commonMain/kotlin/com/github/michaelbull/itertools/Product.kt similarity index 100% rename from kotlin-itertools/src/commonMain/kotlin/com/github/michaelbull/itertools/Product.kt rename to src/commonMain/kotlin/com/github/michaelbull/itertools/Product.kt diff --git a/kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/CombinationsTest.kt b/src/commonTest/kotlin/com/github/michaelbull/itertools/CombinationsTest.kt similarity index 100% rename from kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/CombinationsTest.kt rename to src/commonTest/kotlin/com/github/michaelbull/itertools/CombinationsTest.kt diff --git a/kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/PermutationsTest.kt b/src/commonTest/kotlin/com/github/michaelbull/itertools/PermutationsTest.kt similarity index 100% rename from kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/PermutationsTest.kt rename to src/commonTest/kotlin/com/github/michaelbull/itertools/PermutationsTest.kt diff --git a/kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt b/src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt similarity index 98% rename from kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt rename to src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt index 284df3c..765a101 100644 --- a/kotlin-itertools/src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt +++ b/src/commonTest/kotlin/com/github/michaelbull/itertools/ProductTest.kt @@ -2,7 +2,6 @@ package com.github.michaelbull.itertools import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertTrue class ProductTest {