Parent when addning new module with IntelliJ Idea Kotlin and Gradle - kotlin

as C# developer, I'm trying to understand how modules works in Java/Kotlin. When I create a new Project in IntelliJ based on Kotlin and add a new module, there is a option Parent. If I choose None I get a message during the build
Error resolving plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.72']
> Plugin request for plugin already on the classpath must not include a version
and if I remove the version
Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sources:
If I do the same, but when adding a new module I choose instead of None a Parent project, everything works. So my question is what is a difference between adding a Parent when creating new module. And when should i use one over another.

Related

IntelliJ plugin template doesn't know about PsiJavaFile

I have an IntelliJ plugin, which was created from the github-template, that cannot resolve the class com.intellij.psi.PsiJavaFile.
Has anyone else run into this and figured out what needs to be configured?
I'm new to IntelliJ plugin development. I followed the instructions detailed at https://plugins.jetbrains.com/docs/intellij/github-template.html to create a plugin.
I imported the generated plugin into IntelliJ and everything seems OK. No compile warnings, etc..., but when I try to use the class com.intellij.psi.PsiJavaFile, IntelliJ says it cannot resolve the class.
I imagine I'm missing a configuration somewhere that tells IntelliJ which libraries to import, but I'm not finding it in the documentation.
You're probably missing the dependency on the Java intellij plugin, which is not enabled by default as you won't need it for every custom plugin.
Add com.intellij.java to the platformPlugins section of the gradle.properties file:
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java
To address that the IDE cannot resolve PsiJavaClass specifically, I don't think it exists. Are you looking for PsiJavaFile or PsiClass?

Kotlin - Application project template - error main class not found

I am using IntelliJ IDEA 2021.1 (Community Edition) - Build #IC-211.6693.111, built on April 6, 2021.
I created a new kotlin project - project template(JVM): Application, built system: Gradle Kotlin,
project JDK:1.8 version 1.8.0_281.
In the “scr/main/kotlin” folder, I created a kotlin file with a simple code like "fun main(){println(“Hi!”)}.
When I tried to run the file(the build was ok), I got this error: “Could not find or load main class MyAppKt”.
What did I do wrong?
Did you also add your main class to the build.gradle file?
mainClassName = "projectPackage.MyAppKt"
I assume if you are adding the MyAppKt file manually it is not added to the build.grale. But clearly more information about the project would help here. Meanwhile check this post Kotlin - Error: Could not find or load main class _DefaultPackage

IntelliJ Gradle "Unable to find Method"

The Error:
Failed to sync Gradle project '-'
Error:Unable to find method 'org.gradle.internal.logging.progress.DefaultProgressLoggerFactory.(Lorg/gradle/internal/logging/progress/ProgressListener;Lorg/gradle/internal/time/TimeProvider;)V'.
You can see, a constructor inside a class, which is found in the logging jar (gradle_home/lib/grade-logging-version.jar) is missing.
So, I think the Class-Path does not contain this jar file.
Gradle Version: 3.5
Running using the Command Line works.
I have already tried this:
Gradle sync failed: Unable to find method
to-find-method, it does not work for me.
I have tried to use different versions.
I can't see any difference when enabling
"Use default gradle wrapper"
"Use gradle wrapper task configuration"
"Use local gradle distribution".
I had the exact same problem today.
The only way I was able to get it to work was to remove my IntelliJ IDEA IDE, get the latest from the website (with JDK) and put it in a new folder (i.e. no overwriting existing files).
After that, I deleted the .idea folder from the project and reimported it cleanly into the "new" IntelliJ.
I suspect upgrading IntelliJ from Version <= 2016.x caused the issue, since a new installation / clean extraction from archive caused it to work on the fly.

Play Framework 2.4 and IntelliJ Idea

