fix(gradle): only allow Spotless plugin to be applied to the root project

This commit is contained in:
Harsh Shandilya 2022-10-26 01:30:33 +05:30
parent a1390a0f05
commit 720f946f41
No known key found for this signature in database
1 changed files with 4 additions and 0 deletions

View File

@ -7,6 +7,7 @@ package dev.msfjarvis.aps.gradle
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
@ -16,6 +17,9 @@ import org.gradle.kotlin.dsl.getByType
class SpotlessPlugin : Plugin<Project> {
override fun apply(project: Project) {
if (project.rootProject != project) {
throw GradleException("Spotless plugin must only be applied to the root project.")
}
project.pluginManager.apply(SpotlessPlugin::class)
project.extensions.getByType<SpotlessExtension>().run {
kotlin {