Skip to content

Commit

Permalink
Use unique moduleName parameters (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Aug 30, 2024
1 parent 2082f77 commit d41e283
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 161 deletions.
250 changes: 132 additions & 118 deletions .kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,24 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
fun KmpConfigurationExtension.configureShared(
java9ModuleName: String? = null,
publish: Boolean = false,
explicitApi: Boolean = true,
action: Action<KmpConfigurationContainerDsl>
) {
if (publish) {
require(!java9ModuleName.isNullOrBlank()) { "publications must specify a module-info name" }
}

configure {
options {
useUniqueModuleNames = true
}

jvm {
kotlinJvmTarget = JavaVersion.VERSION_1_8
compileSourceCompatibility = JavaVersion.VERSION_1_8
compileTargetCompatibility = JavaVersion.VERSION_1_8

@OptIn(ExperimentalKmpConfigurationApi::class)
java9MultiReleaseModuleInfo(java9ModuleName)
java9ModuleInfoName = java9ModuleName
}

js {
Expand Down Expand Up @@ -67,9 +74,7 @@ fun KmpConfigurationExtension.configureShared(
mingwAll()

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

sourceSetTest {
dependencies {
Expand All @@ -78,11 +83,7 @@ fun KmpConfigurationExtension.configureShared(
}
}

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

action.execute(this)
}
Expand Down
20 changes: 2 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension

plugins {
alias(libs.plugins.multiplatform) apply(false)
alias(libs.plugins.binaryCompat)
alias(libs.plugins.binary.compat)
alias(libs.plugins.kotlin.multiplatform) apply(false)
}

allprojects {

findProperty("GROUP")?.let { group = it }
findProperty("VERSION_NAME")?.let { version = it }
findProperty("POM_DESCRIPTION")?.let { description = it.toString() }

repositories {
mavenCentral()
}

}

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

plugins.withType<NodeJsRootPlugin> {
the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

tasks.withType<KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
}

apiValidation {
if (findProperty("CHECK_PUBLICATION") != null) {
ignoredProjects.add("check-publication")
Expand Down
26 changes: 14 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[versions]
binaryCompat = "0.14.0"
configuration = "0.2.1"
coroutines = "1.8.0"
kotlin = "1.9.23"
publish = "0.27.0"
gradle-binary-compat = "0.14.0"
gradle-kmp-configuration = "0.3.2"
gradle-kotlin = "1.9.24"
gradle-publish-maven = "0.29.0"

# tests
kotlinx-coroutines = "1.8.1"

[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-kmp-configuration = { module = "io.matthewnelson:gradle-kmp-configuration-plugin", version.ref = "gradle-kmp-configuration" }
gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "gradle-kotlin" }
gradle-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradle-publish-maven" }

# Tests
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
# tests
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }

[plugins]
binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompat" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
binary-compat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "gradle-binary-compat" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "gradle-kotlin" }
4 changes: 2 additions & 2 deletions secure-random/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ kmpConfiguration {
linuxX64 {
sourceSetTest {
dependencies {
implementation(libs.kotlin.coroutines.test)
implementation(libs.kotlinx.coroutines.test)
}
}
}

kotlin {
sourceSets {
with(sourceSets) {
val linuxMain = findByName("linuxMain")
val androidNativeMain = findByName("androidNativeMain")

Expand Down
2 changes: 1 addition & 1 deletion tools/check-publication/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repositories {
}

kmpConfiguration {
configureShared(explicitApi = false) {
configureShared {
common {
sourceSetMain {
dependencies {
Expand Down

0 comments on commit d41e283

Please sign in to comment.