Skip to content

Commit

Permalink
Fixing Gradle warnings associated with publishPluginZipPublicationToX…
Browse files Browse the repository at this point in the history
…xx tasks (opensearch-project#4696)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta authored and ashking94 committed Nov 7, 2022
1 parent 0dff037 commit 5d3663f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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),
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

0 comments on commit 5d3663f

Please sign in to comment.