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

com.mobgen.halo.android.plugin.sdk.utils.Utils.groovy Maven / Gradle / Ivy

There is a newer version: 2.9.3
Show newest version
package com.mobgen.halo.android.plugin.sdk.utils
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
import com.android.build.gradle.api.BaseVariant
import org.gradle.api.Project
/**
 * Helper class that performs some operations related to android.
 */
public class Utils {

    static def isAndroidPlugin(Project project){
        def isAndroidApp = project.plugins.withType(AppPlugin)
        def isAndroidLibrary = project.plugins.withType(LibraryPlugin)

        // Check that this plugin is being applied on an Android application or library
        return isAndroidApp || isAndroidLibrary
    }

    static def getVariants(Project project){
        if(project.plugins.withType(AppPlugin)){
            return project.android.applicationVariants
        }else if(project.plugins.withType(LibraryPlugin)){
            return project.android.libraryVariants
        }
        return null
    }

    static def buildVariantPath(BaseVariant variant) {
        StringBuilder builder = new StringBuilder()
        if(variant.getFlavorName() != null){
            builder.append("/${variant.getFlavorName()}")
        }
        builder.append("/${variant.getBuildType().getName()}")
        return builder.toString()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy