diff --git a/build.gradle b/build.gradle index 48d4565..3448d22 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,6 @@ * Copyright Contributors to the ODPi Egeria project. */ - /* * Used for Build scripts/plugins only */ @@ -38,16 +37,19 @@ plugins { /* run './gradlew aggregateJavadocs' at top level to build all docs & output to build/docs/javadoc */ apply plugin: 'nebula-aggregate-javadocs' - - /* * Configuration for all projects - INCLUDING this one */ + + allprojects { + // Published artifact info, equired for maven publishing - this is the version of our artifact group = 'org.odpi.egeria' - version = '2.9-SNAPSHOT' + version = '2.10-SNAPSHOT' + + apply plugin: 'idea' repositories { mavenCentral() @@ -62,6 +64,7 @@ allprojects { // rules = ['all-dependency'] // TODO: Change to criticalRules when ready to enforce // //} + } /* @@ -104,6 +107,21 @@ subprojects { } } + // Maven Central (technically sonatype oss) requires we distribute source and javadoc + java { + sourceCompatibility = "VERSION_1_8" + targetCompatibility = "VERSION_1_8" + withJavadocJar() + withSourcesJar() + } + + // Only apply the signing plugin if we're running in the build environment since + // this is dependent on having access to sonatype, and suitable GPG keys + if (System.getenv("CI")) { + apply plugin: 'signing' + // Artifacts need signing for maven central - supplied by GitHub secrets + } + } // sources required to publish a legitimate maven package for distribution @@ -111,6 +129,13 @@ subprojects { withSourcesJar() } + // For later java versions this is recommended - keep conditional in case we want to build on 8 + javadoc { + if(JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } + } + //need to decide who owns the testing infrastructure //random junit versions picked below. test { diff --git a/postgres-connector/build.gradle b/postgres-connector/build.gradle index ac62625..6c32635 100644 --- a/postgres-connector/build.gradle +++ b/postgres-connector/build.gradle @@ -43,5 +43,85 @@ jar { into "libs" } } + + // We only have a single artifact for now - this additional metadata is +// required for publishing to maven central. As above, only if we're running in a build pipeline +// Environment variables are sourced from GitHub secrets in the CI pipeline + if (System.getenv("CI")) { + publishing { + publications { + // definining a publication called 'connector' + connector(MavenPublication) { + // Pick up the standard java artifacts + from components.java + // by default, gradle's groupId, artifactId, version are used for the maven coordinates + // but we need additional metadata to align with Egeria (more may need to be added) + pom { + description = 'Postgres Connector for Egeria' + url = 'http://egeria.odpi.org' + // No additional properties for now + //properties = [ + // propname: "propvalue" + //] + licenses { + // Code + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + // Docs + license { + name = 'Creative Commons Attribution 4.0 International (CC BY 4.0)' + url = 'https://creativecommons.org/licenses/by/4.0' + } + } + developers { + developer { + id = 'planetf1' + name = 'Nigel Jones' + email = 'nigel.l.jones+git@gmail.com' + } + } + scm { + connection = 'scm:git:git://github.com/odpi/egeria-database-connectors.git' + developerConnection = 'scm:git:ssh://github.com/odpi/egeria/egeria-database-connectors.git' + url = 'http://github.com/odpi/egeria-database-connectors/' + } + + } + } + + } + // Release versions get pushed to staging area on maven central, snapshots to snapshot repo + // Secrets for credentials + repositories { + maven { + name = 'OSSRH' + def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2' + def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots' + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + // User token (under profile) on oss.sonatype.org + credentials { + username = System.getenv("OSSRH_USERNAME") + password = System.getenv("OSSRH_TOKEN") + } + } + } + } + + // To publish to ossrh we need to sign the artifacts + signing { + // This is the publication to sign + sign publishing.publications.connector + // gpg --export-secret-keys myemal@gmail.com | base64 + def signingKey = System.getenv("OSSRH_GPG_PRIVATE_KEY") + // Passphrase for key + def signingPassword = System.getenv("OSSRH_GPG_PASSPHRASE") + // public key id (last 8 characters only) - note keys also need uploading to all the main registries + def signingKeyId = System.getenv("OSSRH_GPG_KEYID") + // We use these values from secrets rather than gradle.properties + useInMemoryPgpKeys(signingKeyId,signingKey, signingPassword) + } + } }