Skip to content

Commit

Permalink
Fix maven publish to include all artefacts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brettch committed Nov 3, 2023
1 parent bfe16e3 commit 5cd4d72
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -132,4 +122,9 @@ configure(javaProjects) {
}
}
}

// Sign all published artifacts if signing is enabled.
signing {
sign publishing.publications.mavenJava
}
}

0 comments on commit 5cd4d72

Please sign in to comment.