xref: /aosp_15_r20/external/jspecify/gradle/publish.gradle (revision 2167191df2fa07300797f1ac5b707370b5f38c48)
1/*
2 * Copyright 2020 The JSpecify Authors.
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 *     http://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
17// run `./gradlew publishToMavenLocal` to install artifact to your Local Maven Repository
18
19apply plugin: 'maven-publish'
20apply plugin: 'signing'
21apply plugin: 'io.github.gradle-nexus.publish-plugin'
22
23publishing {
24    publications {
25        mavenJava(MavenPublication) {
26            pom {
27                groupId = 'org.jspecify'
28                artifactId = 'jspecify'
29                name = 'JSpecify annotations'
30                description = 'An artifact of well-named and well-specified annotations to power static analysis checks'
31                url = 'http://jspecify.org/'
32                from components.java
33                licenses {
34                    license {
35                        name = 'The Apache License, Version 2.0'
36                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
37                    }
38                }
39                scm {
40                    connection = 'scm:git:[email protected]:jspecify/jspecify.git'
41                    developerConnection = 'scm:git:[email protected]:jspecify/jspecify.git'
42                    url = 'https://github.com/jspecify/jspecify/'
43                }
44                developers {
45                    // These are here only because Sonatype requires us to list someone.
46                    // Any project member is welcome to add themselves if they want to.
47                    developer {
48                        id = 'kevinb9n'
49                        name = 'Kevin Bourrillion'
50                        email = '[email protected]'
51                    }
52                }
53            }
54        }
55    }
56}
57
58nexusPublishing {
59    repositories {
60        // The following line causes the `The Project.getConvention() method has been deprecated.` warning.
61        // The `gradle-nexus` plugin still is on [gradle 8.2.1](https://github.com/gradle-nexus/publish-plugin/blob/c2614e3a5fd61008c66633ca061760df8d4a5106/gradle/wrapper/gradle-wrapper.properties#L4).
62        // I tracked down the deprecation warning to the `sonatype` block, but didn't find a way to avoid the warning.
63        sonatype {
64            // For users registered in Sonatype after 24 Feb 2021
65            nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
66            snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
67        }
68    }
69}
70
71def privateKey = findProperty('privateKey')
72def pgpPassword = findProperty('pgpPassword')
73
74signing {
75    useInMemoryPgpKeys(privateKey, pgpPassword)
76    sign publishing.publications.mavenJava
77}
78
79tasks.withType(Sign).configureEach {
80    onlyIf {
81        privateKey?.trim() && pgpPassword?.trim()
82    }
83}
84