Giter VIP home page Giter VIP logo

gradlekotlinconverter's Introduction

Hi there ๐Ÿ‘‹

It is hard to describe myself. I have extensive experience making random things. You won't find two projects that look or work the same in my profile, and I hope that's a good thing for you. :)

Right now, I'm happy working in design to code.

  • ๐Ÿ”ญ Iโ€™m currently investigating the bridge between developers and designers.
  • ๐Ÿ’ฌ Ask me about mobile, web, or anything random.
  • ๐Ÿ˜Ž Feel free to reach me on Twitter, Reddit or anywhere!

Visitor count

gradlekotlinconverter's People

Contributors

5peak2me avatar arberg avatar bernaferrari avatar code-schreiber avatar imgbotapp avatar islamsalah avatar jasonjoneski avatar mherod avatar pavi2410 avatar simtop avatar whosnickdoglio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradlekotlinconverter's Issues

Shebang

Hi,

I'm on Arch Linux using Kotlin 1.4.0.

If I run ./gradlekotlinconverter.kts I get this error message:

usr/bin/env: 'kotlinc -script': No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines

But if I change the first line in gradlekotlinconverter.kts from this:

#!/usr/bin/env kotlinc -script

to this:

#!/usr/bin/kotlinc -script

it works!

convert dependencyResolutionManagement.versionCatalogs in settings.gradle to settings.gradle.kts

Just sharing one of the findings hopefully will be helpful since as mention here

settings.gradle file

dependencyResolutionManagement {
  versionCatalogs {
    libs {
     version('kotlinVersion', '1.8.0')
     plugin('kotlin.jvm', 'org.jetbrains.kotlin.jvm').versionRef('kotlinVersion')
   }
 }
}

Working conversion

dependencyResolutionManagement {
  versionCatalogs {
    create("libs") {    // <----------- This is main conversion     
     version("kotlinVersion", "1.8.0")
     plugin("kotlin.jvm", "org.jetbrains.kotlin.jvm").versionRef("kotlinVersion")
    }
  }
}

How to use it?

Can you please provide clear instruction about how to use it

Fails to convert plugins closure

It looks like it's related to the "id" key as that is being stripped from the plugin name in the output.

E.g.

plugins {
    id "com.android.library"
    id "kotlin-android" 
    id "kotlin-android-extensions"
}

converts to:

plugins {
    id("com.andro.library")
    id("kotlin-andro")
    id("kotlin-andro-extensions")
}

all colons converted to equals

Hi there, it seems all colons get converted to equals, not just parameter names? i.e. for project dependency handlers

implementation project(path: ":customer-api:api")

becomes

implementation(project(path = " =customer-api =api"))

I tried only matching colons preceded by "(" or "," in this commit which seems to sort out, pr?

Doesn't work

Hi

Simply fails with a 200 lines Gradle build file.
The resulting file has almost 900 lines and does not compile. :(

build.gradle.zip

fails to compile for me:

File being compiled: (10,33) in /.../gradlekotlinconverter.kts
The root cause org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException was thrown at: org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)

 * Source files: gradlekotlinconverter.kts
 * Compiler version info: Konan: 1.4.31 / Kotlin: 1.4.31
 * Output kind: PROGRAM

exception: org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration Gradlekotlinconverter
File being compiled: (10,33) in /.../gradlekotlinconverter.kts
The root cause org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException was thrown at: org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)
        at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:43)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:453)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:21)
        at org.jetbrains.kotlin.psi.KtVisitor.visitScript(KtVisitor.java:78)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:73)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:519)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:21)
        at org.jetbrains.kotlin.psi.KtScript.accept(KtScript.java:69)
        at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:60)
        at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.registerDeclarations(LazyTopDownAnalyzer.kt:78)
        at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.visitKtFile(LazyTopDownAnalyzer.kt:96)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:513)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
        at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:243)
        at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:230)
        at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitElement(ExceptionWrappingKtVisitorVoid.kt:27)
        at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:35)
        at org.jetbrains.kotlin.psi.KtVisitor.visitKtFile(KtVisitor.java:73)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:69)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:513)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
        at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:243)
        at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:230)
        at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:201)
        at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:57)
        at org.jetbrains.kotlin.backend.konan.TopDownAnalyzerFacadeForKonan.analyzeFilesWithGivenTrace(TopDownAnalyzerFacadeForKonan.kt:94)
        at org.jetbrains.kotlin.backend.konan.TopDownAnalyzerFacadeForKonan.analyzeFiles(TopDownAnalyzerFacadeForKonan.kt:67)
        at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1$1.invoke(ToplevelPhases.kt:86)
        at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1$1.invoke(ToplevelPhases.kt)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:114)
        at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1.invoke(ToplevelPhases.kt:85)
        at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1.invoke(ToplevelPhases.kt)
        at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:97)
        at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:95)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:23)
        at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
        at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:41)
        at org.jetbrains.kotlin.backend.konan.KonanDriverKt.runTopLevelPhases(KonanDriver.kt:29)
        at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:78)
        at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:35)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
        at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
        at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222)
        at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
        at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:273)
        at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:270)
        at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:27)
        at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:21)
        at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:272)
        at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:484)
        at org.jetbrains.kotlin.cli.utilities.MainKt$main$1.invoke(main.kt:41)
        at org.jetbrains.kotlin.cli.utilities.MainKt$main$1.invoke(main.kt)
        at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:17)
        at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)
