Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Kobalt should use separate runtime to compile Kotlin based projects #317

Closed
dmitry-zhuravlev opened this issue Jan 31, 2017 · 9 comments
Closed

Comments

@dmitry-zhuravlev
Copy link
Contributor

After playing with latest Kobalt version based on the latest Kotlin version (beta version at the moment) I realize that Kobalt should use Kotlin runtime configuration for compiling project different from Kotlin runtime bundled with Kobalt.

The use case can be following:
A user can have a big legacy project which is based on some outdated version of Kotlin. But he wants to migrate to the latest version of Kobalt. He cannot do it because the latest version of Kobalt probably will have the latest Kotlin compiler under the hood. So it tends to full migration of the project to the newest version and this will probably take a lot of time and definitelly not what the user want.

So the Kotlin runtime used by Kotlin to compile Build.kt file should be different from Kotlin runtime used in project.
Kotlin runtime for the project can be specified in Build.kt as following:

val kotlinVersion = "1.0.6"

apply kotlin kotlinVersion

dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
}

dependenciesTest {
compile("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
}

The derictive "apply kotlin" should apply the valid version of Kotlin compiler to the project.

@dmitry-zhuravlev
Copy link
Contributor Author

@cbeust I added some implementation of KotlinProjectConfigurator for Kobalt based project. You can find it in the https://github.com/cbeust/kobalt-intellij-plugin/tree/kotlin-1.1-migration
Now if the user click to "Configure Kotlin" tooltip there will be an option "Kobalt".
This option afterwords will specify the corresponding dependencies in Build.kt.

So the only thing which is missing at the moment it is a "apply kotlin kotlinVersion" plugin which gives to user the ability to specify the needed Kotlin compiler for the project.

To compile the plugin you should use the latest beta version of Kotlin.

@cbeust
Copy link
Owner

cbeust commented Feb 2, 2017

Even with 1.1.0-beta-22 I can't seem to compile this commit:

/Users/cedricbeust/kotlin/kobalt-intellij-plugin/src/com/beust/kobalt/intellij/Closeable.kt
Error:(44, 14) Kotlin: Public-API inline function cannot access non-public-API 'internal fun Closeable?.closeFinally(cause: Throwable?): Unit defined in com.beust.kobalt.intellij'
Error:(54, 2) Kotlin: Unresolved reference: SinceKotlin
Error:(55, 2) Kotlin: Unresolved reference: PublishedApi
/Users/cedricbeust/kotlin/kobalt-intellij-plugin/src/com/beust/kobalt/intellij/configurator/KotlinKobaltProjectConfigurator.kt
Error:(12, 22) Kotlin: Unresolved reference: kotlin
Error:(13, 22) Kotlin: Unresolved reference: kotlin
Error:(14, 22) Kotlin: Unresolved reference: kotlin

@cbeust
Copy link
Owner

cbeust commented Feb 2, 2017

In particular:

image

Where is this dependency coming from?

This is the SDK I'm currently using:

image

@cbeust
Copy link
Owner

cbeust commented Feb 2, 2017

I wiped my repo and recloned, same problems. master builds fine but if I check out to "kobalt-1.1-migration", I get the compilation errors above.

I can fix the Credentials one by importing Credentials on a different path but the SDK I used doesn't seem to know any of these symbols:

image

Really strange since I find them in the github kotlin repo in the idea/ folder.

Any thoughts? I'd really like to try that new configurator.

@dmitry-zhuravlev
Copy link
Contributor Author

dmitry-zhuravlev commented Feb 3, 2017

@cbeust Yeach, forgot to mention that there need to do some reconfiguration in IDEA SDK to build plugin from this branch:

  1. Recheck what you have the latest Kotlin plugin installed (1.1.0-beta-22-IJ2016.3-1)
  2. Add in SDK classpath HOME/.IntelliJIdea2016.3/config/plugins/Kotlin/lib/kotlin-plugin.jar
  3. Try to find in SDK classpath kotlin-runtime.jar and kotlin-reflect.jar and replace it with the same jars but from HOME/.IntelliJIdea2016.3/config/plugins/Kotlin/lib/
  4. Do not use optimize import in IDEA expecially for com.beust.kobalt.intellij.server.ServerUtil because it will replace the workaround import (see the problem description in the com.beust.kobalt.intellij.Closeable.kt file)

@dmitry-zhuravlev
Copy link
Contributor Author

Also org.apache.http.auth.Credentials should be located in httpclient-4.5.2.jar and it is a part of SDK IDEA_INSTALL_DIR/lib

@dmitry-zhuravlev
Copy link
Contributor Author

dmitry-zhuravlev commented Apr 6, 2017

Ok, just tried to test existing ability of Kobalt (1.0.51) to specify Kotlin version.
In the Build.kt I set:

   kotlinCompiler {
        version = "1.0.6"
    }

When I execute the compile task the output is following:

───── kobalt-example:compile
  Kotlin 1.1.1 compiling 1 file

So the version of Kotlin compiler is still 1.1.1. @cbeust Any thoughts?

@cbeust cbeust closed this as completed in 69560ca Apr 6, 2017
@cbeust
Copy link
Owner

cbeust commented Apr 6, 2017

Fixed in 1.0.53.

@dmitry-zhuravlev
Copy link
Contributor Author

Great! For me it works.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants