Skip to content

Commit 01d9c0d

Browse files
committed
Add check to see if task exists on project before adding dependency
1 parent 6f5e662 commit 01d9c0d

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorPlugin.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,12 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
171171

172172
project.pluginManager.withPlugin(pluginId) {
173173
getAffectedPath(testType, project)?.let { path ->
174-
if (AffectedModuleDetector.isProjectProvided(project) && !isExcludedModule(config, path)) {
174+
val pathOrNull = project.tasks.findByPath(path)
175+
if (AffectedModuleDetector.isProjectProvided(project) && !isExcludedModule(config, path) && pathOrNull != null) {
175176
task.dependsOn(path)
176177
}
177178

178-
project.tasks.findByPath(path)?.onlyIf { task ->
179+
pathOrNull?.onlyIf { task ->
179180
when {
180181
!AffectedModuleDetector.isProjectEnabled(task.project) -> true
181182
else -> AffectedModuleDetector.isProjectAffected(task.project)

sample/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ buildscript {
1919
}
2020
}
2121

22-
plugins {
23-
id("io.gitlab.arturbosch.detekt") version "1.20.0"
24-
}
25-
2622
apply plugin: "org.jlleitschuh.gradle.ktlint"
2723
apply plugin: "com.dropbox.affectedmoduledetector"
2824

@@ -47,8 +43,6 @@ affectedModuleDetector {
4743
}
4844

4945
allprojects {
50-
apply plugin: Dependencies.Libs.DETEKT_PLUGIN
51-
5246
repositories {
5347
google()
5448
mavenCentral()

sample/sample-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import com.dropbox.sample.Dependencies
33
plugins {
44
id 'com.android.library'
55
id 'kotlin-android'
6+
id("io.gitlab.arturbosch.detekt") version "1.20.0"
67
}
78

89
affectedTestConfiguration {

0 commit comments

Comments
 (0)