Skip to content

Commit a5684bf

Browse files
authored
feat: automate publishing to maven central in gradle (#145)
1 parent f6dde49 commit a5684bf

File tree

1 file changed

+52
-28
lines changed

1 file changed

+52
-28
lines changed

build.gradle

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,45 +53,69 @@ subprojects {
5353
}
5454
}
5555

56-
plugins.withId("maven-publish") {
57-
publishing {
58-
publications {
59-
maven(MavenPublication) {
60-
pom {
61-
name = project.group + ":" + project.name
62-
url = 'https://github.com/grpc/grpc-kotlin'
63-
afterEvaluate {
64-
// description is not available until evaluated.
65-
description = project.description
66-
}
56+
if (
57+
project.name == "grpc-kotlin-stub"
58+
|| project.name == "grpc-kotlin-compiler"
59+
|| project.name == "grpc-kotlin-stub-lite"
60+
) {
61+
apply plugin: 'maven-publish'
62+
apply plugin: 'signing'
63+
64+
plugins.withId("maven-publish") {
65+
publishing {
66+
publications {
67+
maven(MavenPublication) {
68+
// from components.java
6769

68-
scm {
69-
connection = 'scm:git:https://github.com/grpc/grpc-kotlin.git'
70-
developerConnection = 'scm:git:[email protected]:grpc/grpc-kotlin.git'
70+
pom {
71+
name = project.group + ":" + project.name
7172
url = 'https://github.com/grpc/grpc-kotlin'
72-
}
73+
afterEvaluate {
74+
// description is not available until evaluated.
75+
description = project.description
76+
}
7377

74-
licenses {
75-
license {
76-
name = 'Apache 2.0'
77-
url = 'https://opensource.org/licenses/Apache-2.0'
78+
scm {
79+
connection = 'scm:git:https://github.com/grpc/grpc-kotlin.git'
80+
developerConnection = 'scm:git:[email protected]:grpc/grpc-kotlin.git'
81+
url = 'https://github.com/grpc/grpc-kotlin'
82+
}
83+
84+
licenses {
85+
license {
86+
name = 'Apache 2.0'
87+
url = 'https://opensource.org/licenses/Apache-2.0'
88+
}
7889
}
79-
}
8090

81-
developers {
82-
developer {
83-
id = "grpc.io"
84-
name = "gRPC Contributors"
85-
86-
url = "https://grpc.io/"
87-
organization = "gRPC Authors"
88-
organizationUrl = "https://www.google.com"
91+
developers {
92+
developer {
93+
id = "grpc.io"
94+
name = "gRPC Contributors"
95+
96+
url = "https://grpc.io/"
97+
organization = "gRPC Authors"
98+
organizationUrl = "https://www.google.com"
99+
}
89100
}
90101
}
91102
}
92103
}
104+
repositories {
105+
maven {
106+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
107+
credentials {
108+
username project.findProperty("sonatypeUsername") ?: ""
109+
password project.findProperty("sonatypePassword") ?: ""
110+
}
111+
}
112+
}
93113
}
94114
}
115+
116+
signing {
117+
sign publishing.publications
118+
}
95119
}
96120

97121
tasks.withType(Test) {

0 commit comments

Comments
 (0)