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

前端 未结 3 1792
野性不改
野性不改 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:51

    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

    0 讨论(0)
  • 2020-12-24 07:55

    Here's some documentation on those:

    • ApplicationVariant:
    • BaseVariant
    • ApkVariant
    0 讨论(0)
  • 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<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')
    
    0 讨论(0)
提交回复
热议问题