-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathbuild.gradle
More file actions
200 lines (187 loc) · 6.65 KB
/
build.gradle
File metadata and controls
200 lines (187 loc) · 6.65 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
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* A Bill of Materials (BOM) for the Google Ads API client library for Java.
*
* This BOM ensures that all Google Ads API library artifacts and their
* transitive dependencies are using compatible versions.
*
* To use this BOM, add the following to the dependencyManagement section of your
* pom.xml file and replace REPLACE_WITH_CURRENT-VERSION with the current
* version of google-ads-bom:
*
* <dependencyManagement>
* <dependencies>
* <dependency>
* <groupId>com.google.api-ads</groupId>
* <artifactId>google-ads-bom</artifactId>
* <version>REPLACE-WITH-CURRENT-VERSION</version>
* <type>pom</type>
* <scope>import</scope>
* </dependency>
* </dependencies>
* </dependencyManagement>
*
* Then, add dependencies on the Google Ads API library artifacts without
* specifying their versions.
*
* <dependencies>
* <!-- Add google-ads WITHOUT a version -->
* <dependency>
* <groupId>com.google.api-ads</groupId>
* <artifactId>google-ads</artifactId>
* </dependency>
* </dependencies>
*
*/
plugins {
id 'java-platform'
id 'maven-publish'
id 'org.jreleaser'
}
// Creates an empty JAR to be published alongside the BOM's POM file.
// JReleaser requires at least one JAR to publish, and will not publish a
// standalone POM file.
task emptyJar(type: Jar) {
archiveClassifier = "empty"
}
// The code below is used to create a staging directory for jreleaser to deploy to.
// This is required because the jreleaser task does not create the directory itself.
task prepareJReleaser {
doLast {
mkdir "${buildDir}/staging-deploy"
}
}
// The jreleaser task depends on the prepareJReleaser task to ensure that the
// staging directory is created before it runs.
tasks.named("jreleaserConfig").configure {
dependsOn prepareJReleaser
dependsOn emptyJar
dependsOn generatePomFileForMavenPublication
}
jreleaser {
project {
gitRootSearch = true // Allow JReleaser to search upwards for .git
copyright = 'Google LLC'
description = 'Bill of Materials for the Google Ads API Client Library'
links {
homepage = 'https://github.com/googleads/google-ads-java'
documentation = 'https://developers.google.com/google-ads/api/docs/client-libs/java'
}
license = 'Apache-2.0'
authors = ['Josh Radcliff', 'Sarah Botwinick Pollack']
}
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString())
stage = 'UPLOAD'
}
}
release {
github {
skipRelease = true
skipTag = true
}
}
}
}
}
repositories {
mavenCentral()
}
javaPlatform {
// Allows importing other BOMs, like the Google Cloud BOM below.
allowDependencies()
}
dependencies {
// This makes this BOM inherit all dependency versions from the Google Cloud
// BOM. This version is determined based on the current used version of
// google-cloud-shared-dependencies.
api(platform("com.google.cloud:libraries-bom:26.74.0"))
// Add constraints for all of this project's artifacts.
constraints {
api "com.google.api-ads:google-ads:${version}"
api "com.google.api-ads:google-ads-codegen:${version}"
api "com.google.api-ads:google-ads-shadowjar:${version}"
api "com.google.api-ads:google-ads-stubs-v20:${version}"
api "com.google.api-ads:google-ads-stubs-v21:${version}"
api "com.google.api-ads:google-ads-stubs-v22:${version}"
api "com.google.api-ads:google-ads-stubs-v23:${version}"
}
}
publishing {
publications {
maven(MavenPublication) {
from components.javaPlatform
pom {
name = 'Google Ads API Client BOM'
description = 'Bill of Materials for the Google Ads API Client Library'
url = 'https://github.com/googleads/google-ads-java'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
scm {
url = 'https://github.com/googleads/google-ads-java'
connection = 'scm:git:https://github.com/googleads/google-ads-java.git'
developerConnection = 'scm:git:[email protected]:googleads/google-ads-java.git'
}
developers {
developer {
name = 'Josh Radcliff'
url = 'https://github.com/jradcliff'
}
developer {
name = 'Sarah Botwinick Pollack'
url = 'https://github.com/sarahcaseybot'
}
}
}
}
}
repositories {
maven {
name = 'sonatype'
url = uri(layout.buildDirectory.dir("staging-deploy"))
}
}
}
// Lists all dependencies available in this BOM, including transitive dependencies.
// This is useful for users to see what dependencies they can use without specifying a version.
task listAllDependencyConstraints {
doLast {
println "Dependency constraints:"
def resolvable = configurations.create("resolvable")
resolvable.dependencies.add(dependencies.platform(project))
resolvable.dependencies.add(dependencies.project(path: ":google-ads"))
def allDeps = new TreeSet<String>()
resolvable.incoming.resolutionResult.allComponents.each { component ->
if (component.moduleVersion != null) {
allDeps.add(component.moduleVersion.id.toString())
}
}
allDeps.each { String dep -> println dep }
}
}