I come with this odd question, after look on the intelliJ forums I have no results.
I started to work in a project that has multiple gradle modules.
There is one module that has another module referencing it.
Lets say I have ModuleA with all my classes, each class I add on a new package appears also in ModuleB
When I checked on the folders of ModuleB I noticed a weird icon.
Checking the folder (right-click) I can see the option:
Go to Link Target
That basically takes me to ModuleA's folder configuration.
I could find no gradle configuration that makes these references or how to reproduce it.
Any idea how?
These are Symbolic links and are created in Bash. This doesn't have anything to do with gradle.
More info here
Related
I spent the last 1,5 hour trying to make this simple tutorial work in IntelliJ IDEA, as you can see in this video.
When trying to run the code, I get the error:
/[...] -Dfile.encoding=UTF-8 src.HelloKt
Error: Could not find or load main class src.HelloKt
Caused by: java.lang.ClassNotFoundException: src.HelloKt
I have tried setting up SDK, invalidating cache, removing .idea and .gradle, rebuilding project, deleting the profile and adding it again. I tried those actions in different orders.
Here's a screenshot of the project:
It also complains Kotlin is not configured, but I have already configured it.
Here's the run configuration:
Here are the project settings:
Your Hello.kt file needs to be somewhere inside the src/main folder, probably in src/main/kotlin. This is different from the tutorial, because your project is using Gradle, and the one in the tutorial isn't. I think this is because newer versions of IntelliJ use Gradle by default for new projects, which wasn't the case when the tutorial was written.
The use of src/main/kotlin and src/test/kotlin as source code directories is a convention in Gradle (and Maven). When importing a Gradle project into IntelliJ, main becomes a module, and kotlin becomes a source folder within that module. The same goes for test. In your screenshots, the bold text and blue icons on main and test confirm that's how your project is set up. Files outside of those folders aren't treated as source files, which explains why your Hello.kt file isn't being compiled or recognised correctly.
It's likely that the default behaviour of IntelliJ when creating a new project has changed since this tutorial was written. In the tutorial, they select "Kotlin" as the project type and this creates a project that doesn't use Gradle. As a result, the project doesn't use the src/main/kotlin directory structure.
I can see from your video that you selected the same option, but on the next screen, IntelliJ still automatically selected Gradle as the build system for the new project. To match the project structure used in the tutorial, I think you would need to select "IntelliJ" as the build system.
I have two projects, having their own modules:
projectA
moduleA1
moduleA2
projectB
moduleB1
moduleB2
I want to edit both projects at the same time with Intellij Idea. They advice to import one project as a module of another. Ok, let projectA be a module of projectB. I'd like to see the structure:
projectA
moduleA1
moduleA2
projectB
moduleB1
moduleB2
But I get
projectA
moduleA1
moduleA2
moduleB1
moduleB2
What am I doing wrong? Is there any capability not to unwrap the current project structure?
Not going into the configurations of the classpath and other variables, just simply the file structure; I had the same problem at first when attempting to re-create your scenario. Though it is a simple "over-looked" setting of the modules.
The overall layout is:
Now when adding another module (in this case "ModuleA3", Intellij will set the default path to: $PROJECT_DIR$/Module3A
Because of this, Intellij is trying to create this module as a sub-module of the "Top-Level Project"; the solution is somewhat simple, change the path to:
$PROJECT_DIR$/ProjectA/Module3A
EDIT: I can now post images so I included my originals for this question; I find them easier to see what is going on.
-Thomas
I maintain an IntelliJ plugin (Codename one) and we need to control the users classpath. I'm adding a classpath either via the plugin or manually by going to here:
And pressing the + sign where I pick Java:
Then choose classes:
This seems to work OK:
But the completion and other such functionality doesn't work and when I go back the entry is disabled and I get this error message:
This doesn't really tell me anything?
A workaround is to open the .iml file in a text editor, and add the following to the orderEntry list:
<orderEntry type="library" scope="PROVIDED" name="LibraryName" level="project" />
Unfortunately this isn't very practical and it only solves some of the problems I'm experiencing. Any direction or hint would be appreciated here.
Edit: Adding screenshot of preferences UI:
Second Edit: Screenshot of the module section
The answer from kukido is good, for additional details though check out this: http://devnet.jetbrains.com/message/5509300
Essentially what I want is to still have my module but add a dependency programmatically which can be done by:
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
model.addLibraryEntry(library);
model.commit();
This doesn't really tell me anything?
IntelliJ is trying to warn you that you have created a library, but it is not referenced anywhere in the project. It is gently asking "Did you mean to add this library as a dependency?".
The entry is not disabled. It is greyed out to show that it is not referenced in any module as a dependency. Once you add the library to the dependencies list, the color will change.
It is a two-step process:
Create a library
Reference new library in a module
Code completion is not working because your module is not aware of the library classes.
Module dependencies
Non-referenced and referenced libraries
I'm trying to open an existing project into Idea Community Edition (it is a netbeans project). I tried using create project from existing code.
One of the modules ends with .Lib (something like MyApp.Lib). For some reason Idea doesn't import that module, and even if I try to create a project with just that module it doesn't let me (it doesn't even show up in the directory browser, even though that it is there if I check with windows explorer).
I'm guessing it has to do something with the Lib at the end, probably it considers it as a library folder. Does anyone happen to know a way around this?
Renaming the module is not an option, as it is under version control.
I found the solution to this. Needed to remove .lib from the Ignore files and folders in the Settings>File Types section.
After a lot of good comment about IDEA, I decided to give it a try. I downloaded the Community Edition and would like to use it for PlayFramework development.
I have followed official documentation and some other information gathered around, but I have not succeeded completely. When using a project with differents (play) modules, the different classes are not found.
For example when using Secure module, IDEA keeps complaining about not finding Secure.class. It has to be a classpath issue. I tried to attach Java source & classes ($PLAY/modules/secure/) in module settings (F4), class is still not found. Did I miss something?
BTW, I have done a play dependencies and play idealize, which seems to add another module Secure into project in IDEA.
Thanks,
The answer is to run the following:
play deps
play idealize
This forces the IDEA .iml project file to be refreshed with the updated class path entries for the new module (in this case Secure).
A issue I came across using IntelliJ and Playframework.
The log4j.properties file or log4j.xml file are not in classpath by default. You have to add the conf as a source folder in module settings.
You need to add the Secure module you have created in IDEA as a dependency to the main application module:
Go to File -> Project Structure
Choose the main module
Choose the Dependencies tab
Click Add -> Module Dependency
Choose the IDEA Module you created for the Play Secure module
Also make sure you have the correct source path selected for the Secure module in IDEA.