How do I know the properties in applicationVariants of android gradle plugin?

。_饼干妹妹 提交于 2019-11-30 01:59:24

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

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')

The link in @CaptRespect's answer is to a specific build. Here are the links to the public API in the master branch:

/gradle/api/ApplicationVariant.java
(derives from) /gradle/api/ApkVariant.java
(derives from) /gradle/api/BaseVariant.java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!