Include sources and javadoc artifacts while publishing to a Maven repository (#1049) (#1139)

This change fixes the issue where the sources and javadoc artifacts were not built and included with the publish.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-08-23 17:12:20 -07:00 committed by GitHub
parent f73e66e5e7
commit 07a57d9bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -121,13 +121,19 @@ public class PublishPlugin implements Plugin<Project> {
});
});
// Add git origin info to generated POM files
publishing.getPublications().withType(MavenPublication.class, publication -> {
// Add git origin info to generated POM files
publication.getPom().withXml(PublishPlugin::addScmInfo);
// have to defer this until archivesBaseName is set
project.afterEvaluate(p -> publication.setArtifactId(getArchivesBaseName(project)));
// publish sources and javadoc for Java projects.
if (project.getPluginManager().hasPlugin("opensearch.java")) {
publication.artifact(project.getTasks().getByName("sourcesJar"));
publication.artifact(project.getTasks().getByName("javadocJar"));
}
generatePomTask.configure(
t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName())))
);