diff --git a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangeTrackerPlugin.kt b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangeTrackerPlugin.kt index 03ea86c..7e9e620 100644 --- a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangeTrackerPlugin.kt +++ b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangeTrackerPlugin.kt @@ -14,11 +14,11 @@ class ChangeTrackerPlugin : Plugin { } project.extensions.create(CHANGE_TRACKER_EXTENSION, ChangeTrackerExtension::class.java) - project.evaluationDependsOnChildren() + project.evaluationDependsOnChildrenRecursive() project.afterEvaluate { - project.tasks.create(CHANGED_TRACKER_MODULES_TASK_NAME, ChangedModulesTask::class.java) - configureTasks(project) + it.tasks.create(CHANGED_TRACKER_MODULES_TASK_NAME, ChangedModulesTask::class.java) + configureTasks(it) } } @@ -37,13 +37,19 @@ class ChangeTrackerPlugin : Plugin { private fun getTaskForSubProjects(taskName: String, subProjects: Set): List = subProjects.mapNotNull { subProject -> - subProject.tasks.findByName(taskName)?.apply { - onlyIf { - subProject.rootProject - .getExtraProperty>(CHANGED_TRACKER_OUTPUT) - ?.contains(subProject) - ?: false + val task = subProject.tasks.findByName(taskName) + if (task != null) { + task.apply { + onlyIf { + subProject.rootProject + .getExtraProperty>(CHANGED_TRACKER_OUTPUT) + ?.contains(subProject) + ?: false + } } + } else { + subProject.logger.quiet("ChangeTracker - Task [$taskName] not found for $subProject") + null } } } \ No newline at end of file diff --git a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangedModulesTask.kt b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangedModulesTask.kt index d73ecd3..94945d4 100644 --- a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangedModulesTask.kt +++ b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/ChangedModulesTask.kt @@ -37,14 +37,15 @@ open class ChangedModulesTask : DefaultTask() { result.removeAll(blacklist) result.addAll(whitelist) - project.logger.quiet("Affected modules $result") + project.logger.quiet("Affected projects") + result.forEach { it.logger.quiet(it.toString()) } + rootProject.extensions.extraProperties.set(CHANGED_TRACKER_OUTPUT, result) } private fun getProjectsByName(projectArgs: Set): Set = - projectArgs.let { args -> - rootProject.subprojects - .filter { args.contains(it.path) } - .toSet() - } + rootProject + .subprojects + .filter { projectArgs.contains(it.path) } + .toSet() } \ No newline at end of file diff --git a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/project/ProjectLocator.kt b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/project/ProjectLocator.kt index a6097a8..e478af6 100644 --- a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/project/ProjectLocator.kt +++ b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/project/ProjectLocator.kt @@ -17,7 +17,7 @@ class ProjectLocator(private val rootProject: Project) { rootProject } else { projects.find { (_, projectPaths) -> - (0 until projectPaths.size).all { projectPaths[it] == filePaths[it] } + (projectPaths.indices).all { projectPaths[it] == filePaths[it] } }?.first } } diff --git a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/util/ProjectExtensions.kt b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/util/ProjectExtensions.kt index 6706655..c9d6acc 100644 --- a/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/util/ProjectExtensions.kt +++ b/change_tracker/src/main/kotlin/com/ismaeldivita/changetracker/util/ProjectExtensions.kt @@ -10,3 +10,8 @@ fun Project.getExtraProperty(key: String): T? = extensions.extraProperties[k val Project.changeTrackerExtension: ChangeTrackerExtension get() = extensions.getByName(CHANGE_TRACKER_EXTENSION) as ChangeTrackerExtension + +fun Project.evaluationDependsOnChildrenRecursive() { + subprojects.forEach { it.evaluationDependsOnChildrenRecursive() } + evaluationDependsOnChildren() +} \ No newline at end of file