-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
151 lines (138 loc) · 5.77 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven-publish'
// 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
}
// Published artifact info, equired for maven publishing - this is the version of our artifact
group = 'org.odpi.egeria'
version = '3.12-SNAPSHOT'
repositories {
mavenCentral()
// Needed if we want to build with egeria snapshots (ie for testing, fixing bugs)
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
configurations {
// configuration that holds jars to include in the jar
// https://discuss.gradle.org/t/how-to-include-dependencies-in-jar/19571/8
bundledLibs
implementation.extendsFrom bundledLibs
}
ext {
// The version of Egeria to use
egeriaVersion = '3.12-SNAPSHOT'
}
dependencies {
implementation "org.odpi.egeria:open-connector-framework:${egeriaVersion}"
implementation "org.odpi.egeria:repository-services-connectors:${egeriaVersion}"
implementation('org.apache.commons:commons-lang3:3.12.0')
bundledLibs 'org.slf4j:slf4j-api'
bundledLibs 'org.apache.httpcomponents:httpclient:4.5.14'
bundledLibs 'com.google.code.gson:gson:2.10'
bundledLibs 'com.rabbitmq:amqp-client:5.16.0'
testImplementation 'org.apache.groovy:groovy:4.0.6'
testImplementation 'org.apache.groovy:groovy-dateutil:4.0.6'
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'org.junit.platform:junit-platform-engine:1.9.1'
testImplementation "org.odpi.egeria:repository-services-implementation:${egeriaVersion}"
}
// Maven Central (technically sonatype oss) requires we distribute source and javadoc
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
jar {
from {
configurations.bundledLibs.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// 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)
}
}
// 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
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 = 'SAS Viya Connector for Egeria'
name = 'SAS Viya Connector'
url = 'http://egeria.odpi.org'
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 = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/odpi/egeria-connector-sas-viya.git'
developerConnection = 'scm:git:ssh://github.com/odpi/egeria/egeria-connector-sas-viya.git'
url = 'http://github.com/odpi/egeria-connector-sas-viya/'
}
}
}
}
// Release versions get pushed to staging area on maven central, snapshots to snapshot repo
// Secrets for credentials
if (System.getenv('CI')) {
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
if (System.getenv('CI')) {
signing {
// This is the publication to sign
sign publishing.publications.connector
// gpg --export-secret-keys [email protected] | 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)
}
}