Skip to content

Commit 1e25864

Browse files
authored
Merge pull request #11 from phansier/deploy
Publish library to MavenCentral
2 parents ff54df2 + e9a3155 commit 1e25864

7 files changed

Lines changed: 133 additions & 112 deletions

File tree

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# FlowReactiveNetwork on Coroutines
2-
[![Download](https://api.bintray.com/packages/andreyberyukhov/FlowReactiveNetwork/FlowReactiveNetwork/images/download.svg) ](https://bintray.com/andreyberyukhov/FlowReactiveNetwork/FlowReactiveNetwork/_latestVersion)
2+
[![Download](https://api.bintray.com/packages/andreyberyukhov/FlowReactiveNetwork/FlowReactiveNetwork/images/download.svg) ](https://repo1.maven.org/maven2/ru/beryukhov/flowreactivenetwork/1.0.3/)
33
[![Kotlin Version](https://img.shields.io/badge/Kotlin-1.4.30-blue.svg)](https://kotlinlang.org)
44

55
[![kotlinweekly](https://img.shields.io/badge/kotlinweekly.net-204-blue.svg)](https://mailchi.mp/kotlinweekly/kotlin-weekly-204)
@@ -22,13 +22,11 @@ You can depend on the library through Gradle:
2222
dependencies {
2323
implementation 'ru.beryukhov:flowreactivenetwork:1.0.2'
2424
}
25-
// as for the library is not available in jcenter yet
25+
// now the library is available in mavenCentral()
2626
allprojects {
2727
repositories {
2828
//...
29-
maven {
30-
url "https://dl.bintray.com/andreyberyukhov/FlowReactiveNetwork"
31-
}
29+
mavenCentral() // should probably be here already
3230
}
3331
}
3432
```

build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ buildscript {
55

66
repositories {
77
google()
8-
jcenter()
8+
mavenCentral()
99
}
1010
dependencies {
11-
classpath("com.android.tools.build:gradle:4.1.2")
11+
classpath("com.android.tools.build:gradle:4.1.3")
1212
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
13-
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
1413
}
1514
}
1615

1716
allprojects {
1817
repositories {
1918
google()
19+
mavenCentral()
2020
jcenter()
21-
maven(url = "https://dl.bintray.com/andreyberyukhov/FlowReactiveNetwork")
2221
}
2322
}
2423

24+
plugins {
25+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
26+
}
27+
2528
task<Delete>("clean") {
2629
delete(rootProject.buildDir)
2730
}

deploy.gradle

Lines changed: 0 additions & 101 deletions
This file was deleted.

reactiveNetwork/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ android {
6161

6262
}
6363

64-
apply {from("../deploy.gradle")}
64+
apply {from("${rootProject.projectDir}/scripts/publish-root.gradle")}
65+
apply {from("${rootProject.projectDir}/scripts/publish-module.gradle")}

sample/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies {
4040
implementation("com.google.android.material:material:1.2.1")
4141
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
4242

43-
implementation("ru.beryukhov:flowreactivenetwork:1.0.2")
43+
implementation("ru.beryukhov:flowreactivenetwork:1.0.3")
4444
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.extra["coroutines_version"]}")
4545
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${rootProject.extra["coroutines_version"]}")
4646

scripts/publish-module.gradle

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
ext {
5+
PUBLISH_GROUP_ID = 'ru.beryukhov'
6+
PUBLISH_VERSION = '1.0.3'
7+
PUBLISH_ARTIFACT_ID = 'flowreactivenetwork'
8+
}
9+
10+
task androidSourcesJar(type: Jar) {
11+
archiveClassifier.set('sources')
12+
if (project.plugins.findPlugin("com.android.library")) {
13+
// For Android libraries
14+
from android.sourceSets.main.java.srcDirs
15+
from android.sourceSets.main.kotlin.srcDirs
16+
} else {
17+
// For pure Kotlin libraries, in case you have them
18+
from sourceSets.main.java.srcDirs
19+
from sourceSets.main.kotlin.srcDirs
20+
}
21+
}
22+
23+
artifacts {
24+
archives androidSourcesJar
25+
}
26+
27+
group = PUBLISH_GROUP_ID
28+
version = PUBLISH_VERSION
29+
30+
afterEvaluate {
31+
publishing {
32+
publications {
33+
release(MavenPublication) {
34+
groupId PUBLISH_GROUP_ID
35+
artifactId PUBLISH_ARTIFACT_ID
36+
version PUBLISH_VERSION
37+
38+
// Two artifacts, the `aar` (or `jar`) and the sources
39+
if (project.plugins.findPlugin("com.android.library")) {
40+
from components.release
41+
} else {
42+
from components.java
43+
}
44+
45+
artifact androidSourcesJar
46+
//artifact javadocJar
47+
48+
pom {
49+
name = PUBLISH_ARTIFACT_ID
50+
description = 'Android library listening network connection state and Internet connectivity with Coroutines Flow'
51+
url = 'https://github.com/phansier/FlowReactiveNetwork'
52+
licenses {
53+
license {
54+
name = 'Apache-2.0 License'
55+
url = 'https://github.com/phansier/FlowReactiveNetwork/blob/master/LICENSE'
56+
}
57+
}
58+
developers {
59+
developer {
60+
id = 'phansier'
61+
name = 'Andrey Beryukhov'
62+
email = 'beryukhov-andrey@yandex.ru'
63+
}
64+
}
65+
scm {
66+
connection = 'scm:git:github.com/phansier/FlowReactiveNetwork.git'
67+
developerConnection = 'scm:git:ssh://github.com/phansier/FlowReactiveNetwork.git'
68+
url = 'https://github.com/phansier/FlowReactiveNetwork/tree/main'
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
76+
signing {
77+
useInMemoryPgpKeys(
78+
//todo refine use of ext here
79+
"rootProject.ext[\"signing.keyId\"]",
80+
"rootProject.ext[\"signing.key\"]",
81+
"rootProject.ext[\"signing.password\"]",
82+
)
83+
sign publishing.publications
84+
}

scripts/publish-root.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ext["signing.keyId"] = ''
2+
ext["signing.password"] = ''
3+
ext["signing.key"] = ''
4+
ext["ossrhUsername"] = ''
5+
ext["ossrhPassword"] = ''
6+
ext["sonatypeStagingProfileId"] = ''
7+
8+
File secretPropsFile = project.rootProject.file('local.properties')
9+
if (secretPropsFile.exists()) {
10+
// Read local.properties file first if it exists
11+
Properties p = new Properties()
12+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
13+
p.each { name, value -> ext[name] = value }
14+
} else {
15+
// Use system environment variables
16+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
17+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
18+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
19+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
20+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
21+
ext["signing.key"] = System.getenv('SIGNING_KEY')
22+
}
23+
24+
// Set up Sonatype repository
25+
nexusPublishing {
26+
repositories {
27+
sonatype {
28+
stagingProfileId = sonatypeStagingProfileId
29+
username = ossrhUsername
30+
password = ossrhPassword
31+
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
32+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
33+
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)