|
| 1 | +/* |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * A Bill of Materials (BOM) for the Google Ads API client library for Java. |
| 17 | + * |
| 18 | + * This BOM ensures that all Google Ads API library artifacts and their |
| 19 | + * transitive dependencies are using compatible versions. |
| 20 | + * |
| 21 | + * To use this BOM, add the following to the dependencyManagement section of your |
| 22 | + * pom.xml file and replace REPLACE_WITH_CURRENT-VERSION with the current |
| 23 | + * version of google-ads-bom: |
| 24 | + * |
| 25 | + * <dependencyManagement> |
| 26 | + * <dependencies> |
| 27 | + * <dependency> |
| 28 | + * <groupId>com.google.api-ads</groupId> |
| 29 | + * <artifactId>google-ads-bom</artifactId> |
| 30 | + * <version>REPLACE-WITH-CURRENT-VERSION</version> |
| 31 | + * <type>pom</type> |
| 32 | + * <scope>import</scope> |
| 33 | + * </dependency> |
| 34 | + * </dependencies> |
| 35 | + * </dependencyManagement> |
| 36 | + * |
| 37 | + * Then, add dependencies on the Google Ads API library artifacts without |
| 38 | + * specifying their versions. |
| 39 | + * |
| 40 | + * <dependencies> |
| 41 | + * <!-- Add google-ads WITHOUT a version --> |
| 42 | + * <dependency> |
| 43 | + * <groupId>com.google.api-ads</groupId> |
| 44 | + * <artifactId>google-ads</artifactId> |
| 45 | + * </dependency> |
| 46 | + * </dependencies> |
| 47 | + * |
| 48 | + */ |
| 49 | + |
| 50 | +plugins { |
| 51 | + id 'java-platform' |
| 52 | + id 'maven-publish' |
| 53 | + id 'org.jreleaser' |
| 54 | +} |
| 55 | + |
| 56 | +// Creates an empty JAR to be published alongside the BOM's POM file. |
| 57 | +// JReleaser requires at least one JAR to publish, and will not publish a |
| 58 | +// standalone POM file. |
| 59 | +task emptyJar(type: Jar) { |
| 60 | + archiveClassifier = "empty" |
| 61 | +} |
| 62 | + |
| 63 | +// The code below is used to create a staging directory for jreleaser to deploy to. |
| 64 | +// This is required because the jreleaser task does not create the directory itself. |
| 65 | +task prepareJReleaser { |
| 66 | + doLast { |
| 67 | + mkdir "${buildDir}/staging-deploy" |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +// The jreleaser task depends on the prepareJReleaser task to ensure that the |
| 72 | +// staging directory is created before it runs. |
| 73 | +tasks.named("jreleaserConfig").configure { |
| 74 | + dependsOn prepareJReleaser |
| 75 | + dependsOn emptyJar |
| 76 | + dependsOn generatePomFileForMavenPublication |
| 77 | +} |
| 78 | + |
| 79 | +jreleaser { |
| 80 | + project { |
| 81 | + gitRootSearch = true // Allow JReleaser to search upwards for .git |
| 82 | + copyright = 'Google LLC' |
| 83 | + description = 'Bill of Materials for the Google Ads API Client Library' |
| 84 | + links { |
| 85 | + homepage = 'https://github.com/googleads/google-ads-java' |
| 86 | + documentation = 'https://developers.google.com/google-ads/api/docs/client-libs/java' |
| 87 | + } |
| 88 | + license = 'Apache-2.0' |
| 89 | + authors = ['Josh Radcliff', 'Sarah Botwinick Pollack'] |
| 90 | + } |
| 91 | + signing { |
| 92 | + active = 'ALWAYS' |
| 93 | + armored = true |
| 94 | + } |
| 95 | + deploy { |
| 96 | + maven { |
| 97 | + mavenCentral { |
| 98 | + sonatype { |
| 99 | + active = 'ALWAYS' |
| 100 | + url = 'https://central.sonatype.com/api/v1/publisher' |
| 101 | + stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString()) |
| 102 | + stage = 'UPLOAD' |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + release { |
| 107 | + github { |
| 108 | + skipRelease = true |
| 109 | + skipTag = true |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | + |
| 117 | +javaPlatform { |
| 118 | + // Allows importing other BOMs, like the Google Cloud BOM below. |
| 119 | + allowDependencies() |
| 120 | +} |
| 121 | + |
| 122 | +dependencies { |
| 123 | + // This makes this BOM inherit all dependency versions from the Google Cloud |
| 124 | + // BOM. This version is determined based on the current used version of |
| 125 | + // google-cloud-shared-dependencies. |
| 126 | + api(platform("com.google.cloud:libraries-bom:26.65.0")) |
| 127 | + |
| 128 | + // Add constraints for all of this project's artifacts. |
| 129 | + constraints { |
| 130 | + api "com.google.api-ads:google-ads:${version}" |
| 131 | + api "com.google.api-ads:google-ads-codegen:${version}" |
| 132 | + api "com.google.api-ads:google-ads-shadowjar:${version}" |
| 133 | + api "com.google.api-ads:google-ads-stubs-v19:${version}" |
| 134 | + api "com.google.api-ads:google-ads-stubs-v20:${version}" |
| 135 | + api "com.google.api-ads:google-ads-stubs-v21:${version}" |
| 136 | + } |
| 137 | +} |
| 138 | + |
| 139 | +publishing { |
| 140 | + publications { |
| 141 | + maven(MavenPublication) { |
| 142 | + from components.javaPlatform |
| 143 | + pom { |
| 144 | + name = 'Google Ads API Client BOM' |
| 145 | + description = 'Bill of Materials for the Google Ads API Client Library' |
| 146 | + url = 'https://github.com/googleads/google-ads-java' |
| 147 | + licenses { |
| 148 | + license { |
| 149 | + name = 'Apache License, Version 2.0' |
| 150 | + url = 'http://www.apache.org/licenses/LICENSE-2.0' |
| 151 | + } |
| 152 | + } |
| 153 | + scm { |
| 154 | + url = 'https://github.com/googleads/google-ads-java' |
| 155 | + connection = 'scm:git:https://github.com/googleads/google-ads-java.git' |
| 156 | + developerConnection = 'scm:git:git@github.com:googleads/google-ads-java.git' |
| 157 | + } |
| 158 | + developers { |
| 159 | + developer { |
| 160 | + name = 'Josh Radcliff' |
| 161 | + url = 'https://github.com/jradcliff' |
| 162 | + } |
| 163 | + developer { |
| 164 | + name = 'Sarah Botwinick Pollack' |
| 165 | + url = 'https://github.com/sarahcaseybot' |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + repositories { |
| 172 | + maven { |
| 173 | + name = 'sonatype' |
| 174 | + url = uri(layout.buildDirectory.dir("staging-deploy")) |
| 175 | + } |
| 176 | + } |
| 177 | +} |
0 commit comments