xref: /aosp_15_r20/external/jspecify/gradle/publish.gradle (revision 2167191df2fa07300797f1ac5b707370b5f38c48)
1*2167191dSAndroid Build Coastguard Worker/*
2*2167191dSAndroid Build Coastguard Worker * Copyright 2020 The JSpecify Authors.
3*2167191dSAndroid Build Coastguard Worker *
4*2167191dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*2167191dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*2167191dSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*2167191dSAndroid Build Coastguard Worker *
8*2167191dSAndroid Build Coastguard Worker *     http://www.apache.org/licenses/LICENSE-2.0
9*2167191dSAndroid Build Coastguard Worker *
10*2167191dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*2167191dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*2167191dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*2167191dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*2167191dSAndroid Build Coastguard Worker * limitations under the License.
15*2167191dSAndroid Build Coastguard Worker */
16*2167191dSAndroid Build Coastguard Worker
17*2167191dSAndroid Build Coastguard Worker// run `./gradlew publishToMavenLocal` to install artifact to your Local Maven Repository
18*2167191dSAndroid Build Coastguard Worker
19*2167191dSAndroid Build Coastguard Workerapply plugin: 'maven-publish'
20*2167191dSAndroid Build Coastguard Workerapply plugin: 'signing'
21*2167191dSAndroid Build Coastguard Workerapply plugin: 'io.github.gradle-nexus.publish-plugin'
22*2167191dSAndroid Build Coastguard Worker
23*2167191dSAndroid Build Coastguard Workerpublishing {
24*2167191dSAndroid Build Coastguard Worker    publications {
25*2167191dSAndroid Build Coastguard Worker        mavenJava(MavenPublication) {
26*2167191dSAndroid Build Coastguard Worker            pom {
27*2167191dSAndroid Build Coastguard Worker                groupId = 'org.jspecify'
28*2167191dSAndroid Build Coastguard Worker                artifactId = 'jspecify'
29*2167191dSAndroid Build Coastguard Worker                name = 'JSpecify annotations'
30*2167191dSAndroid Build Coastguard Worker                description = 'An artifact of well-named and well-specified annotations to power static analysis checks'
31*2167191dSAndroid Build Coastguard Worker                url = 'http://jspecify.org/'
32*2167191dSAndroid Build Coastguard Worker                from components.java
33*2167191dSAndroid Build Coastguard Worker                licenses {
34*2167191dSAndroid Build Coastguard Worker                    license {
35*2167191dSAndroid Build Coastguard Worker                        name = 'The Apache License, Version 2.0'
36*2167191dSAndroid Build Coastguard Worker                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
37*2167191dSAndroid Build Coastguard Worker                    }
38*2167191dSAndroid Build Coastguard Worker                }
39*2167191dSAndroid Build Coastguard Worker                scm {
40*2167191dSAndroid Build Coastguard Worker                    connection = 'scm:git:[email protected]:jspecify/jspecify.git'
41*2167191dSAndroid Build Coastguard Worker                    developerConnection = 'scm:git:[email protected]:jspecify/jspecify.git'
42*2167191dSAndroid Build Coastguard Worker                    url = 'https://github.com/jspecify/jspecify/'
43*2167191dSAndroid Build Coastguard Worker                }
44*2167191dSAndroid Build Coastguard Worker                developers {
45*2167191dSAndroid Build Coastguard Worker                    // These are here only because Sonatype requires us to list someone.
46*2167191dSAndroid Build Coastguard Worker                    // Any project member is welcome to add themselves if they want to.
47*2167191dSAndroid Build Coastguard Worker                    developer {
48*2167191dSAndroid Build Coastguard Worker                        id = 'kevinb9n'
49*2167191dSAndroid Build Coastguard Worker                        name = 'Kevin Bourrillion'
50*2167191dSAndroid Build Coastguard Worker                        email = '[email protected]'
51*2167191dSAndroid Build Coastguard Worker                    }
52*2167191dSAndroid Build Coastguard Worker                }
53*2167191dSAndroid Build Coastguard Worker            }
54*2167191dSAndroid Build Coastguard Worker        }
55*2167191dSAndroid Build Coastguard Worker    }
56*2167191dSAndroid Build Coastguard Worker}
57*2167191dSAndroid Build Coastguard Worker
58*2167191dSAndroid Build Coastguard WorkernexusPublishing {
59*2167191dSAndroid Build Coastguard Worker    repositories {
60*2167191dSAndroid Build Coastguard Worker        // The following line causes the `The Project.getConvention() method has been deprecated.` warning.
61*2167191dSAndroid Build Coastguard Worker        // 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*2167191dSAndroid Build Coastguard Worker        // I tracked down the deprecation warning to the `sonatype` block, but didn't find a way to avoid the warning.
63*2167191dSAndroid Build Coastguard Worker        sonatype {
64*2167191dSAndroid Build Coastguard Worker            // For users registered in Sonatype after 24 Feb 2021
65*2167191dSAndroid Build Coastguard Worker            nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
66*2167191dSAndroid Build Coastguard Worker            snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
67*2167191dSAndroid Build Coastguard Worker        }
68*2167191dSAndroid Build Coastguard Worker    }
69*2167191dSAndroid Build Coastguard Worker}
70*2167191dSAndroid Build Coastguard Worker
71*2167191dSAndroid Build Coastguard Workerdef privateKey = findProperty('privateKey')
72*2167191dSAndroid Build Coastguard Workerdef pgpPassword = findProperty('pgpPassword')
73*2167191dSAndroid Build Coastguard Worker
74*2167191dSAndroid Build Coastguard Workersigning {
75*2167191dSAndroid Build Coastguard Worker    useInMemoryPgpKeys(privateKey, pgpPassword)
76*2167191dSAndroid Build Coastguard Worker    sign publishing.publications.mavenJava
77*2167191dSAndroid Build Coastguard Worker}
78*2167191dSAndroid Build Coastguard Worker
79*2167191dSAndroid Build Coastguard Workertasks.withType(Sign).configureEach {
80*2167191dSAndroid Build Coastguard Worker    onlyIf {
81*2167191dSAndroid Build Coastguard Worker        privateKey?.trim() && pgpPassword?.trim()
82*2167191dSAndroid Build Coastguard Worker    }
83*2167191dSAndroid Build Coastguard Worker}
84