|
| 1 | +import org.gradle.api.publish.maven.MavenPublication |
| 2 | + |
| 3 | +/* |
| 4 | + * ****************************************************************************** |
| 5 | + * Copyright 2002 Spectra Logic Corporation. All Rights Reserved. |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use |
| 7 | + * this file except in compliance with the License. A copy of the License is located at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * or in the "license" file accompanying this file. |
| 12 | + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 13 | + * CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 14 | + * specific language governing permissions and limitations under the License. |
| 15 | + * **************************************************************************** |
| 16 | + */ |
| 17 | + |
| 18 | +plugins { |
| 19 | + `maven-publish` |
| 20 | + signing |
| 21 | +} |
| 22 | + |
| 23 | +publishing { |
| 24 | + repositories { |
| 25 | + maven { |
| 26 | + name = "internal" |
| 27 | + val releasesRepoUrl = "https://artifacts.eng.sldomain.com/repository/spectra-releases/" |
| 28 | + val snapshotsRepoUrl = "https://artifacts.eng.sldomain.com/repository/spectra-snapshots/" |
| 29 | + url = uri(if (extra["isReleaseVersion"] as Boolean) releasesRepoUrl else snapshotsRepoUrl) |
| 30 | + credentials { |
| 31 | + username = extra.has("artifactsUsername").let { |
| 32 | + if (it) extra.get("artifactsUsername") as String else null |
| 33 | + } |
| 34 | + password = extra.has("artifactsPassword").let { |
| 35 | + if (it) extra.get("artifactsPassword") as String else null |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + maven { |
| 40 | + name = "OSSRH" |
| 41 | + val releasesOssrhRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 42 | + val snapshotsOssrhRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" |
| 43 | + url = uri(if (extra["isReleaseVersion"] as Boolean) releasesOssrhRepoUrl else snapshotsOssrhRepoUrl) |
| 44 | + credentials { |
| 45 | + username = extra.has("ossrhUsername").let { |
| 46 | + if (it) extra.get("ossrhUsername") as String else null |
| 47 | + } |
| 48 | + password = extra.has("ossrhPassword").let { |
| 49 | + if (it) extra.get("ossrhPassword") as String else null |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +tasks.register("publishToInternalRepository") { |
| 57 | + group = "publishing" |
| 58 | + description = "Publishes all Maven publications to the internal Maven repository." |
| 59 | + dependsOn(tasks.withType<PublishToMavenRepository>().matching { |
| 60 | + it.repository == publishing.repositories["internal"] |
| 61 | + }) |
| 62 | +} |
| 63 | + |
| 64 | +tasks.register("publishToSonatypeOSSRH") { |
| 65 | + group = "publishing" |
| 66 | + description = "Publishes all Maven publications to Sonatype's OSSRH repository." |
| 67 | + dependsOn(tasks.withType<PublishToMavenRepository>().matching { |
| 68 | + it.repository == publishing.repositories["OSSRH"] |
| 69 | + }) |
| 70 | +} |
| 71 | + |
| 72 | +val augmentPom = tasks.register("augmentPom") { |
| 73 | + publishing.publications.filterIsInstance<MavenPublication>().forEach { pub -> |
| 74 | + pub.pom { |
| 75 | + name.set("${project.group}:${project.name}") |
| 76 | + url.set("https://github.com/SpectraLogic/ds3_java_sdk") |
| 77 | + licenses { |
| 78 | + license { |
| 79 | + name.set("The Apache License, Version 2.0") |
| 80 | + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") |
| 81 | + } |
| 82 | + } |
| 83 | + developers { |
| 84 | + developer { |
| 85 | + name.set("Spectra Logic Developers") |
| 86 | + |
| 87 | + organization.set("Spectra Logic") |
| 88 | + organizationUrl.set("https://spectralogic.com/") |
| 89 | + } |
| 90 | + } |
| 91 | + scm { |
| 92 | + connection.set("scm:git:https://github.com/SpectraLogic/ds3_java_sdk.git") |
| 93 | + developerConnection.set("scm:git:https://github.com/SpectraLogic/ds3_java_sdk.git") |
| 94 | + url.set("https://github.com/SpectraLogic/ds3_java_sdk") |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +tasks.withType<GenerateMavenPom>().configureEach { |
| 101 | + dependsOn(augmentPom) |
| 102 | +} |
| 103 | + |
| 104 | +tasks.withType<Sign>().configureEach { |
| 105 | + onlyIf("isReleaseVersion is set") { project.extra["isReleaseVersion"] as Boolean } |
| 106 | +} |
0 commit comments