Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eygraber/gradle-conventions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.58
Choose a base ref
...
head repository: eygraber/gradle-conventions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.0.59
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Jan 4, 2024

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    b25fc74 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cdeb9bf View commit details
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ with(gradleConventionsExtension) {
wasmJsNode = webOptions.isNodeEnabled,
wasmWasi = KmpTarget.WasmWasi in targets,
watchos = KmpTarget.Watchos in targets,
createCommonJsSourceSetIfApplicable = shouldCreateCommonJsSourceSet
createCommonJsSourceSet = shouldCreateCommonJsSourceSet
)
}
}
54 changes: 28 additions & 26 deletions conventions-plugin/src/main/kotlin/kmp.kt
Original file line number Diff line number Diff line change
@@ -21,9 +21,8 @@ fun KotlinMultiplatformExtension.allKmpTargets(
wasmJsNode: Boolean = true,
wasmJsModuleName: String? = null,
binaryType: BinaryType = BinaryType.Library,
createCommonJsSourceSetIfApplicable: Boolean = true,
requireAtLeastOneTarget: Boolean = true,
useDefaultTargetHierarchy: Boolean = true
createCommonJsSourceSet: Boolean = true,
requireAtLeastOneTarget: Boolean = true
) {
kmpTargets(
project = project,
@@ -46,9 +45,8 @@ fun KotlinMultiplatformExtension.allKmpTargets(
wasmJsNode = wasmJsNode,
wasmJsModuleName = wasmJsModuleName,
binaryType = binaryType,
createCommonJsSourceSetIfApplicable = createCommonJsSourceSetIfApplicable,
requireAtLeastOneTarget = requireAtLeastOneTarget,
useDefaultTargetHierarchy = useDefaultTargetHierarchy
createCommonJsSourceSet = createCommonJsSourceSet,
requireAtLeastOneTarget = requireAtLeastOneTarget
)
}

@@ -73,9 +71,8 @@ fun KotlinMultiplatformExtension.kmpTargets(
wasmJsNode: Boolean = true,
wasmJsModuleName: String? = null,
binaryType: BinaryType = BinaryType.Library,
createCommonJsSourceSetIfApplicable: Boolean = true,
requireAtLeastOneTarget: Boolean = true,
useDefaultTargetHierarchy: Boolean = true
createCommonJsSourceSet: Boolean = true,
requireAtLeastOneTarget: Boolean = true
) {
require(project.kotlinToolingVersion.toKotlinVersion().isAtLeast(major = 1, minor = 9, patch = 20)) {
"A minimum Kotlin version of 1.9.20 is required to use kmpTargets"
@@ -90,16 +87,8 @@ fun KotlinMultiplatformExtension.kmpTargets(
}
}

if(useDefaultTargetHierarchy) {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
if(createCommonJsSourceSetIfApplicable) {
group("jsWasm") {
withJs()
withWasm()
}
}
}
if(createCommonJsSourceSet) {
createCommonJs(project)
}

if(android) {
@@ -330,14 +319,27 @@ fun KotlinMultiplatformExtension.kmpTargets(
}
}

if(js && wasmJs) {
project.registerDetektKmpIntermediateTask(
intermediateName = "jsWasm",
targets = listOf(targets.getByName("js"), targets.getByName("wasmJs"))
)
}

if(jvm) {
jvm()
}
}

private fun KotlinMultiplatformExtension.createCommonJs(
project: Project
) {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyDefaultHierarchyTemplate {
group("commonJs") {
withJs()
withWasm()
}
}

sourceSets.register("commonJsMain")
sourceSets.register("commonJsTest")

project.registerDetektKmpIntermediateTask(
intermediateName = "commonJs",
targets = listOfNotNull(targets.findByName("js"), targets.findByName("wasmJs"))
)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2g -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=1024m

group=com.eygraber
version=0.0.58-SNAPSHOT
version=0.0.59-SNAPSHOT

POM_URL=https://github.com/eygraber/gradle-conventions/
POM_SCM_URL=https://github.com/eygraber/gradle-conventions/