Search Gradle plugins

Using the plugins DSL:

plugins {
  id("com.diffplug.gradle.spotless") version "4.2.1"
}

Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("com.diffplug.spotless:spotless-plugin-gradle:4.2.1")
  }
}

apply(plugin = "com.diffplug.gradle.spotless")

Using the plugins DSL:

plugins {
  id "com.diffplug.gradle.spotless" version "4.2.1"
}

Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "com.diffplug.spotless:spotless-plugin-gradle:4.2.1"
  }
}

apply plugin: "com.diffplug.gradle.spotless"

Learn how to apply plugins to subprojects