Caused by: org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException: Descriptor wasn't found for declaration SCRIPT
        at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)
        at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:17)
        at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.findClassDescriptor(LazyDeclarationResolver.kt:88)
        at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getScriptDescriptor(LazyDeclarationResolver.kt:65)
        at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.visitScript(LazyTopDownAnalyzer.kt:89)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:519)
        at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:21)
        at org.jetbrains.kotlin.psi.KtScript.accept(KtScript.java:69)
        at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:60)
        at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:32)
        ... 58 more

Test the conversions

While I was adding support for conversion of Groovy's array syntax [items...] to Kotlin's listOf(items...), the resultant output didn't look nice because of the later steps.

We should do proper testing of each and every function separately and also as a whole.

Conversion of compileKotlin is incorrect

The code

compileKotlin {
    dependsOn(tasks.getByPath('compileGroovy'))
    classpath += files(compileGroovy.destinationDir)
}

was converted to:

compileKotlin {
    dependsOn tasks.getByPath("compileGroovy")
    classpath(+= files(compileGroovy.destinationDir))
}

which is incorrect.

Expression 'compileKotlin' cannot be invoked as a function. The function 'invoke()' is not found

developmentOnly / runtimeOnly

your script could not transform dependencies of the types developmentOnly and runtimeOnly.

Even if it those are custom configurations it should treat everything inside "dependencies" the same.

Example:

configurations {
    developmentOnly // for dependencies that are needed for development only
}
dependencies {
      developmentOnly "net.java.dev.jna:jna:5.5.0"
    developmentOnly "io.methvin:directory-watcher:0.9.9"
    ...
}

repositories maven

Hello, here is a tricky but important special case to handle

repositories {
    maven { url = uri("https://jitpack.io") }
}

actual/expected

repositories {
-   maven { url = uri("https://jitpack.io") }
+    maven("https://jitpack.io")
}

Few issues

1)Assume we have string

implementation platform('it.tdlight:tdlight-java-bom:2.8.10.6')

Script converts it into

implementation platform("it.tdlight:tdlight-java-bom:2.8.10.6")

Correct variant is

implementation(platform("it.tdlight:tdlight-java-bom:2.8.10.6"))

2)Assume we have string

implementation 'it.tdlight:tdlight-java'

Script converts it into

implementation "it.tdlight:tdlight-java"

Correct variant is

implementation("it.tdlight:tdlight-java")

project with api suffix

Hi there..
If I'm migrating a project with 'api' suffix it removes it.