I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this.
In previous versions I could just run
activator idea
Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist
[error] Not a valid command: idea (similar: eval, alias)
[error] Not a valid project ID: idea
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: idea (similar: clean)
[error] idea
[error] ^
And the UI seems broken, when I click on generate intelliJ project it tries to compile the app and gives this error:
play/Play$
java.lang.NoClassDefFoundError: play/Play$
Use 'last' for the full log.
Failed to load project.
I created the project from scratch using the play java template with:
activator new
I have also tried importing the folder as a project but intelliJ doesn't seem to identify it as a project
I run into the same problem, as I used IDEA to open a project folder, it had an play 2 app in a sub folder, then I import module (play 2 app) to the system.
And it works well.
After that I have changed the module folder name, then when I run the app, it displayed:
Not a valid project ID: "project team"
I re-checked the folder, and found that in the File -> Project Structure option, the name of module is "root", and the "team" is the module for whole project (not the module imported by SBT), so apparently, the module wasn't functional after I changed the module folder name.
So I found and removed all .idea folder, which is IDEA configureation, then re-open/re-import the module, still not work. I thought it's IDEA cache issue, it do have cache for the opened project, so I changed the project folder from team to something else, clean the .idea folders, and re-open/re-import it. It worked.
If the play app is in the project folder as a sub folder, to import the module at File -> Project Structure.
The project name should be "root" when running it in IDEA. So in this case, you should rename "project team" to "root" in the name field.
Solution 1
In my case (IDEA 2018.2), I changed the lazy val variable in build.sbt, it had the name "root" when my project name was "top", changed "root" to "top".
Before:
lazy val root = (project in file(".")).enablePlugins(PlayScala)
After:
lazy val top = (project in file(".")).enablePlugins(PlayScala)
Change project variable
Solution 2
The method proposed by Tom solved my problem partially, because after rebooting the IDEA I returned the project name back, it was necessary to change the variable from "top" to "root" in build.sbt.
Before:
name: = "top"
After:
name := "root"
Intellij IDEA lets you quickly create a Play application without using a command prompt. You don’t need to configure anything outside of the IDE, the SBT build tool takes care of downloading appropriate libraries, resolving dependencies and building the project.
Before you start creating a Play application in IntelliJ IDEA, make sure that the latest Scala Plugin is installed and enabled in IntelliJ IDEA. Even if you don’t develop in Scala, it will help with the template engine and also resolving dependencies.
Basically, install Play Framework, Scala plugins and import project into Intellij as SBT project. Don't use activator to create IDEA project files. More details here.
It seems I had not updated scala/sbt to the latest version in intelliJ
Once I had done this it noticed that it was a valid project, though the docs don't seem to mention you can import it as an SBT project, just how to create it as a new sbt project (which I did not want to do as I wanted to create it via activator)
I also had the project/play-fork-run.sbt file issue
I use Intellij Idea 16.3.3 and this problem appears sometimes. How I fixed it? You just need to open your SBT plugin and under your project get the context menu then you should choose "Ignore SBT project". After a current process is finished you should turn on this option again. This is work for me:)

Using Gradle with IntelliJ

We are trying to setup a number of Gradle (v1.5) web projects in IntelliJ v12.1.2
The new JetGradle integration works fine until we get the the Artifacts
The module is imported as a Gradle project, the artifact is been created as a Web Application (Exploded) and the Web facet has been added - all the dependencies that are declared in the build.gradle file are correctly added to the WEB-INF/lib directory in the artifact
The problem comes when we make a change to the dependencies in the build.gradle file and refresh the module using the JetGradle refresh button - the dependencies of the module are updated correctly but nothing is changed in the artifact
If we changing just one dependency then the change can be done manually but if there are a number of changes or there are a lot of new/changed transative dependencies then it seems the only timely way to get the correct dependencies in the artifact is to delete and recreate it
Am I missing something obvious, does anyone know a better way to update the artifacts
Thanks
Automatic artifact config update is not implemented yet. I've created corresponding ticket for that - http://youtrack.jetbrains.com/issue/IDEA-109369