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

com.avito.plugin.QAppsPlugin.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

The newest version!
package com.avito.plugin

import com.avito.android.signer.SignServicePlugin
import com.avito.android.signer.signedApkDir
import com.avito.android.withAndroidApp
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.register

public class QAppsPlugin : Plugin {

    override fun apply(project: Project) {

        val extension = project.extensions.create("qapps")

        project.withAndroidApp { appExtension ->
            appExtension.applicationVariants.all { variant ->

                project.tasks.register(
                    qappsUploadUnsignedTaskName(variant.name),
                ) {
                    description = "Upload unsigned ${variant.name} to qapps"
                    configure(extension, variant)

                    val packageTaskProvider = variant.packageApplicationProvider

                    val apkProvider = packageTaskProvider.flatMap { it.outputDirectory }

                    apkDirectory.set(apkProvider)

                    // todo remove, somehow implicit dependency not working
                    dependsOn(packageTaskProvider)
                }

                if (project.plugins.hasPlugin(SignServicePlugin::class.java)) {

                    val signedApkDir = project.tasks.signedApkDir(variant.name)

                    if (signedApkDir.isPresent) {
                        project.tasks.register(
                            qappsUploadSignedTaskName(variant.name),
                        ) {
                            description = "Upload signed ${variant.name} to qapps"
                            configure(extension, variant)
                            apkDirectory.set(signedApkDir)
                        }
                    }
                }
            }
        }
    }

    // todo use new AGP API
    private fun QAppsUploadTask.configure(
        extension: QAppsExtension,
        @Suppress("DEPRECATION") variant: com.android.build.gradle.api.ApplicationVariant
    ) {
        group = "ci"

        variantName.set(variant.name)
        versionName.set(variant.versionName)
        versionCode.set(variant.versionCode.toString())
        packageName.set(variant.applicationId)
        host.set(extension.serviceUrl)
        comment.set(extension.comment)
        branch.set(extension.branchName)
        releaseBuildVariants.set(extension.releaseBuildVariants)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy