-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathbuild.gradle
More file actions
265 lines (232 loc) · 8.53 KB
/
Copy pathbuild.gradle
File metadata and controls
265 lines (232 loc) · 8.53 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import java.time.LocalDate
plugins {
id 'java-library'
id 'base'
id 'jacoco'
id 'signing'
id 'maven-publish'
id 'com.github.hierynomus.license' version '0.16.1'
id 'com.github.ben-manes.versions' version '0.51.0'
}
group = 'com.tokbox'
base.archivesName = 'opentok-server-sdk'
version = '4.17.0'
ext.githubPath = "opentok/Opentok-Java-SDK"
repositories {
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.wiremock:wiremock:3.10.0'
testImplementation 'com.google.guava:guava:33.4.6-jre'
testImplementation 'io.jsonwebtoken:jjwt-api:0.12.6'
testImplementation 'io.jsonwebtoken:jjwt-impl:0.12.6'
testImplementation 'io.jsonwebtoken:jjwt-jackson:0.12.6'
implementation 'com.vonage:jwt:2.0.1'
implementation 'org.apache.commons:commons-lang3:3.18.0'
implementation 'commons-codec:commons-codec:1.18.0'
implementation 'io.netty:netty-codec-http:4.1.119.Final'
implementation 'io.netty:netty-handler:4.1.119.Final'
implementation 'org.asynchttpclient:async-http-client:3.0.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
}
// The target Java version for compiling main sources. Pass -PjavaTarget=11
// (or 17, etc.) on the command line to test against a different version.
// Defaults to 8, the minimum supported runtime version.
def targetJava = project.findProperty('javaTarget') ? Integer.parseInt(project.findProperty('javaTarget').toString()) : 8
java {
sourceCompatibility = JavaVersion.toVersion(targetJava)
targetCompatibility = sourceCompatibility
}
// Use the JDK matching targetJava via Gradle toolchains. For Java 9+, enforce
// API compatibility with --release. For Java 8, --release is not supported by
// javac 8, so sourceCompatibility/targetCompatibility (set above) suffice.
compileJava {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(targetJava)
}
if (targetJava >= 9) {
options.release = targetJava
}
}
// Tests always compile and run on Java 21 regardless of the target version.
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = sourceCompatibility
}
task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
task javadocJar(type: Jar) {
archiveClassifier.set("javadoc")
from javadoc
}
javadoc {
title = 'OpenTok Java SDK Reference'
destinationDir = file('docs')
exclude '**/util/**', '**/constants/**'
options {
locale 'en_US'
setMemberLevel JavadocMemberLevel.PUBLIC
addBooleanOption('Xdoclint:none', true)
}
}
jacoco {
toolVersion = "0.8.13"
}
jacocoTestReport {
reports {
xml.getRequired().set(true)
html.getRequired().set(true)
}
}
check.dependsOn jacocoTestReport
license {
header rootProject.file('codequality/HEADER')
ext.year = LocalDate.now().getYear()
}
artifacts {
archives javadocJar, sourcesJar
}
java {
withSourcesJar()
withJavadocJar()
}
test {
testLogging {
exceptionFormat = 'full'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = "OpenTok Java SDK"
artifactId = 'opentok-server-sdk'
packaging = 'jar'
description = "The OpenTok Java SDK lets you generate sessions and tokens for OpenTok applications. This version of the SDK also includes support for working with OpenTok 2.0 archives."
url = "https://github.com/$githubPath"
licenses {
license {
name = 'MIT License'
url = "https://raw.github.com/$githubPath/refs/heads/main/LICENSE"
}
}
developers {
developer {
id = "devrel"
name = "Vonage Devrel"
email = "devrel@vonage.com"
}
developer {
id = 'manasdpradhan'
name = 'Manas Pradhan'
email = 'manas@tokbox.com'
organization = 'Vonage'
}
developer {
id = 'aoberoi'
name = 'Ankur Oberoi'
email = 'aoberoi@gmail.com'
organization = 'Vonage'
}
developer {
id = 'slorello89'
name = 'Steve Lorello'
email = 'steve.lorello@vonage.com'
organization = 'Vonage'
}
developer {
id = 'smadani'
name = 'Sina Madani'
email = 'sina.madani@vonage.com'
organization = 'Vonage'
}
}
scm {
connection = "scm:git@github.com/$githubPath"
developerConnection = "scm:git@github.com/$githubPath"
url = "https://github.com/$githubPath"
}
issueManagement {
system = "GitHub"
url = "https://github.com/$githubPath"
}
}
}
}
}
// Task to create a bundle for Central Portal upload
task createCentralBundle(type: Zip) {
dependsOn 'publishToMavenLocal'
archiveBaseName = 'central-bundle'
archiveVersion = project.version
archiveExtension = 'zip'
def localRepo = repositories.mavenLocal().url
def groupPath = project.group.toString().replace('.', '/')
def artifactPath = "${groupPath}/${base.archivesName.get()}/${project.version}"
def sourceDir = "${localRepo}/${artifactPath}"
doFirst {
// Generate checksums for all files
fileTree(sourceDir).each { file ->
if (file.isFile() && !file.name.endsWith('.md5') && !file.name.endsWith('.sha1')) {
// Generate MD5
ant.checksum(file: file, algorithm: 'MD5', fileext: '.md5')
// Generate SHA1
ant.checksum(file: file, algorithm: 'SHA1', fileext: '.sha1')
}
}
}
from(sourceDir) {
include '**/*'
// Maintain the proper Maven repository structure in the zip
into("${groupPath}/${base.archivesName.get()}/${project.version}")
}
destinationDirectory = file("${buildDir}/central")
doLast {
// Validate bundle contents
def requiredFiles = [
"${base.archivesName.get()}-${project.version}.jar",
"${base.archivesName.get()}-${project.version}.pom",
"${base.archivesName.get()}-${project.version}-sources.jar",
"${base.archivesName.get()}-${project.version}-javadoc.jar"
]
def bundleFile = archiveFile.get().asFile
logger.lifecycle("Created bundle: ${bundleFile}")
logger.lifecycle("Bundle size: ${bundleFile.length()} bytes")
// Check if signing was performed
def hasSignatures = fileTree(sourceDir).any { it.name.endsWith('.asc') }
if (hasSignatures) {
logger.lifecycle("✅ Bundle includes PGP signatures")
} else {
logger.warn("⚠️ Bundle does not include PGP signatures (signing keys not provided)")
}
}
}
// Task to upload bundle to Central Portal
task uploadToCentralPortal(type: Exec) {
dependsOn 'createCentralBundle'
def username = System.getenv("MAVEN_USERNAME")
def password = System.getenv("MAVEN_SECRET")
def bundleFile = "${buildDir}/central/central-bundle-${project.version}.zip"
commandLine 'curl', '-X', 'POST',
'-H', 'Content-Type: multipart/form-data',
'-F', "bundle=@${bundleFile}",
'-u', "${username}:${password}",
'https://central.sonatype.com/api/v1/publisher/upload'
}
signing {
required { gradle.taskGraph.hasTask("uploadToCentralPortal") && findProperty("signingKey") }
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
if (signingKey && signingPassword) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}