我如何知道android gradle插件的applicationVariants属性? [英] How do I know the properties in applicationVariants of android gradle plugin?

查看:3607
本文介绍了我如何知道android gradle插件的applicationVariants属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Android Studio和gradle插件来开发应用程序。我在 DSL参考资料上了解了一些android gradle插件的用法。但我发现的一件事是applicationVariants在doc上的一部分很难理解。它只给出了这样的描述:

I'm using Android Studio with gradle plugin to develop applications. I learn some usage of android gradle plugin on DSL Reference. But one thing I found is that the applicationVariants part on doc is hard to understand. It only gives such a description:


DomainObjectSet< ApplicationVariant> applicationVariants

DomainObjectSet<ApplicationVariant> applicationVariants

应用程序变体列表。由于集合是在评估之后构建的,因此它应该与Gradle的所有迭代器一起用于处理将来的项目。

The list of Application variants. Since the collections is built after evaluation, it should be used with Gradle's all iterator to process future items.

但是,什么是属性ApplicationVariant?我不知道。我发现没有任何引用链接来描述ApplicationVariant。

But what's the properties in the ApplicationVariant? I don't know. And I found nothing reference link to describe the ApplicationVariant.

只有在 Gradle插件用户指南。它记录了applicationVariants,libraryVariants和testVariants中的可用属性。但是我发现其中很多属性已被弃用了很长时间,并且Android没有更新此页面。

Only in the Gradle Plugin User Guide at the very bottom of the page. It documents the available properties in applicationVariants, libraryVariants and testVariants. But I found quite some of these properties are deprecated for a long time, and Android didn't update this page.

那么我在哪里可以找到ApplicationVariant中最新的属性?

So where do I find the most updated properties in ApplicationVariant?

推荐答案

https://android.googlesource.com/platform/tools/build/+/8dca86a/gradle /src/main/groovy/com/android/build/gradle/internal/ApplicationVariant.groovy

我也很难找到它。下面是它移动的界面:
它也会有你定义的任何道具,比如versionName,applicationId等。

I had a hard time finding it too. Here's the interface incase it moves: It will also have any props you define in your flavor, like the versionName, applicationId etc

public interface ApplicationVariant {
    String getName()
    String getDescription()
    String getDirName()
    String getBaseName()
    VariantConfiguration getConfig()
    boolean getZipAlign()
    boolean isSigned()
    boolean getRunProguard()
    FileCollection getRuntimeClasspath()
    FileCollection getResourcePackage()
    Compile getCompileTask()
    List<String> getRunCommand()
    String getPackage()
    AndroidBuilder createBuilder(AndroidBasePlugin androidBasePlugin)
}

并打印任何对象的道具:

And to print the props of any object:

def filtered = ['class', 'active']

println theObject.properties
            .sort{it.key}
            .collect{it}
            .findAll{!filtered.contains(it.key)}
            .join('\n')

这篇关于我如何知道android gradle插件的applicationVariants属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