Skip to content

Commit

Permalink
Decouple SQLite implementation from main Android artifact, and publis…
Browse files Browse the repository at this point in the history
…h a BOM.

Signed-off-by: Kenneth J. Shackleton <[email protected]>
  • Loading branch information
kennethshackleton committed Feb 4, 2024
1 parent 43b9628 commit b81814c
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 14 deletions.
8 changes: 6 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
}

dependencies {
implementation("com.bloomberg:selekt-android:<version>")
implementation(platform("com.bloomberg:selekt-bom:<version>"))
implementation("com.bloomberg:selekt-android")
implementation("com.bloomberg:selekt-android-sqlcipher")
}
```

Expand All @@ -20,7 +22,9 @@
}

dependencies {
implementation 'com.bloomberg:selekt-android:<version>'
implementation platform('com.bloomberg:selekt-bom:<version>'))
implementation 'com.bloomberg:selekt-android'
implementation 'com.bloomberg:selekt-android-sqlcipher'
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
selekt.versionName=0.21.0
selekt.nextVersionName=0.22.0
selekt.versionName=0.22.0
selekt.nextVersionName=0.23.0

openssl.version=3.1.2
openssl.sha256=a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539
Expand Down
7 changes: 7 additions & 0 deletions selekt-android-sqlcipher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ logger.quiet("SQLCipher version: {}", sqlcipherVersionName)

plugins {
id("com.android.library")
id("kotlin-android")
`maven-publish`
signing
id("io.gitlab.arturbosch.detekt")
Expand Down Expand Up @@ -49,6 +50,7 @@ android {
}
}
release {
isMinifyEnabled = false
ndk {
abiFilters.addAll(allABIs)
}
Expand All @@ -65,6 +67,11 @@ android {
}
}

dependencies {
implementation(projects.selektJava)
implementation(projects.selektSqlite3Classes)
}

allABIs.forEach { abi ->
tasks.matching {
it is ExternalNativeBuildJsonTask && it.name.contains(abi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

package com.bloomberg.selekt.android

import com.bloomberg.selekt.ExternalSQLite
import com.bloomberg.selekt.SQLite
import com.bloomberg.selekt.commons.loadEmbeddedLibrary
import com.bloomberg.selekt.externalSQLiteSingleton

private const val CAN_USE_EMBEDDED_PROPERTY_KEY = "com.bloomberg.selekt.lib.can_use_embedded"

internal val sqlite = externalSQLiteSingleton {
fun loadSQLite(): ExternalSQLite = externalSQLiteSingleton {
"selekt".let {
try {
System.loadLibrary(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.bloomberg.selekt.android

import com.bloomberg.selekt.ExternalSQLite
import com.bloomberg.selekt.externalSQLiteSingleton

internal val sqlite = externalSQLiteSingleton()
fun loadSQLite(): ExternalSQLite = externalSQLiteSingleton()
10 changes: 2 additions & 8 deletions selekt-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,11 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
buildConfigField("Boolean", "USE_EMBEDDED_LIBS", "true")
}
release {
isMinifyEnabled = false
buildConfigField("Boolean", "USE_EMBEDDED_LIBS", "false")
buildConfigField("String", "gitCommitSha1", "\"${gitCommit()}\"")
}
}
arrayOf("debug", "main", "release", "test").forEach {
sourceSets[it].java.srcDir("src/$it/kotlin")
}
sourceSets["test"].resources.srcDir(layout.buildDirectory.dir("intermediates/libs"))
publishing {
singleVariant("release") {
Expand All @@ -65,15 +58,16 @@ android {

dependencies {
api(projects.selektApi)
compileOnly(projects.selektAndroidSqlcipher)
compileOnly(androidX("room", "runtime", Versions.ANDROIDX_ROOM.version))
implementation(projects.selektAndroidSqlcipher)
implementation(projects.selektJava)
implementation(projects.selektSqlite3Classes)
kaptTest(androidX("room", "compiler", Versions.ANDROIDX_ROOM.version))
testImplementation(androidX("lifecycle", "livedata-ktx", Versions.ANDROIDX_LIVE_DATA.version))
testImplementation(androidX("room", "runtime", Versions.ANDROIDX_ROOM.version))
testImplementation(androidX("room", "ktx", Versions.ANDROIDX_ROOM.version))
testImplementation("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT5}")
testRuntimeOnly(projects.selektAndroidSqlcipher)
testRuntimeOnly("org.robolectric:android-all:${Versions.ROBOLECTRIC_ANDROID_ALL}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import com.bloomberg.selekt.SQL_RANGE
import com.bloomberg.selekt.SQL_READONLY
import com.bloomberg.selekt.SQL_TOO_BIG

internal val sqlite = loadSQLite()

object Selekt {
internal const val TAG = "SLKT"

Expand Down
45 changes: 45 additions & 0 deletions selekt-bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2024 Bloomberg Finance L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
`java-platform`
`maven-publish`
}

dependencies {
constraints {
projects.run {
listOf(
selektAndroid,
selektAndroidLint,
selektAndroidSqlcipher,
selektApi,
selektJava,
selektSqlite3Classes
)
}.forEach(::api)
}
}

publishing {
publications.register<MavenPublication>("main") {
from(components.getByName("javaPlatform"))
pom {
commonInitialisation(project)
description.set("Selekt BOM.")
}
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include(":selekt-android")
include(":selekt-android-lint")
include(":selekt-android-sqlcipher")
include(":selekt-api")
include(":selekt-bom")
include(":selekt-java")
include(":selekt-sqlite3")
include(":selekt-sqlite3-classes")
Expand Down

0 comments on commit b81814c

Please sign in to comment.