Gradle

apply plugin: vs plugins

In gradle, sometimes you see both:

plugins {  
    id 'java'  
    id 'org.springframework.boot' version '3.2.3'  
    ...
}  

and

apply plugin: 'io.spring.dependency-management'

They're basically the same thing with plugins {} is a newer syntax.

So in theory, you can just do:

plugins {  
    id 'java'  
    id 'org.springframework.boot' version '3.2.3'  
    id 'io.spring.dependency-management' version '1.1.4'  
}

Plugins vs Dependency

In gradle, there are sometimes plugins { } and dependencies { }

Plugins:

  • Plugins is for you to build your app, it's normally, extra tasks that gradle can use.
  • Normally is for larger scope of development, like java, kotlin, springboot

Dependencies:

  • Dependencies are what compiled with your code to run your application

The buildscript block

Build script is what happening during the process of gradle build. In here, we can use classpath: to specify some extra dependency for our gradle build process.

Example:

buildscript {
    repositories {
        mavenCentral() // Specify the repository for resolving dependencies
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
        // Add other classpath dependencies as needed
    }
}