Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
#16 add maven publishing
Browse files Browse the repository at this point in the history
Signed-off-by: Nigel Jones <nigel.l.jones+git@gmail.com>
  • Loading branch information
planetf1 committed May 26, 2021
1 parent c8858bb commit 3753df9
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 4 deletions.
33 changes: 29 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright Contributors to the ODPi Egeria project.
*/


/*
* Used for Build scripts/plugins only
*/
Expand Down Expand Up @@ -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()
Expand All @@ -62,6 +64,7 @@ allprojects {
// rules = ['all-dependency'] // TODO: Change to criticalRules when ready to enforce
//
//}

}

/*
Expand Down Expand Up @@ -104,13 +107,35 @@ 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
java {
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 {
Expand Down
80 changes: 80 additions & 0 deletions postgres-connector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

0 comments on commit 3753df9

Please sign in to comment.