kobalt icon indicating copy to clipboard operation
kobalt copied to clipboard

Problem with Kobalt plugin after initializing a new project

Open RandolphKahle opened this issue 8 years ago • 15 comments

I created a new project in OS X by mkdir "project", cd "project"

Then did ./kobaltw --init java

This all works.

./kobaltw run
./kobaltw test

all works...

Did ./kobaltw --init idea and then ran IntelliJ, opened project.

Stack trace follows:

String index out of range: 0
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.lang.String.charAt(String.java:658)
    at com.intellij.configurationStore.ProjectStateStorageManager.expandMacros(ProjectStateStorageManager.kt:33)
    at com.intellij.configurationStore.StateStorageManagerImpl.createStateStorage(StateStorageManagerImpl.kt:194)
    at com.intellij.configurationStore.StateStorageManagerImpl.getOrCreateStorage(StateStorageManagerImpl.kt:150)
    at com.intellij.configurationStore.StateStorageManagerImpl.getStateStorage(StateStorageManagerImpl.kt:133)
    at com.intellij.configurationStore.ComponentStoreImpl.a(ComponentStoreImpl.kt:269)
    at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:90)
    at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.initializeComponent(PlatformComponentManagerImpl.java:54)
    at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.getComponentInstance(ServiceManagerImpl.java:237)
    at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:246)
    at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:212)
    at com.intellij.openapi.components.ServiceManager.doGetService(ServiceManager.java:46)
    at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:41)
    at com.beust.kobalt.intellij.settings.KobaltSettings.getInstance(KobaltSettings.java:34)
    at com.beust.kobalt.intellij.manager.KobaltManager$getSettingsProvider$1.fun(KobaltManager.kt:128)
    at com.beust.kobalt.intellij.manager.KobaltManager$getSettingsProvider$1.fun(KobaltManager.kt:43)
    at com.intellij.openapi.externalSystem.service.settings.AbstractExternalSystemToolWindowCondition.value(AbstractExternalSystemToolWindowCondition.java:48)
    at com.intellij.openapi.externalSystem.service.settings.AbstractExternalSystemToolWindowCondition.value(AbstractExternalSystemToolWindowCondition.java:31)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl$11.computeInReadAction(ToolWindowManagerImpl.java:502)
    at com.intellij.openapi.progress.util.ReadTask$1.run(ReadTask.java:52)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:951)
    at com.intellij.openapi.progress.util.ReadTask.runBackgroundProcess(ReadTask.java:49)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils$7.run(ProgressIndicatorUtils.java:205)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:446)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.a(ProgressIndicatorUtils.java:201)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.access$000(ProgressIndicatorUtils.java:43)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils$6$2.run(ProgressIndicatorUtils.java:180)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)

RandolphKahle avatar May 18 '16 02:05 RandolphKahle

@dmitry-zhuravlev Any thoughts?

cbeust avatar May 18 '16 02:05 cbeust

@cbeust I think we should deprecate './kobaltw --init idea' because it generates some "old" format not suited for the new plugin. This functionality fully integrated within plugin during "import\create project". @RandyKahle I suggest you to do following:

  1. Install the latest plugin
  2. Run create new project project and choose Kobalt: image
  3. Follow wizzard instructions.

This will generate pretty the same project which you try to generate via comand line ( but without some sample HelloWord.java class - will be added later on)

dmitry-zhuravlev avatar May 18 '16 09:05 dmitry-zhuravlev

Just for fun I tried to do --init idea and got NPE on Windows:

java -Dfile.encoding=windows-1251 -classpath C:\Users....kobalt\wrapper\dist\kobalt-0.780\kobalt\wrapper\kobalt-0.780.jar com.beust.kobalt.wrapper.Main --init idea __ __ __ __ __ / /// ____ / / ____ _ / / / /_ / ,< / __ \ / __ \ / __ `/ / / / / / /| | / // / / // // // / / / / / // || __/ /./ __,/ // __/ 0.780

