All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.prof18.kmpframeworkbundler.KMPFrameworkBundlerExtension.kt Maven / Gradle / Ivy

Go to download

Gradle plugin to manage the distribution via CocoaPod of a Kotlin Multiplatform library for Apple platforms with a XCFramework or a FatFramework

There is a newer version: 0.0.16
Show newest version
package com.prof18.kmpframeworkbundler

import com.prof18.kmpframeworkbundler.data.ErrorMessages
import com.prof18.kmpframeworkbundler.data.FrameworkType
import org.gradle.api.Action
import org.gradle.api.DefaultTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.model.ObjectFactory
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import javax.inject.Inject
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Nested
import org.gradle.kotlin.dsl.property

internal const val KMP_FRAMEWORK_BUNDLER_EXTENSION = "frameworkBundlerConfig"

abstract class KMPFrameworkBundlerExtension @Inject constructor(
    objects: ObjectFactory,
) {

    val frameworkName: Property = objects.property()
    val outputPath: Property = objects.property()
    val versionName: Property = objects.property()
    var frameworkType: FrameworkType = FrameworkType.XC_FRAMEWORK

    @get:Nested
    abstract val cocoaPodRepoInfo: CocoaPodRepoDSL

    // Internal variables
    internal val debugFrameworkList: MutableList = mutableListOf()
    internal val releaseFrameworkList: MutableList = mutableListOf()
    internal val xcFrameworkTasks: MutableList = mutableListOf()

    @Suppress("Unused") // Used by the external world
    fun cocoaPodRepoInfo(action: Action) {
        action.execute(cocoaPodRepoInfo)
    }

    internal fun validateUserInput() {
        if (!frameworkName.isPresent) {
            throw InvalidUserDataException(ErrorMessages.FRAMEWORK_NAME_NOT_PRESENT_MESSAGE)
        }
        if (!outputPath.isPresent) {
            throw InvalidUserDataException(ErrorMessages.OUTPUT_PATH_NOT_PRESENT_MESSAGE)
        }
        if (!versionName.isPresent) {
            throw InvalidUserDataException(ErrorMessages.VERSION_NAME_NOT_PRESENT_MESSAGE)
        }
    }
}

abstract class CocoaPodRepoDSL {
    abstract val summary: Property
    abstract val homepage: Property
    abstract val license: Property
    abstract val authors: Property
    abstract val gitUrl: Property
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy