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

Fixing Gradle warnings associated with publishPluginZipPublicationToXxx tasks #4696

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix flaky DecommissionControllerTests.testTimesOut ([4683](https://github.com/opensearch-project/OpenSearch/pull/4683))
- Fix new race condition in DecommissionControllerTests ([4688](https://github.com/opensearch-project/OpenSearch/pull/4688))
- Fix SearchStats (de)serialization (caused by https://github.com/opensearch-project/OpenSearch/pull/4616) ([#4697](https://github.com/opensearch-project/OpenSearch/pull/4697))
- Fixing Gradle warnings associated with publishPluginZipPublicationToXxx tasks ([#4696](https://github.com/opensearch-project/OpenSearch/pull/4696))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public String call() throws Exception {
return String.format(
"%s/distributions/%s-%s.pom",
project.getBuildDir(),
getArchivesBaseName(project),
pomTask.getName().toLowerCase().contains("zip") ? project.getName() : getArchivesBaseName(project),
Copy link
Collaborator Author

@reta reta Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out to be a tricky one: we introduced wrong task for ZIP plugin publication, see https://github.com/opensearch-project/OpenSearch/pull/4696/files#diff-204511a3817dea7312e96afb8aa664eafe003b512a0ac979f4a383b03fbd93c1R134 where the JAR artifact name is being set (but for ZIP artifact, is it project.getName())

Because of that the implicit dependency between publishNebulaPublicationToMavenLocal and generatePomFileForPluginZipPublication was established but it should not ( publishNebulaPublicationToMavenLocal is JAR artifact, not ZIP).

prudhvigodithi marked this conversation as resolved.
Show resolved Hide resolved
project.getVersion()
);
}
Expand Down Expand Up @@ -130,7 +130,6 @@ public String call() throws Exception {
publication.getPom().withXml(PublishPlugin::addScmInfo);

if (!publication.getName().toLowerCase().contains("zip")) {

// have to defer this until archivesBaseName is set
project.afterEvaluate(p -> publication.setArtifactId(getArchivesBaseName(project)));

Expand All @@ -139,6 +138,8 @@ public String call() throws Exception {
publication.artifact(project.getTasks().getByName("sourcesJar"));
publication.artifact(project.getTasks().getByName("javadocJar"));
}
} else {
project.afterEvaluate(p -> publication.setArtifactId(project.getName()));
}

generatePomTask.configure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.gradle.api.publish.maven.MavenPublication;

import java.nio.file.Path;
import java.util.Set;
import java.util.stream.Collectors;

import org.gradle.api.Task;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;

public class Publish implements Plugin<Project> {

// public final static String PLUGIN_ZIP_PUBLISH_POM_TASK = "generatePomFileForPluginZipPublication";
public final static String PUBLICATION_NAME = "pluginZip";
public final static String STAGING_REPO = "zipStaging";
public final static String LOCAL_STAGING_REPO_PATH = "/build/local-staging-repo";
Expand Down Expand Up @@ -67,10 +69,15 @@ public void apply(Project project) {
if (validatePluginZipPom != null) {
validatePluginZipPom.dependsOn("generatePomFileForNebulaPublication");
}
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks()
.findByName("publishPluginZipPublicationToZipStagingRepository");
if (publishPluginZipPublicationToZipStagingRepository != null) {
publishPluginZipPublicationToZipStagingRepository.dependsOn("generatePomFileForNebulaPublication");

// There are number of tasks prefixed by 'publishPluginZipPublication', f.e.:
// publishPluginZipPublicationToZipStagingRepository, publishPluginZipPublicationToMavenLocal
final Set<Task> publishPluginZipPublicationToTasks = project.getTasks()
.stream()
.filter(t -> t.getName().startsWith("publishPluginZipPublicationTo"))
.collect(Collectors.toSet());
if (!publishPluginZipPublicationToTasks.isEmpty()) {
publishPluginZipPublicationToTasks.forEach(t -> t.dependsOn("generatePomFileForNebulaPublication"));
}
} else {
project.getLogger()
Expand Down