-
Notifications
You must be signed in to change notification settings - Fork 60
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
method calls conversion not done right #40
Comments
Almost same Issue: android {
compileSdk 31
defaultConfig {
applicationId "some.name"
minSdk 30
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
... was converted to android {
compileSdk 31
defaultConfig {
applicationId = "some.name"
minSdk 30
targetSdk 31
versionCode 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
... but should be: android {
compileSdk = 31
defaultConfig {
applicationId = "some.name"
minSdk = 30
targetSdk = 31
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
... |
it can fix by following code. in gradlekotlinconverter.kts fun String.addEquals(): String {
val compileSdk = "compileSdk"
val signing = "keyAlias|keyPassword|storeFile|storePassword"
val other = "multiDexEnabled|correctErrorTypes|javaMaxHeapSize|jumboMode|dimension|useSupportLibrary"
val databinding = "dataBinding|viewBinding"
val defaultConfig = "applicationId|minSdk|targetSdk|versionCode|versionName|testInstrumentationRunner"
val negativeLookAhead = "(?!\\{)[^\\s]" // Don't want '{' as next word character
val versionExp = """($compileSdk|$defaultConfig|$signing|$other|$databinding)\s*${negativeLookAhead}.*""".toRegex()
return this.replace(versionExp) {
val split = it.value.split(" ")
// if there is more than one whitespace, the last().toIntOrNull() will find.
if (split.lastOrNull { it.isNotBlank() } != null) {
"${split[0]} = ${split.last()}"
} else {
it.value
}
}
} |
Thanks @5peak2me! I'll check and integrate your proposal. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
above should be converted to
The text was updated successfully, but these errors were encountered: