I recently switched from eclipse. With eclipse, I was used to have "non-src" projects (General->Simple Projects) in my workspace. They were pretty handy, since I could use them for version control of documentations, configure servers, ...)
Now with intellij, I am missing this feature. I only can import src modules into my project, otherwise I get the warning "nothing to import". Any idea how to trick intellij to accept a plain old file system directory?
Update:
To clarify, this is my setup:
root (trunk, sync with svn)
+- maven-project (root pom.xml)
|+- module a
|+- module b
|\- ...
+- documentation
|\- word/xls/...
\- server
\- jboss home dir
I sync (update) directly on "root" to keep everything together.
I imported the structure to intellij, but only got the "maven-project" (with all submodules), not "documentation" nor "server".
I would like to have the folders next to "maven-project" in my project structure. That way, I could easily edit server settings files within idea for example or add/commit new office files without using extra tools or cli.
Hope this helps to get the picture.
Unfortunately there is no kind of "Empty Module" or "Facet-less Module" in IntelliJ.
In such cases I just create a static "Web" project, as I think this is the least invasive type for modules, which doesn't need any facet:
File -> New Module
Static Web -> Web
At "Content Root" -> Point to your sources
Can you bypass the import feature and just create a new module, and then copy the contents in there?
Otherwise, do you really need a module at all? Folders can quite happily sit in the file structure of your intellij project without being modules.
Related
Every time I create a new JavaFX project in IntelliJ it loads a simple HelloWorld project in it. How can I make it empty instead (without the need to delete those .java files every time)? Also how can I choose to create the project without a building system (as you can see in the picture, I'm always forced to create the project with Maven or Gradle)
When creating the new project, choose "Java" instead of "JavaFX".
A JavaFX application is just a Java application, so if you don't want the additional things which IntelliJ is doing when you choose to create a JavaFX project (e.g. supplying example code and associating with a build system like Maven or Gradle), you can just choose a basic Java application project from the wizard and it won't do those other things.
See the section in openjfx.io documentation titled "JavaFX and IntelliJ IDEA" for other steps you need to take:
Set the project JDK
File -> Project Structure -> Project
Create a JavaFX library in Idea
File -> Project Structure -> Libraries
Point to the lib folder of the JavaFX SDK.
Add VM options for the module path
Run -> Edit Configurations...
--module-path /path/to/javafx-sdk-15.0.1/lib --add-modules javafx.controls,javafx.fxml
For windows use quotes around the path and \ rather than /.
Run the project
Run -> Run...
You might also need to take the actions identified in the accepted answer to:
How to convert a normal java project in intellij into a JavaFx project
But that answer was written a while back and setting the resource copy configuration to include JavaFX fxml and css files might not be needed anymore.
Now, you might think that is annoying amount of things to do, and I might agree with you.
I am trying to learn about annotation processing by looking at this sample.
I've cloned it to my local machine and used IDEA to open it.
However IDEA tells me:
Project SDK not set up.
After setting up Java SDK, the project is not opening correctly. So how can I open this project?
The project structure :
annotationprocessing10
|
|------factory
|-----annotation
|------pom.xml
|-----processor
|------pom.xml
|-----pom.xml
|-------factory-sample
I tried opening annotationprocessing10 (root) directly and also tried factory directly but neither worked. Here is a screenshot of the directory structure:
The given repo is not a maven module (no POM.xml in the base directory), the maven modules are the projects inside.
Make sure you import the modules inside the root directory in IDEA to identify it as a maven project.
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:)
I want to use IntelliJ in the following manner. A Project (akin to Eclipse workspace) that contains multiple modules (akin to Eclipse Projects). As you can guess I am moving over to IntelliJ from a more recent Eclipse background.
I set up an empty project called MainProject which appears in the dir structure:
C:\IntelliJProjects\MainProject
This correctly contains my ".idea" directory. I want this to stay out of source control and on the C drive.
I then added two Java modules, one for each component within the project that I will work on. These are in perforce and under a p4 client spec with a root
V:\dev
("V" is a network drive that the code has to live on but I do not want the IntelliJ project files to live there). The two modules have a content root
v:\dev\component1\trunk\src
v:\dev\component2\trunk\src
This all works ok. I have marked the content correctly in the module, src, test etc
Now for the issue. When I try to set up perforce the project root is:
C:\IntelliJProjects\MainProject
but the client spec root is
v:\dev
so I get the following error when I test the connection
<pre>
Connection problems: </br>
Wrong client specification: </br>
Client roots: </br>
v:\dev </br>
Actual root: </br>
C:\IntelliJProjects\MainProject </br>
</pre>
When using Eclipse, Perforce has never been concerned with where the Eclipse workspace is so likewise I was not expecting IntelliJ to be concerned with where the project file is stored. I can see many cases where you would not want the project or indeed the module .iml files under perforce but the code certainly would be.
The only way around this would be to have the project file on the network drive under the client spec but as it is at the project level it could not rightly live under either:
v:\dev\component1
v:\dev\component2
so I would have a project under
v:\dev
which would break if I ever altered client specs
The only other way I have figured out is that I add
v:\dev
as a directory under "Version Control" where you can add in directories
has no VCS
v:\dev has VCS defined as perforce
Is this the only way or can anyone advise a better approach?
I know this is an old question, but i'm having the same problem now and i managed to solve it.
I have an IntelliJ project in a folder A, while my Perforce workspace is in folder B.
In my project i have both modules inside the project folder and inside the Perforce workspace, and i was having the "Wrong client specification" error as i mapped the whole project to Perforce.
All i had to do was to go to:
IntelliJ project preferences -> Version Control
click on the + and add map my entire Perforce workspace directory to Perforce as a VCS, as in the picture:
Your setting is correct. If you map whole "Project" to Perforce VCS, IDEA will consider everything in your project (including .idea) to be under Perforce, which is not what you want.
BTW it's strongly advised to keep project source on local disks, otherwise IDEA might have issues with file synchronization or just might function slower than it could be.
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.