Skip to content

Commit 2780eea

Browse files
committed
Create scripts to publish to maven
1 parent b2bdd72 commit 2780eea

File tree

2 files changed

+178
-0
lines changed

2 files changed

+178
-0
lines changed

scripts/publish-module.gradle

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
apply plugin: 'org.jetbrains.dokka'
4+
5+
tasks.register('androidSourcesJar', Jar) {
6+
archiveClassifier.set('sources')
7+
if (project.plugins.findPlugin("com.android.library")) {
8+
from android.sourceSets.main.java.srcDirs
9+
from android.sourceSets.main.kotlin.srcDirs
10+
} else {
11+
from sourceSets.main.java.srcDirs
12+
from sourceSets.main.kotlin.srcDirs
13+
}
14+
}
15+
16+
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
17+
pluginsMapConfiguration.set(
18+
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
19+
)
20+
}
21+
22+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
23+
archiveClassifier.set('javadoc')
24+
from dokkaJavadoc.outputDirectory
25+
}
26+
27+
artifacts {
28+
archives androidSourcesJar
29+
archives javadocJar
30+
}
31+
32+
group = PUBLISH_GROUP_ID
33+
version = PUBLISH_VERSION
34+
35+
afterEvaluate {
36+
publishing {
37+
publications {
38+
release(MavenPublication) {
39+
tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("androidSourcesJar") }
40+
groupId PUBLISH_GROUP_ID
41+
artifactId PUBLISH_ARTIFACT_ID
42+
version PUBLISH_VERSION
43+
if (project.plugins.findPlugin("com.android.library")) {
44+
from components.release
45+
} else {
46+
from components.java
47+
}
48+
49+
artifact javadocJar
50+
51+
pom {
52+
name = PUBLISH_ARTIFACT_ID
53+
description = 'Stream Core official Android SDK'
54+
url = 'https://github.com/getstream/stream-android-core'
55+
licenses {
56+
license {
57+
name = 'Stream License'
58+
url = 'https://github.com/GetStream/stream-android-core/blob/main/LICENSE'
59+
}
60+
}
61+
developers {
62+
developer {
63+
id = 'jcminarro'
64+
name = 'Jc Miñarro'
65+
66+
}
67+
developer {
68+
id = 'aleksandar-apostolov'
69+
name = 'Aleksandar Apostolov'
70+
71+
}
72+
developer {
73+
id = 'VelikovPetar'
74+
name = 'Petar Velikov'
75+
76+
}
77+
developer {
78+
id = 'andremion'
79+
name = 'André Mion'
80+
81+
}
82+
developer {
83+
id = 'rahul-lohra'
84+
name = 'Rahul Kumar Lohra'
85+
86+
}
87+
developer {
88+
id = 'gpunto'
89+
name = 'Gianmarco'
90+
91+
}
92+
}
93+
scm {
94+
connection = 'scm:git:github.com/getstream/stream-android-core.git'
95+
developerConnection = 'scm:git:ssh://github.com/getstream/stream-android-core.git'
96+
url = 'https://github.com/getstream/stream-android-core/tree/main'
97+
}
98+
}
99+
}
100+
}
101+
}
102+
}
103+
104+
signing {
105+
useInMemoryPgpKeys(
106+
rootProject.ext["signing.keyId"],
107+
rootProject.ext["signing.key"],
108+
rootProject.ext["signing.password"],
109+
)
110+
sign publishing.publications
111+
}

scripts/publish-root.gradle

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import io.getstream.core.Configuration
2+
3+
// Create variables with empty default values
4+
ext["ossrhUsername"] = ''
5+
ext["ossrhPassword"] = ''
6+
ext["sonatypeStagingProfileId"] = ''
7+
ext["signing.keyId"] = ''
8+
ext["signing.password"] = ''
9+
ext["signing.key"] = ''
10+
ext["snapshot"] = ''
11+
12+
File secretPropsFile = project.rootProject.file('local.properties')
13+
if (secretPropsFile.exists()) {
14+
// Read local.properties file first if it exists
15+
Properties p = new Properties()
16+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
17+
p.each { name, value -> ext[name] = value }
18+
} else {
19+
// Use system environment variables
20+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
21+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
22+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
23+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
24+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
25+
ext["signing.key"] = System.getenv('SIGNING_KEY')
26+
ext["snapshot"] = System.getenv('SNAPSHOT')
27+
}
28+
29+
if (snapshot) {
30+
ext["rootVersionName"] = Configuration.snapshotVersionName
31+
} else {
32+
ext["rootVersionName"] = Configuration.versionName
33+
}
34+
35+
// Set up Sonatype repository
36+
nexusPublishing {
37+
repositories {
38+
sonatype {
39+
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
40+
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
41+
stagingProfileId = sonatypeStagingProfileId
42+
username = ossrhUsername
43+
password = ossrhPassword
44+
version = rootVersionName
45+
}
46+
}
47+
}
48+
49+
tasks.register("printAllArtifacts") {
50+
group = "publishing"
51+
52+
doLast {
53+
subprojects.each { subproject ->
54+
subproject.plugins.withId("maven-publish") {
55+
def publishingExtension = subproject.extensions.findByType(PublishingExtension)
56+
publishingExtension?.publications?.all { publication ->
57+
if (publication instanceof MavenPublication) {
58+
def groupId = publication.groupId
59+
def artifactId = publication.artifactId
60+
def version = publication.version
61+
println("$groupId:$artifactId:$version")
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)