Skip to content

Commit 4b2db74

Browse files
author
Lucas Frossard
committed
adding release script
1 parent 4c55bac commit 4b2db74

File tree

3 files changed

+150
-19
lines changed

3 files changed

+150
-19
lines changed

sdk/build.gradle

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ plugins {
1010
id 'maven-publish'
1111
}
1212

13+
apply from: 'release.gradle'
14+
1315
android {
1416
namespace 'com.whatsapp.otp.android.sdk'
1517
compileSdk 33
@@ -44,22 +46,3 @@ dependencies {
4446
testImplementation 'androidx.test:core:1.5.0'
4547
androidTestImplementation 'junit:junit:4.13.2'
4648
}
47-
48-
publishing {
49-
publications {
50-
mavenJava(MavenPublication) {
51-
groupId = "com.whatsapp.otp"
52-
artifactId = "whatsapp-otp-android-sdk"
53-
version = "0.1.0"
54-
55-
afterEvaluate {
56-
from(components["release"])
57-
}
58-
}
59-
}
60-
repositories {
61-
maven {
62-
mavenLocal()
63-
}
64-
}
65-
}

sdk/gradle.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GROUP=com.whatsapp.otp
2+
LIBRARY_VERSION_NAME=0.1.0
3+
4+
POM_ARTIFACT_ID=whatsapp-otp-android-sdk
5+
POM_NAME=OtpSdk
6+
POM_PACKAGING=aar
7+
POM_DESCRIPTION=WhatsApp Otp SDK for Android Apps
8+
POM_URL=https://github.com/WhatsApp/WhatsApp-Android-OTP-SDK
9+
POM_SCM_URL=https://github.com/WhatsApp/WhatsApp-Android-OTP-SDK.git
10+
POM_SCM_CONNECTION=scm:git:https://github.com/WhatsApp/WhatsApp-Android-OTP-SDK.git
11+
POM_SCM_DEV_CONNECTION=scm:git:[email protected]:WhatsApp/WhatsApp-Android-OTP-SDK.git
12+
POM_LICENSE_NAME=MIT license
13+
POM_LICENSE_URL=https://github.com/WhatsApp/WhatsApp-Android-OTP-SDK/blob/main/LICENSE
14+
POM_LICENSE_DIST=repo
15+
POM_DEVELOPER_ID=whatsapp
16+
POM_DEVELOPER_NAME=WhatsApp

sdk/release.gradle

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
apply plugin: 'maven-publish'
8+
apply plugin: 'signing'
9+
10+
version = LIBRARY_VERSION_NAME
11+
group = GROUP
12+
13+
def isReleaseBuild() {
14+
return LIBRARY_VERSION_NAME.contains("SNAPSHOT") == false
15+
}
16+
17+
def getMavenRepositoryUrl() {
18+
return hasProperty('repositoryUrl') ? property('repositoryUrl') : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
19+
}
20+
21+
def getMavenRepositoryUsername() {
22+
return hasProperty('repositoryUsername') ? property('repositoryUsername') : ""
23+
}
24+
25+
def getMavenRepositoryPassword() {
26+
return hasProperty('repositoryPassword') ? property('repositoryPassword') : ""
27+
}
28+
29+
afterEvaluate { project ->
30+
task androidJavadoc(type: Javadoc) {
31+
source = android.sourceSets.main.java.source
32+
classpath += files(android.getBootClasspath().join(File.pathSeparator))
33+
if (JavaVersion.current().isJava8Compatible()) {
34+
options.addStringOption('Xdoclint:none', '-quiet')
35+
}
36+
if (JavaVersion.current().isJava9Compatible()) {
37+
options.addBooleanOption('html5', true)
38+
}
39+
}
40+
41+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
42+
archiveClassifier = 'javadoc'
43+
from androidJavadoc.destinationDir
44+
}
45+
46+
task androidSourcesJar(type: Jar) {
47+
archiveClassifier = 'sources'
48+
from android.sourceSets.main.java.source
49+
}
50+
51+
artifacts {
52+
archives androidSourcesJar
53+
archives androidJavadocJar
54+
}
55+
56+
android.libraryVariants.all { variant ->
57+
tasks.androidJavadoc.doFirst {
58+
classpath += files(variant.javaCompileProvider.get().classpath.files.join(File.pathSeparator))
59+
}
60+
def name = variant.name.capitalize()
61+
task "jar${name}"(type: Jar, dependsOn: variant.javaCompileProvider) {
62+
from variant.javaCompileProvider.get().destinationDir
63+
}
64+
}
65+
66+
def releaseVariant
67+
android.libraryVariants.all { variant ->
68+
if (variant.buildType.name == 'release') {
69+
releaseVariant = variant.name
70+
}
71+
}
72+
73+
publishing {
74+
publications {
75+
mavenRelease(MavenPublication) {
76+
groupId GROUP
77+
artifactId POM_ARTIFACT_ID
78+
version LIBRARY_VERSION_NAME
79+
80+
from components[releaseVariant]
81+
82+
artifact androidJavadocJar
83+
artifact androidSourcesJar
84+
85+
pom {
86+
name = POM_NAME
87+
description = POM_DESCRIPTION
88+
url = POM_URL
89+
90+
scm {
91+
url = POM_SCM_URL
92+
connection = POM_SCM_CONNECTION
93+
developerConnection = POM_SCM_DEV_CONNECTION
94+
}
95+
96+
licenses {
97+
license {
98+
name = POM_LICENSE_NAME
99+
url = POM_LICENSE_URL
100+
distribution = POM_LICENSE_DIST
101+
}
102+
}
103+
104+
developers {
105+
developer {
106+
id = POM_DEVELOPER_ID
107+
name = POM_DEVELOPER_NAME
108+
}
109+
}
110+
}
111+
}
112+
}
113+
114+
repositories {
115+
mavenLocal()
116+
maven {
117+
url getMavenRepositoryUrl()
118+
credentials(PasswordCredentials) {
119+
username = getMavenRepositoryUsername()
120+
password = getMavenRepositoryPassword()
121+
}
122+
}
123+
}
124+
}
125+
126+
signing {
127+
required { isReleaseBuild() }
128+
publishing.publications.all { publication ->
129+
sign publication
130+
}
131+
}
132+
}

0 commit comments

Comments
 (0)