android - what is the purpose of the init.gradle file -


can explain meaning of purpose of init.gradle file seems duplicating code me:

  buildscript {     repositories {         maven {             url "https://someenterpriseurl"         }     } }  allprojects {     repositories {         maven {             url "https://someenterpriseurl"         }     } } 

the reason confusion in projects build.gradle file defined this:

    buildscript {     repositories {         maven {             url "https://someenterpriseurl"         }     }     dependencies {         classpath 'com.android.tools.build:gradle:1.1.1'      } }  allprojects {     repositories {         maven {             url "https://someenterpriseurl"         }     } } 

so why have defined in init.gradle file ? how developers have init.gradle file when im defining same thing in build.gradle file?

your build.gradle files per-project , per-module. init.gradle files set on per user basis (in ~/.gradle or in gradle's home directory local gradle installations). expect see init.gradle files used more commonly in large organizations, trying standardize gradle build policies across multiple projects , development teams.

quoting the gradle documentation:

here several possible uses:

  • set enterprise-wide configuration, such find custom plugins.

  • set properties based on current environment, such developer's machine vs. continuous integration server.

  • supply personal information user required build, such repository or database authentication credentials.

  • define machine specific details, such jdks installed.

  • register build listeners. external tools wish listen gradle events might find useful.

  • register build loggers. might wish customize how gradle logs events generates.


Comments