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.6.1
Show newest version
// Copyright (c) 2024. Tony Robalik.
// SPDX-License-Identifier: Apache-2.0
package com.autonomousapps

import com.autonomousapps.extension.AbiHandler
import com.autonomousapps.extension.DependenciesHandler
import com.autonomousapps.extension.ProjectIssueHandler
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.kotlin.dsl.create
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 { ... }
 *   }
 * }
 * ```
 */
abstract class DependencyAnalysisSubExtension(
  project: Project,
) : AbstractExtension(project.objects, project.gradle) {

  private val path = project.path

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

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

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

  internal companion object {
    fun of(project: Project): DependencyAnalysisSubExtension {
      return project.extensions.create(NAME, project)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy