KMMBridgeartifactsCustom Artifact Manager

Custom Artifact Manager

Publishing a Kotlin Xcode dependency requires a place to host the binary. Assuming you need an alternative storage location than one supported by the default implementations, you can implement one yourself.

Create a new implementation of the ArtifactManager interface.

This new ArtifactManager needs to live in one of these locations:

  • In your modules build.gradle.kts file where the KMMBridge block is being called
  • In another module or project that then publishes your code as a buildscript dependency
  • In your buildSrc directory (Note: this isn’t fully tested so we cannot confidently recommend this)

There are two methods to implement:

configure

Optional

fun configure(
        project: Project,
        version: String,
        uploadTask: TaskProvider<Task>,
        kmmPublishTask: TaskProvider<Task>
)

KMMBridge calls this method during Gradle configuration.

  • project (org.gradle.api.Project) - The Gradle project. Can be used to get properties from the project like version or name, and to register tasks.
  • version (String) - The version defined by Gradle. Should be used to define the artifacts version.
  • uploadTask (org.gradle.api.tasks.TaskProvider) - The task for uploading the artifact.
  • kmmPublishTask (org.gradle.api.tasks.TaskProvider) - The task for publishing releases.

The task arguments should be used to establish Gradle dependencies with whatever tasks you might register. For example if you create a new task you may want to have it depend on one of these tasks.

To support Gradle configuration cache, be careful to follow the rules with any tasks you create.

deployArtifact

fun deployArtifact(task: Task, zipFilePath: File, version: String): String

This method should physically send the zip file found at zipFilePath to your storage location.

  • task (org.gradle.api.Task)- The KMMBridge task that calls this method. It is generally used for things like Gradle logging.
  • zipFilePath (java.io.File) - The location of the zip file that should be uploaded to your storage location
  • version (String) - The version defined by Gradle. Should be used to define the artifacts version.

The return value is the URL at which the file can be accessed. Authentication that may be needed by clients to access this URL is configured externally.

deployArtifact is called from an executing Gradle task. To support Gradle configuration cache, again, follow the rules.