|
6 | 6 | import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
7 | 7 | import org.gradle.api.tasks.testing.logging.TestLogEvent |
8 | 8 |
|
| 9 | +val ciSigningKey: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY") |
| 10 | +val ciSigningPassword: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY_PASSWORD") |
| 11 | +val shouldSignRelease: Boolean |
| 12 | + get() = !ciSigningKey.isNullOrEmpty() && !ciSigningPassword.isNullOrEmpty() |
| 13 | + |
9 | 14 | plugins { |
10 | 15 | alias(libs.plugins.google.protobuf) |
11 | 16 | checkstyle |
12 | 17 | `maven-publish` |
| 18 | + signing |
13 | 19 | } |
14 | 20 |
|
15 | 21 | java { |
@@ -112,47 +118,79 @@ protobuf { |
112 | 118 | // Run "./gradlew publishReleasePublicationToLocalRepository" to generate release JARs locally |
113 | 119 | publishing { |
114 | 120 | publications { |
| 121 | + val mavenGroupId = "net.newpipe" |
| 122 | + val mavenArtifactId = "extractor" |
| 123 | + fun MavenPublication.setupPOM() = pom { |
| 124 | + name = "NewPipe Extractor" |
| 125 | + description = "A library for extracting data from streaming websites, used in NewPipe" |
| 126 | + url = "https://github.com/TeamNewPipe/NewPipeExtractor" |
| 127 | + |
| 128 | + licenses { |
| 129 | + license { |
| 130 | + name = "GNU GENERAL PUBLIC LICENSE, Version 3" |
| 131 | + url = "https://www.gnu.org/licenses/gpl-3.0.txt" |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + scm { |
| 136 | + url = "https://github.com/TeamNewPipe/NewPipeExtractor" |
| 137 | + connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git" |
| 138 | + developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git" |
| 139 | + } |
| 140 | + |
| 141 | + developers { |
| 142 | + developer { |
| 143 | + id = "newpipe" |
| 144 | + name = "Team NewPipe" |
| 145 | + email = "team@newpipe.net" |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + |
115 | 150 | create<MavenPublication>("release") { |
116 | | - groupId = "net.newpipe" |
117 | | - artifactId = "extractor" |
| 151 | + groupId = mavenGroupId |
| 152 | + artifactId = mavenArtifactId |
118 | 153 | version = rootProject.version.toString() |
119 | 154 |
|
120 | 155 | afterEvaluate { |
121 | 156 | from(components["java"]) |
122 | 157 | } |
123 | 158 |
|
124 | | - pom { |
125 | | - name = "NewPipe Extractor" |
126 | | - description = "A library for extracting data from streaming websites, used in NewPipe" |
127 | | - url = "https://github.com/TeamNewPipe/NewPipeExtractor" |
128 | | - |
129 | | - licenses { |
130 | | - license { |
131 | | - name = "GNU GENERAL PUBLIC LICENSE, Version 3" |
132 | | - url = "https://www.gnu.org/licenses/gpl-3.0.txt" |
133 | | - } |
134 | | - } |
135 | | - |
136 | | - scm { |
137 | | - url = "https://github.com/TeamNewPipe/NewPipeExtractor" |
138 | | - connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git" |
139 | | - developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git" |
140 | | - } |
| 159 | + setupPOM() |
| 160 | + } |
| 161 | + create<MavenPublication>("snapshot") { |
| 162 | + groupId = mavenGroupId |
| 163 | + artifactId = mavenArtifactId |
| 164 | + version = "${rootProject.version}-SNAPSHOT" |
141 | 165 |
|
142 | | - developers { |
143 | | - developer { |
144 | | - id = "newpipe" |
145 | | - name = "Team NewPipe" |
146 | | - email = "team@newpipe.net" |
147 | | - } |
148 | | - } |
| 166 | + afterEvaluate { |
| 167 | + from(components["java"]) |
149 | 168 | } |
| 169 | + |
| 170 | + setupPOM() |
150 | 171 | } |
151 | 172 | repositories { |
| 173 | + maven { |
| 174 | + name = "sonatype" |
| 175 | + url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") |
| 176 | + credentials { |
| 177 | + username = System.getenv("SONATYPE_MAVEN_CENTRAL_USERNAME") |
| 178 | + password = System.getenv("SONATYPE_MAVEN_CENTRAL_PASSWORD") |
| 179 | + } |
| 180 | + } |
152 | 181 | maven { |
153 | 182 | name = "local" |
154 | 183 | url = uri(layout.buildDirectory.dir("maven")) |
155 | 184 | } |
156 | 185 | } |
157 | 186 | } |
158 | 187 | } |
| 188 | + |
| 189 | +signing { |
| 190 | + useInMemoryPgpKeys(ciSigningKey, ciSigningPassword) |
| 191 | + sign(publishing.publications["snapshot"]) |
| 192 | +} |
| 193 | + |
| 194 | +tasks.withType<Sign> { |
| 195 | + onlyIf("Signing credentials are present (only used for maven central)") { shouldSignRelease } |
| 196 | +} |
0 commit comments