Skip to content

Commit 50acc7b

Browse files
authored
Merge pull request #661 from Aiven-Open/jeqo/publish-sonatype
chore(build): publish to sonatype
2 parents b61ce81 + fd15357 commit 50acc7b

File tree

2 files changed

+117
-4
lines changed

2 files changed

+117
-4
lines changed

build.gradle

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ subprojects {
5858
apply plugin: 'info.solidsoft.pitest'
5959

6060
apply plugin: "maven-publish"
61+
apply plugin: "signing"
6162

6263
repositories {
6364
// Use Maven Central for resolving dependencies.
@@ -224,15 +225,92 @@ subprojects {
224225
}
225226

226227
publishing {
228+
repositories {
229+
maven {
230+
name="sonatype"
231+
232+
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
233+
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
234+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
235+
236+
credentials(PasswordCredentials)
237+
}
238+
}
227239
publications {
228240
mavenJava(MavenPublication) {
229241
from components.java
242+
243+
pom {
244+
url = "https://github.com/Aiven-Open/tiered-storage-for-apache-kafka"
245+
organization {
246+
name = "Aiven Oy"
247+
url = "https://aiven.io"
248+
}
249+
250+
licenses {
251+
license {
252+
name = "Apache 2.0"
253+
url = "http://www.apache.org/licenses/LICENSE-2.0"
254+
distribution = "repo"
255+
}
256+
}
257+
258+
developers {
259+
developer {
260+
id = 'aiven'
261+
name = 'Aiven Opensource'
262+
email = 'opensource@aiven.io'
263+
}
264+
}
265+
266+
scm {
267+
connection = 'scm:git:git://github.com:Aiven-Open/tiered-storage-for-apache-kafka.git'
268+
developerConnection = 'scm:git:ssh://github.com:Aiven-Open/tiered-storage-for-apache-kafka.git'
269+
url = 'https://github.com/Aiven-Open/tiered-storage-for-apache-kafka'
270+
}
271+
}
272+
230273
afterEvaluate {
231274
groupId = "io.aiven"
232275
artifactId = "tiered-storage-for-apache-kafka-${archivesBaseName}"
233276
}
234277
}
235278
}
279+
280+
signing {
281+
sign publishing.publications.mavenJava
282+
useGpgCmd()
283+
// Some issue in the plugin:
284+
// GPG outputs already armored signatures. The plugin also does armoring for `asc` files.
285+
// This results in double armored signatures, i.e. garbage.
286+
// Override the signature type provider to use unarmored output for `asc` files, which works well with GPG.
287+
signatureTypes = new AbstractSignatureTypeProvider() {
288+
{
289+
BinarySignatureType binary = new BinarySignatureType() {
290+
@Override
291+
String getExtension() {
292+
return "asc"
293+
}
294+
}
295+
register(binary)
296+
setDefaultType(binary.getExtension())
297+
}
298+
}
299+
}
300+
}
301+
302+
// Skip test fixtures from distribution archives
303+
afterEvaluate { proj ->
304+
// Skip test fixtures from distributions
305+
proj.distributions.all {
306+
contents {
307+
// Exclude any test fixtures JARs from the distribution
308+
exclude { element ->
309+
element.file.name.contains('test-fixtures')
310+
element.file.name.contains('sources')
311+
}
312+
}
313+
}
236314
}
237315
}
238316

@@ -299,3 +377,42 @@ tasks.register('validateDependencies') {
299377
//tasks.named("check") {
300378
// dependsOn(tasks.named("validateDependencies"))
301379
//}
380+
381+
// Define the list of modules to be published
382+
def modulesToPublish = [
383+
':commons',
384+
':core',
385+
':storage:core',
386+
':storage:filesystem',
387+
':storage:s3',
388+
':storage:gcs',
389+
':storage:azure',
390+
]
391+
392+
// Define and configure the publishToSonatype task
393+
tasks.register("publishToSonatype") {
394+
description = 'Publishes selected modules to Sonatype repository'
395+
group = 'publishing'
396+
dependsOn(tasks.named("distTar"))
397+
398+
doFirst {
399+
println "Publishing selected modules to Sonatype..."
400+
}
401+
}
402+
403+
// Configure task dependencies after all projects are evaluated
404+
gradle.projectsEvaluated {
405+
tasks.named("publishToSonatype") {
406+
modulesToPublish.each { modulePath ->
407+
def moduleProject = modulePath == ':' ? rootProject : project(modulePath)
408+
def taskName = "${moduleProject.path}:publish${modulePath == ':' ? 'Maven' : 'MavenJava'}PublicationToSonatypeRepository"
409+
410+
try {
411+
dependsOn(taskName)
412+
println "Added $taskName"
413+
} catch (Exception e) {
414+
println "Warning: Publication task not found for ${modulePath}"
415+
}
416+
}
417+
}
418+
}

storage/core/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,3 @@ dependencies {
3333

3434
testFixturesImplementation "org.testcontainers:junit-jupiter:$testcontainersVersion"
3535
}
36-
37-
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
38-
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
39-

0 commit comments

Comments
 (0)