Include sources and javadoc artifacts while publishing to a Maven repository (#1049)
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:
parent
7d18eaf3a4
commit
7469bf6e26
|
@ -121,13 +121,19 @@ public class PublishPlugin implements Plugin<Project> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add git origin info to generated POM files
|
|
||||||
publishing.getPublications().withType(MavenPublication.class, publication -> {
|
publishing.getPublications().withType(MavenPublication.class, publication -> {
|
||||||
|
// Add git origin info to generated POM files
|
||||||
publication.getPom().withXml(PublishPlugin::addScmInfo);
|
publication.getPom().withXml(PublishPlugin::addScmInfo);
|
||||||
|
|
||||||
// have to defer this until archivesBaseName is set
|
// have to defer this until archivesBaseName is set
|
||||||
project.afterEvaluate(p -> publication.setArtifactId(getArchivesBaseName(project)));
|
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(
|
generatePomTask.configure(
|
||||||
t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName())))
|
t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName())))
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue