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

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

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

import com.autonomousapps.extension.AbiHandler
import com.autonomousapps.extension.DependenciesHandler
import com.autonomousapps.extension.IssueHandler
import com.autonomousapps.extension.ProjectIssueHandler
import org.gradle.api.Action
import org.gradle.api.model.ObjectFactory
import javax.naming.OperationNotSupportedException

/**
 * See also [ProjectIssueHandler]. Note that this differs from [DependencyAnalysisExtension], in that you cannot specify
 * the project being configured, as it is _this_ project being configured.
 *
 * ```
 * dependencyAnalysis {
 *   // Configure the severity of issues, and exclusion rules, for this project.
 *   issues {
 *     ignoreKtx()
 *     onAny { ... }
 *     onUnusedDependencies { ... }
 *     onUsedTransitiveDependencies { ... }
 *     onIncorrectConfiguration { ... }
 *     onCompileOnly { ... }
 *     onUnusedAnnotationProcessors { ... }
 *     onRedundantPlugins { ... }
 *   }
 * }
 * ```
 */
open class DependencyAnalysisSubExtension(
  objects: ObjectFactory,
  private val rootExtProvider: () -> DependencyAnalysisExtension,
  private val path: String
) : AbstractExtension(objects) {

  override val issueHandler: IssueHandler by lazy {
    rootExtProvider().issueHandler
  }

  override val abiHandler: AbiHandler by lazy {
    rootExtProvider().abiHandler
  }

  fun issues(action: Action) {
    issueHandler.project(path, action)
  }

  fun abi(action: Action) {
    action.execute(abiHandler)
  }

  @Suppress("UNUSED_PARAMETER")
  fun dependencies(action: Action) {
    throw OperationNotSupportedException("Dependency bundles must be declared in the root project only")
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy