All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.autonomousapps.BuildHealthPlugin.kt Maven / Gradle / Ivy

There is a newer version: 2.6.1
Show newest version
package com.autonomousapps

import com.autonomousapps.internal.GradleVersions
import com.autonomousapps.services.GlobalDslService
import com.autonomousapps.subplugin.DEPENDENCY_ANALYSIS_PLUGIN
import org.gradle.api.Plugin
import org.gradle.api.initialization.Settings

/**
 * ```
 * // settings.gradle[.kts]
 * plugins {
 *   id("com.autonomousapps.build-health") version <>
 * }
 * ```
 */
abstract class BuildHealthPlugin : Plugin {

  internal companion object {
    const val ID = "com.autonomousapps.build-health"
  }

  override fun apply(target: Settings): Unit = target.run {
    if (!GradleVersions.isAtLeastGradle88) {
      error("'$ID' requires Gradle 8.8 or higher.")
    }

    // Create extension
    DependencyAnalysisExtension.of(this)

    // Register service
    GlobalDslService.of(target.gradle).apply {
      get().apply {
        setRegisteredOnSettings()
      }
    }

    gradle.lifecycle.beforeProject {
      pluginManager.apply(DEPENDENCY_ANALYSIS_PLUGIN)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy