I am learning gradle from the gradle official website:
https://docs.gradle.org/current/userguide/declaring_dependencies_between_subprojects.html
Here, in one of the example, it has a file in buildSrc folder-
buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kts
plugins {
id("java")
}
group = "com.example"
version = "1.0"
repositories {
mavenCentral()
}
dependencies {
testImplementation("junit:junit:4.13")
}
The structure of the project is:
.
├── buildSrc
│ ...
├── api
│ ├── src
│ │ └──...
│ └── build.gradle.kts
├── services
│ └── person-service
│ ├── src
│ │ └──...
│ └── build.gradle.kts
├── shared
│ ├── src
│ │ └──...
│ └── build.gradle.kts
└── settings.gradle.kts
The module build scripts api/build.gradle.kts and shared/build.gradle.kts are using the plugin 'myproject.java-conventions' as:
plugins {
id("myproject.java-conventions")
}
I referred the below about how to create custom plugins.
I am confused about how just having a .gradle or .gradle.kts file in buildSrc is a plugin that projects are able to use. And, if so, why are they not using that as:
apply plugin: myproject.java-conventions
What is the difference then in apply plugin apply plugin: myproject.java-conventions
and
plugins {
id("myproject.java-conventions")
}