From 35abf152092ae7a3614050ecd890904af0c34b77 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Mon, 25 Nov 2024 08:27:58 +0100 Subject: [PATCH] WIP 314 Fix Maven dependency on other modules We must ensure that other modules from the Gradle tree are not only built but also published to some internal repository. The Maven based Plugin descriptor (and the helper descriptor) needs to include all (transitive) dependencies of the Mojo. --- htmlSanityCheck-maven-plugin/build.gradle | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/htmlSanityCheck-maven-plugin/build.gradle b/htmlSanityCheck-maven-plugin/build.gradle index 1e942fcb..d548397c 100644 --- a/htmlSanityCheck-maven-plugin/build.gradle +++ b/htmlSanityCheck-maven-plugin/build.gradle @@ -71,16 +71,18 @@ class CrossPlatformExec extends Exec { // This ensures that other HSC modules are published to ../build/maven-repo already (in particular core) generateMavenPlugin.configure { - List thisProjectsPublishTasks = getTasks().withType(PublishToMavenLocal).stream().collect(Collectors.toList()) - mustRunAfter(rootProject.getAllTasks(true).values().stream() - .flatMap(Set::stream) - .filter(task -> task instanceof PublishToMavenLocal) - .filter(task -> !thisProjectsPublishTasks.contains(task)) - .collect(Collectors.toList()) + dependsOn( + project.configurations.implementation.dependencies.withType(ProjectDependency).collect { dep -> + project.rootProject.findProject(dep.dependencyProject.path).tasks + }.flatten().stream() + .filter(task -> { + logger.debug("Checking '${task.name}' of '${task.project}' with class '${task.class}'") + task.name == 'publishMavenJavaPublicationToMyLocalRepositoryForFullIntegrationTestsRepository' + }) + .collect(Collectors.toList()) ) onlyIf { - logger.debug("TaskGraph at generateMavenPlugin: " + gradle.taskGraph.getAllTasks().stream().map(Task::getName).collect(Collectors.toList())) - gradle.taskGraph.getAllTasks().stream().anyMatch(thisProjectsPublishTasks::contains) + gradle.taskGraph.getAllTasks().stream().anyMatch { task -> task.name == 'jar' } } }