Skip to content
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

Closed
nagkumar opened this issue Jun 1, 2021 · 3 comments
Closed

method calls conversion not done right #40

nagkumar opened this issue Jun 1, 2021 · 3 comments

Comments

@nagkumar
Copy link

nagkumar commented Jun 1, 2021

minSdkVersion(24)
targetSdkVersion(30)

above should be converted to

minSdk = 24
targetSdk = 30
@johanno
Copy link

johanno commented Jan 28, 2022

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"
    }
 ...

@5peak2me
Copy link
Contributor

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
        }
    }
}

@bernaferrari
Copy link
Owner

Thanks @5peak2me! I'll check and integrate your proposal.

5peak2me added a commit to 5peak2me/GradleKotlinConverter that referenced this issue Jun 29, 2022
bernaferrari pushed a commit that referenced this issue Jun 29, 2022
* Fix [#38](#38)

* Fix [#40](#40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants