From 5cd4d7295a407d28aba598ed5f82866e06e9a510 Mon Sep 17 00:00:00 2001 From: Brett Henderson Date: Fri, 3 Nov 2023 22:41:50 +1100 Subject: [PATCH] Fix maven publish to include all artefacts The existing Maven publishing configuration was quite old and with the current version of Gradle only publishes the POM file. This change updates the config to follow the latest docs for maven-publish plugin and publishes all artefacts again. --- build.gradle | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 0de12b2c4..0bd3f19f9 100644 --- a/build.gradle +++ b/build.gradle @@ -37,12 +37,23 @@ subprojects { // Apply common configurations to all projects supporting Java. configure(javaProjects) { apply plugin: 'checkstyle' - apply plugin: 'java' + apply plugin: 'java-library' apply plugin: 'maven-publish' apply plugin: 'signing' sourceCompatibility = 17 + java { + withJavadocJar() + withSourcesJar() + } + + javadoc { + if(JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + } + test { /* * Pass on each of our custom properties to the unit tests if they have @@ -66,32 +77,11 @@ configure(javaProjects) { configProperties.samedir = configFile.parentFile } - // Build javadoc and source jars and include in published artifacts. - task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier = 'javadoc' - from 'build/docs/javadoc' - } - task sourcesJar(type: Jar) { - from sourceSets.main.allSource - archiveClassifier = 'sources' - } - artifacts { - archives jar - - archives javadocJar - archives sourcesJar - } - - // Sign all published artifacts if signing is enabled. - signing { - sign configurations.archives - required = Boolean.valueOf(osmosisSigningEnabled) - } - // Configure the maven-publish plugin to upload artifacts to the Sonatype repository. publishing { publications { mavenJava(MavenPublication) { + from components.java pom { name = project.name packaging = 'jar' @@ -132,4 +122,9 @@ configure(javaProjects) { } } } + + // Sign all published artifacts if signing is enabled. + signing { + sign publishing.publications.mavenJava + } }