How to create a Kotlin console application with Gradle in Intellij IDEA - kotlin

I found this tutorial from JetBrains: https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Kotlin
It is dated August 19th, 2020.
I am using the same IntelliJ IDEA version as in their documentation: 2020.2.
However, my project creation wizard looks quite different from theirs.
They provide this screenshot:
But for me, it looks like this:
and when I click on Next:
I don't see where I can choose the Console Application template, or Gradle.
I found a second tutorial - https://kotlinlang.org/docs/tutorials/jvm-get-started.html , which shows yet a third variation of the New Project wizard:
Are the tutorials out of date? Am I doing anything wrong? How do I create a Kotlin project, based on a console application template, with Gradle?

The wizard you have seems to be obsolete now. There was a brand-new one, released as a part of Kotlin 1.4 recently(see here). Most probably, the problem is caused by the Kotlin IDE plugin being outdated or something. Please try to delete in and re-install using the Preferences -> Plugins menu. Comment here with the results, please. I'd like to know if this would help.

Indeed it's quite weird, I've never seen the dialog to look like yours (mine looks like the one in the tutorials). However, choosing the template doesn't do anything special - it simply creates the main file, which you can do so yourself.
So create a new project with the "JVM/IDEA" option. If it already opens up a main.kt file, you don't need to do anything else. If it didn't, look in the src folder - you should see a folder named main with a folder named kotlin (with a blue icon instead of grey) inside - here's where you wanna create your main file (right click -> new kotlin file/class -> main.kt and make it a file, not a class). Finally, put this in the file:
fun main(args: Array<String>) {
println("Hello world!")
}
Note: if you don't have a kotlin folder, create the file in the folder with the blue icon (might even be src). Also, if this doesn't use Gradle (for some reason), create a Gradle project instead, and at the "Additional libraries and frameworks" option, uncheck Java and check Kotlin, then continue with creating main.kt if it isn't created.

You may create a Kotlin + gradle project from the terminal:
$mkdir myProject; cd myProject; gradle init
follow the tutorial.
And then start the Intellij & open the dir
You're good to go
Same process like this

The same happened to me but I figured out how to fix it:
Just disable Material Theme UI.

Related

Cannot create kotlin class in itellij idea

Cannot find the "create kotlin class" option when I right click on src inside a kotlin project in intellij idea! Doing an online course where they tell to create a kotlin class by right clicking on src but I cannot find it in the latest version
You need to right click on the "kotlin" directory, not "src". If you used the InteliJIdea to create the project you should have a project directory structure like this
src -> main -> kotlin
Right click on Kotlin and you will see it.

Scratch file not running on IntelliJ IDEA

I am trying to run a Kotlin scratch file in IntelliJ just like you would run a Java scratch file, but it doesn't work.
I created a new Kotlin scratch file, but can't run the code even after attempting the following:
Create a main function and print something inside.
Print something with println outside of the main function.
Create a class with a main function inside and println something.
When I create a new kotlin project, the project runs fine.
The issue happens only with scratch files. I am using kotlin plugin version 1.1.51 on IntelliJ 2017.1
As the screenshot shows, the icon that allows you to run kotlin code doesn't show up on the left of the editor window:
Your observations are correct, and this is a known issue.

Xtend in IntelliJ IDEA not generate file in src-gen

I combine Xtext and Xtend. In project, where I write code for my DSL, Xtext work but XTend not generate file in src-gen (this is sources root on: <project-root>/src-gen/).
I have this code in function doGenerate
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
fsa.generateFile("a.txt",'a')
}
Src-gen is always empty. In eclipse this work. How can I generate file in IntelliJ IDEA or how can I fix this problem. I run in gradle.
I run gradle task runIdea. I create Java project without any SDK.
When project is created, I add "file.mydsl" in src folder. Then I need change facet settings. I open project structure dialog (Ctrl+Shift+Alt+S), in the left-hand panel, click Facets, choose + icon and add DSL facet. Then apply and code is work. In src-gen create a file "a.txt".

migrate to equinox P2 for update site - Juno

I am trying to migrate an update-site plugin for my product from eclipse equinox to Juno , when I create a new plugin project and copy paste all the src files and change the META-INF as per the previous proj, I get lots of compilation errors.Reason being org.eclipse.update.core removed from Juno.So i have to migrate this existing project to equinox P2.But couldnt find a way to do so as i am completely new to RCP/plugin development.Can someone help me with some pointers. I get "cannot be resolved in to a type error for the following"
UpdateSearchRequest
ContentEntryModel
IFeature
IURLEntry
ICategory
Messages
IFeatureReference
IUpdateModelChangedListener
ISite
IIncludedFeatureReference
etc...
http://plosquare.blogspot.com/2009/05/migrating-eclipse-update-sites-to-p2.html
Perhaps the above might help.
I'd suggest something like the following to get started:
Open the Plug-ins View via Window->Show View->Other...->Plug-in Development->Plug-ins
Select all the plug-ins, right click and select "Add to Java Search..."
Ctrl-O and type one of the class files you listed above
This will allow you to open editors for those classes to see if they're still around. From the editor, you can figure out what Plug-in they're in and start fixing your Plug-in Dependencies in the Manifest Editor. Then you can start fixing the imports in your source either by hand or via Organize imports.

After adding new class file to App_Code, build action is Content instead of Compile

In VS2008, I am adding new classes to a web project.
When I right-click on App-Code -> Add -> New Item -> Class ...
The build action for the newly created item is set to content instead of compile. This seems like it would be a problem with the template. I've found several others through google who have run into this issue, but nobody seemed to have found a more permanent solution, other than "change it from content to compile after creation."
My question: Does anyone know of a fix for this, official or otherwise?
App_Code is a special folder meant for folder based projects.
This is just a hunch, but it might be that you have a project file based project, instead of a simple folder based one.