Exception in thread "main" java.lang.NullPointerException at com.beust.kobalt.app.IdeaFilesTemplate.writeTemplate(IdeaFilesTemplate.kt:46) at com.beust.kobalt.app.IdeaFilesTemplate.generateImlFiles(IdeaFilesTemplate.kt:62) at com.beust.kobalt.app.IdeaFilesTemplate.generateTemplate(IdeaFilesTemplate.kt:38) at com.beust.kobalt.app.ProjectGenerator.run(ProjectGenerator.kt:28) at com.beust.kobalt.Main.runWithArgs(Main.kt:154) at com.beust.kobalt.Main.access$runWithArgs(Main.kt:55) at com.beust.kobalt.Main$run$seconds$1.invoke(Main.kt:117) at com.beust.kobalt.Main$run$seconds$1.invoke(Main.kt:55) at com.beust.kobalt.misc.BenchmarksKt.benchmarkMillis(Benchmarks.kt:5) at com.beust.kobalt.misc.BenchmarksKt.benchmarkSeconds(Benchmarks.kt:9) at com.beust.kobalt.Main.run(Main.kt:115) at com.beust.kobalt.MainKt.mainNoExit(Main.kt:47) at com.beust.kobalt.MainKt.main(Main.kt:29)

Anyway I think we don't need to repair this functionality. "--init idea" should be removed completely just to not confuse the new users. Also documentation should be updated accordingly.

dmitry-zhuravlev avatar May 18 '16 09:05 dmitry-zhuravlev

I tried the recommended approach and it seems to work. I removed IntelliJ completely, reinstalled, and when it first came up I installed the Kobalt plugin. I also had to update to the latest (1.0.2) Kotlin plugin and then things seemed to stabilize.

RandolphKahle avatar May 18 '16 13:05 RandolphKahle

@RandyKahle Nice to hear that it works for you!

dmitry-zhuravlev avatar May 18 '16 15:05 dmitry-zhuravlev

@dmitry-zhuravlev I don't think we need to deprecate --init idea, I should just update it to the correct format.

cbeust avatar May 18 '16 16:05 cbeust

@cbeust But what the reason to keep this? Could you please add some use case to think about?

dmitry-zhuravlev avatar May 18 '16 17:05 dmitry-zhuravlev

I will add a comment. One of the additions I made to Gradle when I adapted it for a particular domain use (In this case NetKernel) was template based generation of a "development environment". This is an often requested feature... Being able to say "Gradle >set up my default environment for use case X<"... I even give user the ability to define their own templates...

In general I think having a tool be able to do template based setups is very handy.

My test of Kobalt will be to move those features from Gradle to Kobalt - starting NetKernel, stopping it, updating, generating template based development structures, etc.

RandolphKahle avatar May 18 '16 17:05 RandolphKahle

Yep, thanks! Now I see that this is some kind of flexibility which probably will be handy for some users.

dmitry-zhuravlev avatar May 18 '16 17:05 dmitry-zhuravlev

@dmitry-zhuravlev regarding the NPE with --init idea, it seems this only happens if the project has not been initialized with a build file. If you run --init kotlin first, then --init idea, there is no NPE

pabl0rg avatar May 20 '16 20:05 pabl0rg

@pabl0rg , @cbeust Tried --init kotlin and then --init idea and still have NPE: image

dmitry-zhuravlev avatar May 24 '16 10:05 dmitry-zhuravlev

The error also happens for me when opening a project with no Kobalt files.

Haven't tried a project with working Kobalt files though.

CaelumF avatar Jun 22 '16 15:06 CaelumF

What do you mean by "opening a project with no Kobalt files"?

dmitry-zhuravlev avatar Jun 22 '16 16:06 dmitry-zhuravlev

A project that I've never ran kobaltw --init in, a pre-existing Kotlin/java project.

CaelumF avatar Jun 22 '16 16:06 CaelumF

@dmitry-zhuravlev @CaelumF is on the #kobalt Slack channel, feel free to jump in if you want to talk to him directly.

cbeust avatar Jun 22 '16 16:06 cbeust

No comment

RandolphKahle avatar May 31 '23 00:05 RandolphKahle