-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
221 lines (202 loc) · 8.36 KB
/
Copy pathbuild.gradle
File metadata and controls
221 lines (202 loc) · 8.36 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
plugins {
id "java-library"
id "maven-publish"
id "signing"
id "com.diffplug.spotless" version "6.25.0"
id "jacoco"
id "org.owasp.dependencycheck" version "12.2.2"
}
layout.buildDirectory = file(".out")
repositories {
mavenCentral()
}
if (System.getenv("LIB_VERSION")) {
version = System.getenv("LIB_VERSION")
}
// Append -SNAPSHOT unless the build is invoked with -PreleaseBuild=true (or
// -DreleaseBuild=true).
def releaseBuildProp = System.getProperty("releaseBuild") ?: project.findProperty("releaseBuild")
def isRelease = (releaseBuildProp ?: "false").toString().toBoolean()
if (!isRelease && !version.toString().endsWith("-SNAPSHOT")) {
version = "${version}-SNAPSHOT"
}
spotless {
java {
target "src/**/*.java"
// Generated by openapi-generator; their headers come from generator/templates/licenseinfo.mustache.
targetExclude "src/main/java/com/apple/ads/model/**", "src/main/java/com/apple/ads/api/**"
licenseHeader "// Copyright (c) 2026 Apple Inc. Licensed under MIT License."
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaCompile).configureEach { options.encoding = "UTF-8" }
tasks.withType(Javadoc).configureEach { options.encoding = "UTF-8" }
tasks.withType(Test).configureEach { defaultCharacterEncoding = "UTF-8" }
tasks.named("jar") {
manifest.attributes(
"Specification-Title" : project.name,
"Specification-Version" : project.version,
"Specification-Vendor" : "Apple Inc.",
"Implementation-Title" : project.name,
"Implementation-Version": project.version,
"Implementation-Vendor" : "Apple Inc.",
"Group-Id" : project.group,
)
}
dependencies {
api "com.squareup.retrofit2:retrofit:${retrofit_version}"
implementation "com.squareup.retrofit2:converter-scalars:${retrofit_version}"
implementation "com.squareup.retrofit2:converter-jackson:${retrofit_version}"
implementation "com.fasterxml.jackson.core:jackson-core:${jackson_version}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jackson_version}"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jackson_version}"
implementation "org.openapitools:jackson-databind-nullable:${jackson_databind_nullable_version}"
implementation "io.swagger:swagger-annotations:${swagger_annotations_version}"
implementation "jakarta.annotation:jakarta.annotation-api:${jakarta_annotation_version}"
implementation "jakarta.validation:jakarta.validation-api:${jakarta_validation_version}"
implementation "org.bouncycastle:bcprov-jdk18on:${bouncycastle_version}"
implementation "org.bouncycastle:bcpkix-jdk18on:${bouncycastle_version}"
implementation "com.nimbusds:nimbus-jose-jwt:${nimbus_jose_version}"
api platform("com.squareup.okhttp3:okhttp-bom:${okhttp_version}")
api "com.squareup.okhttp3:okhttp"
api "com.squareup.okhttp3:logging-interceptor"
api "org.slf4j:slf4j-api:${slf4j_version}"
testImplementation platform("org.junit:junit-bom:${junit_version}")
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"
testImplementation "com.squareup.okhttp3:mockwebserver"
}
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
}
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"com/apple/ads/model/**",
"com/apple/ads/api/**",
])
})
)
}
dependencyCheck {
formats = ["XML", "HTML"]
outputDirectory = layout.buildDirectory.dir("reports").get().asFile.path
def nvdDatafeedUrl = System.getenv("NVD_DATAFEED_URL")
if (nvdDatafeedUrl) {
nvd {
datafeedUrl = nvdDatafeedUrl
}
}
analyzers {
ossIndex {
enabled = false
}
}
}
//make the project version available at runtime
processResources {
expand(projectVersion: project.version)
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// Lock POM to resolved versions so consumers don't see ranges.
versionMapping {
usage("java-api") { fromResolutionOf("runtimeClasspath") }
usage("java-runtime") { fromResolutionResult() }
}
pom {
name = "Apple Ads Platform API Java"
description = "Java client library for the Apple Ads public-facing API."
url = "https://github.com/apple/apple-ads-platform-api-java"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = "apple"
name = "Apple Inc."
url = "https://www.apple.com"
}
}
scm {
url = "https://github.com/apple/apple-ads-platform-api-java"
connection = "scm:git:https://github.com/apple/apple-ads-platform-api-java.git"
developerConnection = "scm:git:git@github.com:apple/apple-ads-platform-api-java.git"
}
}
}
}
}
def centralUsername = findProperty("centralUsername")
def centralPassword = findProperty("centralPassword")
if (centralUsername && centralPassword) {
publishing {
repositories {
maven {
name = "central"
credentials {
username = centralUsername
password = centralPassword
}
url = project.version.toString().endsWith("-SNAPSHOT")
? "https://central.sonatype.com/repository/maven-snapshots/"
: "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
// Sonatype Central requires a manual (or automated, as done here) step to move a staged
// deployment from "uploaded" to "published" after `publish` finishes. Only relevant for
// non-SNAPSHOT releases; snapshot deployments become available immediately.
tasks.named("publish") {
finalizedBy tasks.named("finalizeCentralRelease")
}
tasks.register("finalizeCentralRelease") {
doLast {
if (!project.version.toString().endsWith("-SNAPSHOT")) {
def url = "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/${project.group}"
def connection = new URL(url).openConnection() as HttpURLConnection
connection.setRequestMethod("POST")
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
connection.setRequestProperty("Authorization",
"Basic " + "${centralUsername}:${centralPassword}".bytes.encodeBase64().toString())
def responseCode = connection.responseCode
if (responseCode == 200) {
println "Central release finalized: ${connection.inputStream.text}"
} else {
def error = connection.errorStream?.text ?: "No error details"
throw new GradleException("Failed to finalize Central release ($responseCode): $error")
}
}
}
}
}