-
Notifications
You must be signed in to change notification settings - Fork 467
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
chore(android): Bump version for Next storage #1028
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5bf0ab0
bump version, move to ksp
62506db
docs
1d91500
move config, ksp selection
43030a9
bump test app
14f1791
bump robolectric
2be0191
versions
05462de
ksp selection
ab7fe04
packaging
740b477
log config
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 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 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,119 @@ | ||
import java.nio.file.Paths | ||
|
||
def DEFAULT_KOTLIN_VERSION = "1.9.20" | ||
def DEFAULT_ROOM_VERSION = "2.4.3" | ||
|
||
project.ext.AsyncStorageConfig = [ | ||
kotlinVersion : getKotlinVersion(DEFAULT_KOTLIN_VERSION), | ||
kspVersion : getKspVersion(kotlinVersion), | ||
roomVersion : getPropertyOfDefault('AsyncStorage_next_roomVersion', DEFAULT_ROOM_VERSION), | ||
minSdkVersion : safeExtGet('minSdkVersion', 23), | ||
targetSdkVersion : safeExtGet('targetSdkVersion', 32), | ||
compileSdkVersion : safeExtGet('compileSdkVersion', 32), | ||
useNextStorage : getFlagOrDefault("AsyncStorage_useNextStorage", false), | ||
databaseSizeMB : getDatabaseSize(), | ||
isNewArchitectureEnabled: isNewArchitectureEnabled(), | ||
useDedicatedExecutor : getFlagOrDefault('AsyncStorage_dedicatedExecutor', false), | ||
] | ||
|
||
project.ext.AsyncStorageLibs = [ | ||
coroutines : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3", | ||
testCoroutines : "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3", | ||
testJunit : "junit:junit:4.13.2", | ||
testRunner : "androidx.test:runner:1.4.0", | ||
testRules : "androidx.test:rules:1.4.0", | ||
testExtJunit : "androidx.test.ext:junit:1.1.3", | ||
testRobolectric: "org.robolectric:robolectric:4.11.1", | ||
testTruth : "com.google.truth:truth:1.1.3", | ||
] | ||
|
||
|
||
def getKotlinVersion(String defaultVersion) { | ||
return rootProject.ext.has('kotlinVersion') | ||
? rootProject.ext['kotlinVersion'] | ||
: rootProject.hasProperty('AsyncStorage_kotlinVersion') | ||
? rootProject.properties['AsyncStorage_kotlinVersion'] | ||
: defaultVersion | ||
} | ||
|
||
def isNewArchitectureEnabled() { | ||
// To opt-in for the New Architecture, you can either: | ||
// - Set `newArchEnabled` to true inside the `gradle.properties` file | ||
// - Invoke gradle with `-newArchEnabled=true` | ||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` | ||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" | ||
} | ||
|
||
String getKspVersion(String kotlinVersion) { | ||
|
||
String overriddenKspVersion = getPropertyOfDefault("AsyncStorage_next_kspVersion", null) | ||
if (overriddenKspVersion != null) { | ||
return overriddenKspVersion | ||
} | ||
// https://github.com/google/ksp/releases | ||
def kspVersions = [ | ||
"1.9.20-1.0.14", | ||
"1.9.10-1.0.13", | ||
"1.9.0-1.0.13", | ||
"1.8.22-1.0.11", | ||
"1.8.21-1.0.11", | ||
"1.8.20-1.0.11", | ||
"1.8.10-1.0.9", | ||
"1.8.0-1.0.9", | ||
"1.7.22-1.0.8", | ||
"1.7.21-1.0.8", | ||
"1.7.20-1.0.8", | ||
"1.7.10-1.0.6", | ||
"1.7.0-1.0.6", | ||
"1.6.21-1.0.6", | ||
"1.6.20-1.0.5", | ||
"1.6.10-1.0.4", | ||
"1.6.0-1.0.2", | ||
"1.5.31-1.0.1", | ||
"1.5.30-1.0.0", | ||
] | ||
|
||
return kspVersions.find { it.startsWith(kotlinVersion) } ?: kspVersions.first() | ||
} | ||
|
||
// AsyncStorage has default size of 6MB. | ||
// This is a sane limit to protect the user from the app storing too much data in the database. | ||
// This also protects the database from filling up the disk cache and becoming malformed. | ||
// If you really need bigger size, please keep in mind the potential consequences. | ||
long getDatabaseSize() { | ||
long dbSizeInMB = 6L | ||
def newDbSize = getPropertyOfDefault('AsyncStorage_db_size_in_MB', null) | ||
if (newDbSize != null && newDbSize.isLong()) { | ||
dbSizeInMB = newDbSize.toLong() | ||
} | ||
return dbSizeInMB | ||
} | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
def getFlagOrDefault(flagName, defaultValue) { | ||
rootProject.hasProperty(flagName) ? rootProject.properties[flagName] == "true" : defaultValue | ||
} | ||
|
||
def getPropertyOfDefault(String flagName, String defaultVersion) { | ||
rootProject.hasProperty(flagName) ? rootProject.properties[flagName] : defaultVersion | ||
} | ||
|
||
ext.resolveModulePath = { packageName -> | ||
def basePath = rootDir.toPath().normalize() | ||
|
||
// Node's module resolution algorithm searches up to the root directory, | ||
// after which the base path will be null | ||
while (basePath) { | ||
def candidatePath = Paths.get(basePath.toString(), 'node_modules', packageName) | ||
if (candidatePath.toFile().exists()) { | ||
return candidatePath.toString() | ||
} | ||
|
||
basePath = basePath.getParent() | ||
} | ||
|
||
return null | ||
} |
This file contains 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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some weird reason, the
src
dir was not added, so had to add all and exclude build filesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be related to the rewrite of the glob implementation in npm 9. We've hit issues with it as well: npm/npm-packlist#152
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not cool!