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

com.avito.android.CodeOwnershipPlugin.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

There is a newer version: 2024.32
Show newest version
@file:Suppress("deprecation")
package com.avito.android

import com.avito.kotlin.dsl.getBooleanProperty
import com.avito.kotlin.dsl.isRoot
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.register

public class CodeOwnershipPlugin : Plugin {

    override fun apply(target: Project) {
        check(target.isRoot()) { "Code ownership plugin must be applied to the root project" }

        val strictOwnership = target.getBooleanProperty("avito.ownership.strictOwnership", false)

        target.subprojects { subproject ->
            subproject.plugins.withId("kotlin") {
                setupLibrary(subproject, strictOwnership)
            }
            subproject.plugins.withId("com.android.library") {
                setupLibrary(subproject, strictOwnership)
            }
            subproject.plugins.withId("com.android.application") {
                setupLibrary(subproject, strictOwnership)
            }
        }

        target.tasks.register("exportCodeOwnershipInfo") {
            group = "documentation"
            description = "Exports code ownership info for all the modules to CSV file"
        }
    }

    private fun setupLibrary(project: Project, strictOwnership: Boolean) {
        val codeOwnershipExtension = project.extensions.create("ownership")

        project.afterEvaluate {
            if (strictOwnership) {
                codeOwnershipExtension.checkProjectOwnershipSettings(it.path)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy