Skip to content

Commit

Permalink
Fix Shadow JAR dependency publication
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Nov 28, 2023
1 parent c4e703f commit edfe896
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Delegating CachingWeightWrapper#count to internal weight object ([#10543](https://github.com/opensearch-project/OpenSearch/pull/10543))
- Fix per request latency last phase not tracked ([#10934](https://github.com/opensearch-project/OpenSearch/pull/10934))
- Fix for stuck update action in a bulk with `retry_on_conflict` property ([#11152](https://github.com/opensearch-project/OpenSearch/issues/11152))
- Fix Shadow JAR dependency publication ([#11369](https://github.com/opensearch-project/OpenSearch/issues/11369))

### Security

Expand Down
17 changes: 15 additions & 2 deletions buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

package org.opensearch.gradle;

import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin;
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension;
import groovy.util.Node;
import groovy.util.NodeList;
Expand All @@ -44,7 +43,9 @@
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.XmlProvider;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.ProjectDependency;
import org.gradle.api.artifacts.SelfResolvingDependency;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.BasePluginExtension;
import org.gradle.api.plugins.JavaPlugin;
Expand Down Expand Up @@ -116,7 +117,8 @@ public String call() throws Exception {
root.appendNode("description", project.getDescription());
}
Node dependenciesNode = (Node) ((NodeList) root.get("dependencies")).get(0);
project.getConfigurations().getByName(ShadowBasePlugin.CONFIGURATION_NAME).getAllDependencies().all(dependency -> {
final ConfigurationContainer configurations = project.getConfigurations();
configurations.getByName(JavaPlugin.API_CONFIGURATION_NAME).getDependencies().all(dependency -> {

Check warning on line 121 in buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java#L120-L121

Added lines #L120 - L121 were not covered by tests
if (dependency instanceof ProjectDependency) {
Node dependencyNode = dependenciesNode.appendNode("dependency");
dependencyNode.appendNode("groupId", dependency.getGroup());
Expand All @@ -125,6 +127,17 @@ public String call() throws Exception {
dependencyNode.appendNode("artifactId", artifactId);
dependencyNode.appendNode("version", dependency.getVersion());
dependencyNode.appendNode("scope", "compile");
} else if (!(dependency instanceof SelfResolvingDependency)) {
Node dependencyNode = dependenciesNode.appendNode("dependency");
dependencyNode.appendNode("groupId", dependency.getGroup());
dependencyNode.appendNode("artifactId", dependency.getName());
dependencyNode.appendNode("version", dependency.getVersion());
dependencyNode.appendNode("scope", "compile");

Check warning on line 135 in buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java#L131-L135

Added lines #L131 - L135 were not covered by tests

final Node exclusions = dependencyNode.appendNode("exclusions");
final Node exclusion = exclusions.appendNode("exclusion");
exclusion.appendNode("groupId", "*");
exclusion.appendNode("artifactId", "*");

Check warning on line 140 in buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java

View check run for this annotation

Codecov / codecov/patch

buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java#L137-L140

Added lines #L137 - L140 were not covered by tests
}
});
});
Expand Down

0 comments on commit edfe896

Please sign in to comment.