Skip to content

Commit

Permalink
feat: Apply version-catalog-extensions plugin to all projects
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Oct 6, 2022
1 parent 0d7881d commit 4ee0e94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
`maven-publish`
id("com.redmadrobot.publish-config") version "0.17"
id("com.redmadrobot.publish") version "0.17" apply false
id("com.redmadrobot.version-catalog-extensions") version "0.1" apply false
}

repositories {
Expand Down Expand Up @@ -36,6 +37,7 @@ subprojects {
apply {
plugin("org.gradle.version-catalog")
plugin("com.redmadrobot.publish")
plugin("com.redmadrobot.version-catalog-extensions")
}

group = "com.redmadrobot.versions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ package com.redmadrobot.gradle.catalog

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.catalog.VersionCatalogPlugin.GENERATE_CATALOG_FILE_TASKNAME
import org.gradle.api.plugins.catalog.internal.CatalogExtensionInternal
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.register
import org.gradle.language.base.plugins.LifecycleBasePlugin.CHECK_TASK_NAME

class VersionCatalogExtensionsPlugin : Plugin<Project> {

override fun apply(target: Project) = with(target) {
if (!plugins.hasPlugin("org.gradle.version-catalog")) {
logger.warn(
"""
Can not apply plugin com.redmadrobot.version-catalog-extensions:
Plugin org.gradle.version-catalog not found but it is required
""".trimIndent()
)
return@with
}
apply<BasePlugin>()

val extension = extensions.getByName<CatalogExtensionInternal>("catalog")
val validateCatalog = tasks.register<ValidateVersionCatalogTask>(VALIDATE_CATALOG_TASK_NAME) {
dependenciesModel.set(extension.versionCatalog)
Expand Down

0 comments on commit 4ee0e94

Please sign in to comment.