Eg.
implementation project(':customer-api')
becomes
implementation(project(":customer-")

btw. thanks for that tool, it's great

Three things that the script converted worngly

Hello I found out this 3 cases that it converted wrongly and I write you the right conversion. I hope it's helpful

I created a pull request fixing the first two issues with kapt.

groovy:
kaptAndroidTest SomeLibrary
kotlin:
kaptAndroidTest(SomeLibrary)

groovy:
kaptTest SomeLibrary
kotlin:
kaptTest(SomeLibrary)

Here are the right conversions:
groovy:
implementation fileTree(dir: "libs", include: [".jar"])
kotlin:
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("
.jar"))))

groovy:
maven {
url "SomeUrl"
credentials {
username 'SomeUsername'
password 'SomePassword'
}
}

kotlin:

    maven {
        url  = uri("SomeURL")
        credentials {
            username = "SomeUserName"
            password  ="SomePassword"
        }
    }

compile groovy dsl is not converted to kotlin

A lot of older programs, especially non-Android projects, still use the "compile" dependency directive instead of "implementation". Unfortunately, the converter doesn't convert the "compile" directive from Groovy functions to Kotlin. Not sure if you're aware of this yet.

fails on tasks.withType

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

should be converted to

    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

but is converted to:

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

report something can't do

before
flavorDimensions "env", "moduleEnv"
after
flavorDimensions("env", "moduleEnv")

before

productFlavors {
    dev {
        dimension "env"
        resValue "string", "app_name", "Test App DEV"
        buildConfigField "boolean", "IS_DEBUG", "true"
    }
    pub {
        dimension "env"
        buildConfigField "boolean", "IS_DEBUG", "false"
    }
    moduleDev {
        dimension "moduleEnv"
    }
    modulePub {
        dimension "moduleEnv"
    }
}

after

productFlavors {
    create ("dev") {
        setDimension("env")
        resValue("string", "app_name", "Test App DEV")
        buildConfigField("boolean", "IS_DEBUG", "true")
    }
    create ("pub") {
        setDimension("env")
        buildConfigField("boolean", "IS_DEBUG", "false")
    }
    create ("moduleDev") {
        setDimension("moduleEnv")
    }
    create ("modulePub") {
        setDimension("moduleEnv")
    }
}

before
useLibrary "org.apache.http.legacy"
after
useLibrary("org.apache.http.legacy")

before

testOptions {
    unitTests {
        includeAndroidResources = true
    }
}

after

testOptions {
    unitTests.isIncludeAndroidResources = true
}

before

sourceSets {
    main.java.srcDirs += "src/main/kotlin"
}

after

sourceSets.getByName("main") {
    java.srcDir("src/main/kotlin")
}

How to convert this groovy script? Converter didn't work

ext {
    //versioning
    generateVersionName = { BigDecimal versionCode ->
        int patch = versionCode.remainder(1000)
        int minor = (versionCode / 1000).remainder(1000)
        int major = (versionCode / 1000000).remainder(1000)
        "$major.$minor.$patch"
    }
    appVersionCode = 1_000_000
    appVersionName = generateVersionName(appVersionCode)
    //android
    //versionCode = appVersionCode
    //versionName = appVersionName
}

Conversion of compileGroovy is invalid

compileGroovy {
    dependsOn.clear()
}

is left untouched.

I don't know what it should be but it's incorrect:

Expression 'compileGroovy' cannot be invoked as a function. The function 'invoke()' is not found

Issue when converting root build.gradle file on configurations.classpath.exclude

Thanks for the tool!

In the readme and on reddit you state that this won't magically convert everything perfectly, so I understand if this isn't something you intend to fix. I did want to point out an issue I had when converting my root build.gradle file.

I had a line:

configurations.classpath.exclude group: 'com.android.tools.external.lombok'

inside of the buildscript { } block. It converted it to this

configurations.classpath.exclude group: "com.android.tools.external.lombok"

which doesn't compile. Admittedly, I didn't try too long to fix it, but I wanted to point it out here. Maybe you know what's missing here.

Incorrect converting

I've tried to convert this file but haven't succeeded. The conversion result turned out to be incorrect.

Conversion of functions

The conversion of a function seems to be broken.

Input:

def generateTag() {
    def date = new Date().format('yyyy-MM-dd-HH-mm')
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

Output:

val generateTag() {
    val generateTag() {
        val date = new Date().format("yyyy-MM-dd-HH-mm")
        return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
    }
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

Additionally: In groovy it is possible to declare a method as static like:

static def generateTag() {
    def date = new Date().format('yyyy-MM-dd-HH-mm')
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

What the script puts out is like (Already eliminated duplicated lines from bug above):

static val generateTag() {
    val date = new Date().format("yyyy-MM-dd-HH-mm")
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

But static val does not exist in Kotlin dsl.
Correct would be this output:

fun generateTag() {
    val date = new Date().format("yyyy-MM-dd-HH-mm")
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

fail to run on windows ` org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException was thrown`

hi i tried to run with the command: kotlinc -script gradlekotlinconverter.kts (kotlin 1.3.72)

got the following error

` kotlinc -script gradlekotlinconverter.kts
error: compilation failed: Front-end Internal error: Failed to analyze declaration Gradlekotlinconverter
File being compiled: (11,33) in D:/Setup/Tools/GradleKotlinConverter/gradlekotlinconverter.kts
The root cause org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException was thrown at: org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)

  • Source files: gradlekotlinconverter.kts
  • Compiler version info: Konan: 1.3.72 / Kotlin: 1.3.72
  • Output kind: PROGRAM

exception: org.jetbrains.kotlin.util.KotlinFrontEndException: Front-end Internal error: Failed to analyze declaration Gradlekotlinconverter
File being compiled: (11,33) in D:/Setup/Tools/GradleKotlinConverter/gradlekotlinconverter.kts
The root cause org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException was thrown at: org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)
at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:43)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:453)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtVisitor.visitScript(KtVisitor.java:78)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:73)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:519)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtScript.accept(KtScript.java:69)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:59)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.registerDeclarations(LazyTopDownAnalyzer.kt:78)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.visitKtFile(LazyTopDownAnalyzer.kt:96)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:513)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:242)
at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:229)
at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitElement(ExceptionWrappingKtVisitorVoid.kt:27)
at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:34)
at org.jetbrains.kotlin.psi.KtVisitor.visitKtFile(KtVisitor.java:73)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:69)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:513)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:242)
at org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:229)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:201)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:60)
at org.jetbrains.kotlin.backend.konan.TopDownAnalyzerFacadeForKonan.analyzeFilesWithGivenTrace(TopDownAnalyzerFacadeForKonan.kt:90)
at org.jetbrains.kotlin.backend.konan.TopDownAnalyzerFacadeForKonan.analyzeFiles(TopDownAnalyzerFacadeForKonan.kt:63)
at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1$1.invoke(ToplevelPhases.kt:90)
at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1$1.invoke(ToplevelPhases.kt)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1.invoke(ToplevelPhases.kt:89)
at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$frontendPhase$1.invoke(ToplevelPhases.kt)
at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:149)
at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:147)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:23)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127)
at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:42)
at org.jetbrains.kotlin.backend.konan.KonanDriverKt.runTopLevelPhases(KonanDriver.kt:28)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:77)
at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:34)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:85)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:105)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:83)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:51)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:219)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:211)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:241)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:238)
at org.jetbrains.kotlin.util.UtilKt.profileIf(Util.kt:27)
at org.jetbrains.kotlin.util.UtilKt.profile(Util.kt:21)
at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:240)
at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:375)
at org.jetbrains.kotlin.cli.utilities.MainKt$main$1.invoke(main.kt:37)
at org.jetbrains.kotlin.cli.utilities.MainKt$main$1.invoke(main.kt)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:17)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
Caused by: org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException: Descriptor wasn't found for declaration SCRIPT
at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:18)
at org.jetbrains.kotlin.resolve.lazy.BasicAbsentDescriptorHandler.diagnoseDescriptorNotFound(AbsentDescriptorHandler.kt:17)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.findClassDescriptor(LazyDeclarationResolver.kt:88)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getScriptDescriptor(LazyDeclarationResolver.kt:65)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer$analyzeDeclarations$1.visitScript(LazyTopDownAnalyzer.kt:89)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:519)
at org.jetbrains.kotlin.psi.KtVisitorVoid.visitScript(KtVisitorVoid.java:21)
at org.jetbrains.kotlin.psi.KtScript.accept(KtScript.java:69)
at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:59)
at org.jetbrains.kotlin.resolve.ExceptionWrappingKtVisitorVoid.visitDeclaration(ExceptionWrappingKtVisitorVoid.kt:32)
... 63 more

`

`error: unable to instantiate class Gradlekotlinconverter`

Hi tried to use the tool but after download and run the command ./gradlekotlinconverter.kts build.gradle i got the error:

error: unable to instantiate class Gradlekotlinconverter (gradlekotlinconverter.kts): java.lang.NoClassDefFoundError: kotlin/script/templates/standard/ScriptTemplateWithArgs

Any suggestion to resolve it? thanks!

`id "idea"` gets converted to `id("ea")`

When running the script, id "idea" gets converted to id("ea") in the plugin section. It looks like a regex is looking inside of quoted strings when it shouldn't be.

Thanks for the script! :)

ApplicationVariants.all conversion

In groovy we have
applicationVariants.all { variant -> //do stuff }

but, when converting to kotlin, the same block of code changes it's functionality:
applicationVariants.all { variant -> //do stuff }

This is due the fact that in groovy the closure given as a parameter to .all method can rename it's receiver (in this case it's renamed to variant).
BUT the same block code in kotlin is not a closure anymore, it becomes a lambda. The ".all" method called now is the one in the Iterable interface. (before it was calling the .all inside DomainObjectSet<> interface)

The real kotlin correspondent is:
applicationVariants.all { val variant = this //do stuff }.

I do not expect your converter to go so deep into the conversion, but please add this information to this wiki as it is very tricky to observe it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.