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

前端 未结 3 1791
野性不改
野性不改 2020-12-24 07:28

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 applica

3条回答
  •  一生所求
    2020-12-24 07:56

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

提交回复
热议问题