Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/publish-on-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,29 @@ jobs:

publish:
needs: build-natives
runs-on: ubuntu-latest
# MUST stay on macOS: iosArm64 / iosSimulatorArm64 are disabled on any other
# host, and Kotlin then writes the root module metadata with Gradle-default
# coordinates for them (`composewebview:webview-compose-iosarm64:unspecified`),
# which makes the release unresolvable for iOS consumers (issue #51).
# :webview-compose:verifyPublicationCoordinates guards against a regression.
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Select Xcode 26+ (Compose 1.11 needs iOS 26 SDK)
run: |
# Same selection as the iOS jobs in pr-build-check.yml.
XCODE=$(ls -d /Applications/Xcode_26*.app 2>/dev/null | sort -V | tail -1 || true)
if [ -z "$XCODE" ]; then
XCODE=$(ls -d /Applications/Xcode_16*.app 2>/dev/null | sort -V | tail -1 || true)
fi
if [ -n "$XCODE" ]; then
echo "Using $XCODE"
sudo xcode-select -s "$XCODE"
fi
xcodebuild -version

- name: Download native artifacts
uses: actions/download-artifact@v4
with:
Expand Down
53 changes: 53 additions & 0 deletions webview-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:OptIn(ExperimentalWasmDsl::class)

import com.vanniktech.maven.publish.KotlinMultiplatform
import groovy.json.JsonSlurper
import org.apache.tools.ant.taskdefs.condition.Os
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

Expand Down Expand Up @@ -208,3 +209,55 @@ mavenPublishing {
description.set("Compose Multiplatform WebView library for Desktop, Android and iOS")
}
}

// The root KMP module metadata redirects every target variant to a sibling module
// through an `available-at` entry. Targets that are disabled on the publishing host
// (Apple targets anywhere but macOS) keep Gradle's default project coordinates, so
// the release ships pointing at `composewebview:webview-compose-iosarm64:unspecified`
// and no iOS consumer can resolve it (issue #51). Fail the publish instead.
val verifyPublicationCoordinates by tasks.registering {
description = "Checks that the KMP root module metadata only points at modules being published"
group = "verification"

val metadataFile = tasks.named<GenerateModuleMetadata>(
"generateMetadataFileForKotlinMultiplatformPublication"
).flatMap { it.outputFile }

inputs.file(metadataFile)

doLast {
@Suppress("UNCHECKED_CAST")
val root = JsonSlurper().parse(metadataFile.get().asFile) as Map<String, Any>

@Suppress("UNCHECKED_CAST")
val component = root["component"] as Map<String, Any>
val group = component["group"]
val version = component["version"]

@Suppress("UNCHECKED_CAST")
val variants = root["variants"] as? List<Map<String, Any>> ?: emptyList()
val dangling = variants.mapNotNull { variant ->
@Suppress("UNCHECKED_CAST")
val at = variant["available-at"] as? Map<String, Any> ?: return@mapNotNull null
if (at["group"] == group && at["version"] == version) return@mapNotNull null
"${variant["name"]} -> ${at["group"]}:${at["module"]}:${at["version"]}"
}

check(dangling.isEmpty()) {
buildString {
appendLine("Root module metadata points at modules outside this publication:")
dangling.forEach { appendLine(" $it") }
appendLine("Expected $group:*:$version.")
append(
"Publish from a host that can build every declared target " +
"(macOS is required for the iOS targets)."
)
}
}
logger.lifecycle("Publication coordinates OK: ${variants.size} variants under $group:*:$version")
}
}

tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(verifyPublicationCoordinates)
}
Loading