Skip to content

Commit

Permalink
Upgrade kotlin version to 1.3.61, build caching, and publishing impro…
Browse files Browse the repository at this point in the history
…vements (#39)
  • Loading branch information
noheltcj authored Dec 8, 2019
1 parent 10515b7 commit 68bec4c
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 26 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api("com.noheltcj:rxcommon:0.6.0")
api("com.noheltcj:rxcommon:0.6.1")
}
}
}
Expand All @@ -96,7 +96,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
api 'com.noheltcj:rxcommon:0.6.0'
api 'com.noheltcj:rxcommon:0.6.1'
}
}
}
Expand All @@ -115,6 +115,7 @@ we will be keeping up with this support map going forward.
0.5.2 -> 1.3.30
0.5.3 -> 1.3.31
0.6.0 -> 1.3.50
0.6.1 -> 1.3.61
```

### Objective-C Generics
Expand Down
15 changes: 15 additions & 0 deletions buildSrc/src/main/java/BuildCacheExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import org.gradle.caching.http.HttpBuildCache
import org.gradle.kotlin.dsl.KotlinSettingsScript
import java.net.URI

fun KotlinSettingsScript.setupBuildCache() {
buildCache {
val localBuildCacheUrl = Properties.gradleLocalBuildCacheUrl
if (!localBuildCacheUrl.isNullOrEmpty()) {
println("Using local build cache located at: $localBuildCacheUrl")
local(HttpBuildCache::class.java) {
url = URI(localBuildCacheUrl)
}
}
}
}
43 changes: 34 additions & 9 deletions buildSrc/src/main/java/Properties.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
import org.gradle.api.Project
import java.io.File

object Properties {
val isRelease by lazy {
System.getenv("release") == "true"
private val properties = java.util.Properties()

init {
val home = System.getenv("HOME")
properties.apply {
loadPropertiesIfExists("local.properties")
home?.also {
loadPropertiesIfExists("$it/.gradle/gradle.properties")
}
}
}

val ossrhUsername by lazy {
optionalProperty("ossrhUsername")
}

val ossrhPassword by lazy {
optionalProperty("ossrhPassword")
}

val gradleLocalBuildCacheUrl by lazy {
optionalProperty("GRADLE_LOCAL_BUILD_CACHE_URL")
}

fun Project.requiredForReleaseProperty(name: String) =
private fun optionalProperty(name: String): String? =
properties[name] as String?
?: let {
if (isRelease)
throw RuntimeException("Missing property $name")
return ""
?: System.getenv(name)

private fun java.util.Properties.loadPropertiesIfExists(propertiesFile: String) {
val localPropertiesFile = File(propertiesFile)
if (localPropertiesFile.exists()) {
localPropertiesFile.inputStream().use {
load(it)
}
}
}
}
}
20 changes: 9 additions & 11 deletions buildSrc/src/main/java/Publishing.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
@file:Suppress("UnstableApiUsage")

import Properties.requiredForReleaseProperty
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import java.net.URI

object Publishing {
val shouldSign get() =
Properties.ossrhPassword != null && Properties.ossrhUsername != null

fun PublishingExtension.addRepositories(project: Project) {
repositories {
val ossrhUsername = Properties.ossrhUsername ?: return@repositories
val ossrhPassword = Properties.ossrhPassword ?: return@repositories

maven {
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"

url = URI(
if (Properties.isRelease) {
releasesRepoUrl
} else {
snapshotsRepoUrl
}
)
url = URI(releasesRepoUrl)

authentication {
credentials {
username = project.requiredForReleaseProperty("ossrhUsername")
password = project.requiredForReleaseProperty("ossrhPassword")
username = ossrhUsername
password = ossrhPassword
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Versions {
const val rxcommon = "0.6.0"
const val kotlin = "1.3.50"
const val rxcommon = "0.6.1"
const val kotlin = "1.3.61"
const val dokka = "0.10.0"

object Android {
Expand Down
4 changes: 2 additions & 2 deletions rxcommon-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
compileSdkVersion(29)

defaultConfig {
minSdkVersion(18)
minSdkVersion(16)
targetSdkVersion(29)
versionCode = 1
versionName = Versions.rxcommon
Expand Down Expand Up @@ -173,7 +173,7 @@ publishing {
}

signing {
if (Properties.isRelease) {
if (Publishing.shouldSign) {
sign(publishing.publications)
}
}
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ rootProject.buildFileName = "build.gradle.kts"
include(":rxcommon-core")

enableFeaturePreview("GRADLE_METADATA")

setupBuildCache()

0 comments on commit 68bec4c

Please sign in to comment.