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

com.javiersc.gradle.plugins.all.projects.AllProjectsExtension.kt Maven / Gradle / Ivy

There is a newer version: 0.1.0-rc.45
Show newest version
package com.javiersc.gradle.plugins.all.projects

import com.javiersc.gradle.plugins.all.projects.install.InstallOptions
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.property

open class AllProjectsExtension(project: Project) {

    fun install(action: Action) = action.execute(install.get())

    val install: Property =
        project
            .objects
            .property()
            .value(project.objects.newInstance(InstallOptions::class.java))

    companion object {
        const val name: String = "allProjectsConfig"

        internal fun createExtension(project: Project) =
            project.extensions.create(name, project)
    }
}

internal val Project.allProjectsExtension: AllProjectsExtension
    get() =
        checkNotNull(extensions.findByType(AllProjectsExtension::class)) {
            "`all-projects` plugin is not correctly applied"
        }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy