Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attached "dependencyGuard" to the "check" task. Fixes #30 #34

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@ dependencyGuard {
it.tree = true
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.dropbox.gradle.plugins.dependencyguard

import com.dropbox.gradle.plugins.dependencyguard.internal.DependencyTreeDiffTaskNames
import com.dropbox.gradle.plugins.dependencyguard.internal.isRootProject
import com.dropbox.gradle.plugins.dependencyguard.internal.list.DependencyGuardListTask
import com.dropbox.gradle.plugins.dependencyguard.internal.tree.BuildEnvironmentDependencyTreeDiffTask
import com.dropbox.gradle.plugins.dependencyguard.internal.tree.DependencyTreeDiffTask
import com.dropbox.gradle.plugins.dependencyguard.internal.isRootProject
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.gradle.language.base.plugins.LifecycleBasePlugin

/**
* A plugin for watching dependency changes
Expand All @@ -29,16 +30,31 @@ public class DependencyGuardPlugin : Plugin<Project> {
target.objects
)

val baselineTask = registerDependencyGuardBaselineTask(target, extension)
val guardTask = registerDependencyGuardTask(target, extension)
val dependencyGuardBaselineTask = registerDependencyGuardBaselineTask(target, extension)
val dependencyGuardTask = registerDependencyGuardTask(target, extension)
registerTreeDiffTasks(
target = target,
extension = extension,
baselineTask = baselineTask,
guardTask = guardTask
baselineTask = dependencyGuardBaselineTask,
guardTask = dependencyGuardTask
)

attachToCheckTask(
target = target,
dependencyGuardTask = dependencyGuardTask
)
}

private fun attachToCheckTask(target: Project, dependencyGuardTask: TaskProvider<DependencyGuardListTask>) {
// Required to add the "check" lifecycle task
target.plugins.apply(LifecycleBasePlugin::class.java)

// Attach the "dependencyGuard" task to the "check" lifecycle task
target.tasks.named(LifecycleBasePlugin.CHECK_TASK_NAME).configure {
this.dependsOn(dependencyGuardTask)
}
}

private fun registerDependencyGuardBaselineTask(
target: Project,
extension: DependencyGuardPluginExtension
Expand Down