Skip to content

Commit 0b65b29

Browse files
authored
Include sources and javadoc artifacts while publishing to a Maven repository (#1049) (#1162)
This change fixes the issue where the sources and javadoc artifacts were not built and included with the publish. Signed-off-by: Rabi Panda <[email protected]>
1 parent 1d59eaf commit 0b65b29

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

buildSrc/src/main/java/org/opensearch/gradle/PublishPlugin.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,19 @@ public String call() throws Exception {
121121
});
122122
});
123123

124-
// Add git origin info to generated POM files
125124
publishing.getPublications().withType(MavenPublication.class, publication -> {
125+
// Add git origin info to generated POM files
126126
publication.getPom().withXml(PublishPlugin::addScmInfo);
127127

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

131+
// publish sources and javadoc for Java projects.
132+
if (project.getPluginManager().hasPlugin("opensearch.java")) {
133+
publication.artifact(project.getTasks().getByName("sourcesJar"));
134+
publication.artifact(project.getTasks().getByName("javadocJar"));
135+
}
136+
131137
generatePomTask.configure(
132138
t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName())))
133139
);

0 commit comments

Comments
 (0)