Explain new format of top level gradle file

Viewed 312

Few days ago I have update my android studio to new version (Bumblebee) after that I create new project and see top leve gradle file totally changed and I don't understand new format.

plugins {
    id 'com.android.application' version '7.1.1' apply false
    id 'com.android.library' version '7.1.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

can anyone explain me what is mean of apply false here

and also how I can add

repositories {
    maven { url 'https://jitpack.io' }
}

in top level gradle according to new format

1 Answers

build.gradle

plugins {
  1.  `«plugin id»`                                             
  2.   id(«plugin id»)                                           
  3.   id(«plugin id») version «plugin version» [apply «false»]   
}
  1. for core Gradle plugins
  2. for core Gradle plugins or plugins already available to the build script
  3. for binary Gradle plugins that need to be resolved

Where «plugin id», in case #1 is a static Kotlin extension property, named after the core plugin ID ; and in cases #2 and #3 is a string. «plugin version» is also a string. The apply statement with a boolean can be used to disable the default behavior of applying the plugin immediately (e.g. you want to apply it only in subprojects).

And You have to add repositories inside pluginManagement in setting.gradle

Example :

pluginManagement {
    repositories {
        maven(url = "./maven-repo")
        gradlePluginPortal()
        ivy(url = "./ivy-repo")
    }
}

You can refer here for more info

Related