Skip to content

Commit f0a1dba

Browse files
authored
Avoid eager getByName in pom validation plugin (opensearch-project#19974)
The `getByName()` call is eager, which means this can fail non-deterministically if the dependent gradle tasks have not yet been configured. I ran into this error when doing other gradle refactorings. This change avoids the eager call while also avoiding the nested publications.all() call. Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent 2fddcd8 commit f0a1dba

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

buildSrc/src/main/java/org/opensearch/gradle/precommit/PomValidationPrecommitPlugin.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ public TaskProvider<? extends Task> createTask(Project project) {
5959
validateTask.configure(task -> {
6060
task.dependsOn(generateMavenPom);
6161
task.getPomFile().fileProvider(generateMavenPom.map(GenerateMavenPom::getDestination));
62-
publishing.getPublications().all(publicationForPomGen -> {
63-
task.mustRunAfter(
64-
project.getTasks()
65-
.withType(GenerateMavenPom.class)
66-
.getByName("generatePomFileFor" + Util.capitalize(publicationForPomGen.getName()) + "Publication")
67-
);
68-
});
62+
// Force the validate to run after all generate tasks since they overwrite the same POM file
63+
task.mustRunAfter(project.getTasks().withType(GenerateMavenPom.class));
6964
});
7065
});
7166

0 commit comments

Comments
 (0)