I am in a bit of a pickle. My SQLiteOpenHelper
's onCreate()
method takes too long (60+ seconds). To fix this, I need to bundle an already created .db file as an asset. Unfortunately, I have too many Android dependencies in my onCreate()
method (Content Values, etc), so I cannot create my .db
file on its own without emulating Android.
Here's my plan - create two different SQLiteOpenHelper
s - one for the initial database creation that will generate a .db
file, and the second openHelper
to consume that file. Every end user of my app will only ever use the second openHelper
, but my Gradle build script will use the first openHelper
.
What type of Gradle logic could be used to accomplish this? The steps would be:
- run the first
SQLiteOpenHelper
to capture the.db
file (maybe use Roblectric to run theonCreate()
on the JVM) - copy the
.db
file to my apps/assets
directory - Rebuild my app a final time with the newly generated
.db
file
Is Gradle even capable of solving something like this?
- Note: I know that this is bad design and I am in circular dependency hell. If I was allowed the time (I am not), I would build the initial
.db
file as a separate submodule. - Note2: Ultimately, I would like to be able to build my app with
./gradlew clean build
Aucun commentaire:
Enregistrer un commentaire