-
Notifications
You must be signed in to change notification settings - Fork 35
KMPPT-91 Integrate SQLDlight in KMP Template #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheKalpeshPawar
wants to merge
10
commits into
openMF:dev
Choose a base branch
from
TheKalpeshPawar:sqldelight_integration
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a7ce9e5
feat(database): integrate SQLDelight for multiplatform database suppo…
TheKalpeshPawar 498fb23
chore(core/database): add license headers and apply code formatting
TheKalpeshPawar 9cdf145
feat(core/database): add SQLDelight integration tests and improve pla…
TheKalpeshPawar 2108f8b
test(core-database): remove redundant comments in SQLDelight reposito…
TheKalpeshPawar b48e700
spotless fixes
TheKalpeshPawar 5dc416b
build(convention): enable SQLDelight migration verification
TheKalpeshPawar 9cec06b
build(database): improve browser detection for Karma tests across pla…
TheKalpeshPawar 2aadd11
feat(database): stabilize SQLDelight initialization and fix JS/WasmJS…
TheKalpeshPawar d4b08a1
Refactor SQLDelight initialization and Koin database module configura…
TheKalpeshPawar 617db3d
style(core): clean up unused imports and formatting in DI modules
TheKalpeshPawar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
build-logic/convention/src/main/kotlin/KMPCoreBaseLibraryConventionPlugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
build-logic/convention/src/main/kotlin/KMPSQLDelightConventionPlugin.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import app.cash.sqldelight.gradle.SqlDelightExtension | ||
| import org.convention.libs | ||
| import org.gradle.api.Plugin | ||
| import org.gradle.api.Project | ||
| import org.gradle.internal.Actions.with | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
|
|
||
| private const val DATABASE_NAME = "MifosSQLDelightDatabase" | ||
|
|
||
| class KMPSQLDelightConventionPlugin : Plugin<Project> { | ||
| override fun apply(target: Project) { | ||
| with(target) { | ||
| pluginManager.apply("app.cash.sqldelight") | ||
|
|
||
| extensions.configure<SqlDelightExtension> { | ||
| databases.create(DATABASE_NAME) { | ||
| packageName.set("org.mifos.core.database") | ||
| generateAsync.set(true) | ||
| schemaOutputDirectory.set( | ||
| file("$projectDir/schemas") | ||
| ) | ||
| verifyMigrations.set(true) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| dependencies { | ||
| add("androidMainImplementation",libs.findLibrary("sqldelight.android.driver").get()) | ||
| add("nativeMainImplementation",libs.findLibrary("sqldelight.native.driver").get()) | ||
| add("desktopMainImplementation",libs.findLibrary("sqldelight.sqlite.driver").get()) | ||
| add("jsMainImplementation",libs.findLibrary("sqldelight.web.worker.driver").get()) | ||
| add("wasmJsMainImplementation",libs.findLibrary("sqldelight.web.worker.driver").get()) | ||
|
|
||
| add("commonMainImplementation", libs.findLibrary("sqldelight.coroutines").get()) | ||
| add("commonMainImplementation", libs.findLibrary("sqldelight.primitive.adapters").get()) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| const path = require("path"); | ||
| const os = require("os"); | ||
| const wasm = require.resolve("sql.js/dist/sql-wasm.wasm").replace(/\\/g, "/"); | ||
|
|
||
| config.files.push({ | ||
| pattern: wasm, | ||
| served: true, | ||
| watched: false, | ||
| included: false, | ||
| nocache: false, | ||
| }); | ||
|
|
||
| if (!config.proxies) { | ||
| config.proxies = {}; | ||
| } | ||
| config.proxies["/sql-wasm.wasm"] = `/absolute${wasm}` | ||
|
|
||
| // Adapted from: https://github.com/ryanclark/karma-webpack/issues/498#issuecomment-790040818 | ||
| const output = { | ||
| path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000), | ||
| } | ||
| config.set({ | ||
| webpack: {...config.webpack, output} | ||
| }); | ||
| config.files.push({ | ||
| pattern: `${output.path}/**/*`, | ||
| watched: false, | ||
| included: false, | ||
| }); | ||
|
|
||
| // TODO: Figure out why on earth this is necessary. Presumably a karma-webpack bug??? | ||
| delete config.webpack.optimization; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| config.resolve = { | ||
| fallback: { | ||
| fs: false, | ||
| path: false, | ||
| crypto: false, | ||
| } | ||
| }; | ||
|
|
||
| const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
| config.plugins.push( | ||
| new CopyWebpackPlugin({ | ||
| patterns: [ | ||
| '../../node_modules/sql.js/dist/sql-wasm.wasm' | ||
| ] | ||
| }) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.