I've recently converted over to IntelliJ Idea 13, previously in eclipse I was able to add a project to another project's build path. I'm not able to accomplish this in IntelliJ.
How can I add project1 to project2's build path so that I can use it as a dependency. I don't want to make that project a JAR because I'm still developing it.
Following this similar previous question:
Intellij - Add project dependency like in Eclipse
I was not able to successfully achieve my goal.
In File > Project Structure > Modules
I see the project I'd like to add to my build path (DataProvider) but it's highlighted red, and the bottom warning text states "Invalid item 'DataProvider' in dependencies list'
Any help or assistance would be much appreciated.
Edit:
Solution (Thanks #leeor)
Import project as a module
File > Import Module > (Select Project to be imported)
This will add that project to the project view pane on the left side of the screen.
Then go to your current project
File > Project Structure > Module > (Select your current project)
Under Dependencies
Check mark your project (now a module) you want to import and then click apply and then OK.
Done!
Using IntelliJ Idea 13.1.6 on Mac
If you want to depend on another module without it being jar, you need to import that as a module into the same project. It doesn't look like DataProvider is imported since it doesn't appear in the module list.
Related
I cloned the maven project to my local disk. The project has 3 modules as well as a parent project. i marked the 3 modules with the 3 colors-- the 4th, blue color is the project itself.
The project is running all fine on maven both on Eclipse and on command line.
When i do a mvn install on Eclipse, the project is built and all the tests are run successfully -- i see the good old BUILD SUCCESS report of maven on Eclipse console.
The problem is -- the modules are all messed up. (this "messed up" is the best way i can put it for now.) Eclipse doesn't recognize the dependencies between modules and gives checked errors to some of the code that use outside dependencies.
At one place-- lombok #Getter is used in one class. import lombok.Getter; is seen by the compiler-- no checked error to that. but eclipse doesn't recognize the getter declaration of lombok, say getField() for the field field. i know this because : a) in the class itself-- gives a warning that .. the private field field isn't used.
b) gives a checked error to getField() a reference from another class.
Thought this might be an interesting example to how the dependencies are "working". i'm guessing one dependency that lombok is using is intercepted somewhere along the way to give this inconsistency.
Following is the project root directory structure on disk. (the 3 colors are the 3 modules, have to hide the names for confidentiality):
the 3 modules are defined in the pom.xml as follows:
i see the following in Eclipse project explorer:
so in the Project explorer, the 2 modules/tests (green & yellow) that have java dir, i.e. src/main/java appear twice. the orange module has only src/main/resources and no src/main/java.
In the second occurrences of the modules in the project explorer (the image above), there are no dependencies of any kind, not even Java itself and hence all those red dots all around (compiler errors). The first occurrences of modules have Referenced Libraries and no Maven Dependencies:
How to fix this project so that i can code and run in Eclipse? Just to pin down-- project configuration is all fine and it runs successfully on maven. the problem is Eclipse's own settings on it.
so far i tried the following:
made the project faceted and added Java as the only one to its facets
imported as Maven project -- File > Import > Maven > Existing Maven Projects
ran mvn eclipse:eclipse on its pom.xml
Wasn't even seeing the Build path before these.
i'd appreciate the help-- wore me out.
everyone else on the project is IntelliJ developer-- no workspace to compare with.
i've seen Importing Maven project into Eclipse and some other useful discussions.
i'm not sure whether i should post .project, .settings and some other file contents also.
will do if necessary.
TIA.
Make sure to not only import the parent pom.xml, but also the Maven modules as projects into Eclipse. To do this in one go, use
File > Open Projects from File System... or
in the Git Repositories view right-click the root folder and choose Import Projects...
Make also sure Lombok has been installed into Eclipse, otherwise Eclipse's own incremental compiler would not generate e.g. getter and setter methods that are defined by Lombok annotations. See the Lombok documentation of how to install Lombok into Eclipse. If you have installed Lombok after importing the projects, it might be that you need to do a Project > Clean... or close and reopen again the projects (via the right-click menu).
How do I properly import a Maven multi-module project into Eclipse? When I import a new Maven project and select the parent pom, I can see the submodules under the parent pom which are visible in the package explorer and project explorer. However, they are presented as a deep directory structure, as if Eclipse doesn't know they are Java projects.
When I expand the submodule project, I don't see the Java package shortcuts as I would have if I opened a single Maven project. I only see it as a deep directory structure. How do I import a multimodule Maven project and open the submodule project to take advantage of Eclipse Java project features?
Install M2E Plugin from Market if it is not already installed
From Eclipse IDE choose "File" and "Import" from toolbar. That should
lead you to a pop up.
Type "Existing Maven Project", or navigate to this under
Maven settings.
Then select the main pom project from the import menu, and be sure
to select entire tree of projects under it.
Before approaching this clean the IDE from the currently wrong imported project, deleting its Maven root pom project and every submodule, but leave them on the disk obviously.
I don't recommend the "Convert" options as sometimes that doesn't lead to clean results, especially with big and messy projects.
First, import the parent project. Then, right click on it at the package/project explorer, go to Configure and then click the Configure and Detected Nested Projects..., on the window that will appear click Finish and you're gold.
Also worth mentioning, Package Explorer won't show it nested, use Project Explorer instead.
Have a nice day.
For everyone who still have the same issue, follow these steps:
Open Import Existing Maven Project wizard
Select the Parent POM.xml only and click Finish
Foreach child project, Right Click on the project folder, then click on Import and select his POM.xml file
Hope it helps ! Good Luck !
If you are using git or any version control. Clone the repository first in local.
Steps already explain by #Black Jack. Adding image to support
Step 1
Navigate to project folder.
Open command prompt (or shell)
Run mvn eclipse:eclipse
Step 2
Open eclipse IDE
Open project from File > Open Projects From File System...
Select folder of project containing parent pom.xml file
Step 3
Run Project > Clean from Menu
Step 4
Run File> Restrat From Menu
Solved my problem in Eclipse 2019-06(4.12.0) and 2018-12(4.10.0)
Important trick
When you start to search for files in 'open resource' (for example using Ctrl + Shift + R) eclipse will show file from two address. for example MySampleFile will be available under:
parent-module/sub-module/src/main/java/.../MySampleFile and
sub-module/src/main/java/.../MySampleFile
Use second one. Opening file with first one will not activate IDE features on that file.
To add a few on top of #BlackJacks answer, ensure that the parent pom in the root of the directory that contains sub-projects contains a modules section:
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
So, after the import, unlike IntelliJ, Eclipse opens the sub-modules as separate projects, apart from the main root project.
Hope this helps!
Follow the steps
Choose file menu
Click on import
Select project right click then Convert --> Convert to maven project
Click on import then type or select Existing Maven Project
Now your moduled project in you workbench. If you have any query we can discuss.
I am developing a plugin for IntelliJ as part of a larger research team. The logic for the plugin was developed and tested as a Java project in IntelliJ IDEA. Now the time has come to develop the front end, and the module is not configured as a plugin. How should I go about converting the Java project to a plugin project?
It is not reasonable to start the project over as a plugin project, because it has complex dependencies on several other modules.
This is a similar question to how to import existing plugins, but is different because the code is not a plugin yet.
These are the steps I have followed so far:
Create a new action class (that extends AnAction) to be the main class for the plugin.
Create a run configuration for the plugin. I get this error: Run Configuration Error: No plugin module specified for configuration
Follow the instructions given by OpherV in the question I linked to above to change type="JAVA_MODULE" to type="PLUGIN_MODULE" in the .iml file.
The third step did not resolve the "Run Configuration Error: No plugin module specified for configuration issue." What additional steps are needed?
I am using IntelliJIDEA (Community Edition) 14.1.4 Build #IC-141.1532 on OSX 10.11.1.
I was able to successfully convert the project into a plugin by following these additional steps:
Create a META-INF directory in the root of the project. Inside of this directory create the plugin.xml file. In plugin.xml, register your action. See the IntelliJ code samples for examples of what this file should look like.
Right-click on your project root in the project view (Cmd-1 if it’s not open already) and choose “Open Module Settings” (Cmd-down). This will open Project Structure > Modules > Dependencies.
5.1. Alternately, you can get here by opening the Project Structure with Cmd-; and then choosing Modules and picking your project from the list and going to the Dependencies tab.
Make sure the module SDK is the IntelliJ Community Edition instead of the normal Java 1.8 (or whichever version you have). (I noticed that this changed a line in the .iml file, but you should change the SDK here so you can create it as described here.)
At the bottom of the dependencies window, there is a plus. Click it, and follow the instructions given by samkass in the answer to this question, which I will reiterate here with more context-specificity for ease of following them:
7.1. Once you have clicked on the plus button, select “Jars or directories…”
7.2. Navigate to the META-INF folder, select it, and click OK
7.3. In the dialog that comes up, select “classes” and NOT “jar directory”
7.4. Make sure you’re using that Module in your run target
Once I followed all of these steps, the "Run Configuration Error: No plugin module specified for configuration issue" went away and the Run Configuration I had created worked. I ran it and my action was available in the Refactoring menu as I had registered it in plugin.xml.
I'm switching to Intellij and trying to do the same thing as in Eclipse. In Eclipse, you can add a project as a dependency in another project (project properties -> "Java Build Path" -> "Projects" -> Click on my library project).
The current situation is that I'm developing a library and I can test the features in another project without building the jar file every time I add new stuff to the library.
I'm trying to achieve this with Intellij but without success (the projects are both imported in Intellij).
How can I do that?
File > Project Structure. Then choose your module, and add any dependency, either Jar, Library or Module:
Larger image here: http://i.imgur.com/rjdxJHx.png
From File -> project structure, select Modules. You will be presented with all the added projects. Click a project and from the right hand side select Dependencies tab. This will show you projects that are not imported in red coloured text. HTH
File > Project Structure > Project Settings > Modules
Add the module you want to add as dependency.
Add your module dependency in your project.
If you use Maven you'll see the following message:
Module 'your-module' is imported from Maven. Any changes made in its
configuration may be lost after reimporting.
→ Add your project to your pom.xml
If you don't do that, your dependency will be removed each time you reimport/refresh maven projects.
I have a project with a number of POM files. I have done a clean install and eclipse:eclipse. I would like to import the project as a normal project rather than Maven project. When I imported the project as normal project , I was not able to see the Maven dependencies present in POM in eclipse's build path. Is importing the project as Maven project only way of doing it? When I import the project as Maven project I see a number projects in eclipse workspace (one for each POM). However I would like to view this as a single project in eclipse workspace.
UPDATE: The classpath files of the child projects contain the dependent jar files , however it is not added to build path when the main project is added. Only the entries in classpath file of the main project is being added.
Given that you refer to "Maven project", are you using an eclipse plugin for Maven like M2Eclipse?
Assuming you are using M2Eclipse, the Maven Dependencies Library is automatically enabled for a Maven project. For a normal Java project, importing the library would force you to configure the project as a Maven project (On the context menu for the project, select Configure -> Convert to Maven Project).
Having said that, while you import your Maven project, you will notice an "Advanced" option (towards the lower section of the "Import Maven Projects" dialog). When you expand this option, there will be a checkbox to "Resolve Workspace Projects" - this is checked by default and is hence responsible for importing the child modules as separate projects. If you uncheck this, it will import only the parent module as the project and all children modules will be in sb folders under the parent module.
IMO, resolving the projects provides greater clarity, but then again this is very much a personal choice.
Hope that helps.
Eclipse doesn't support nested projects, and Maven kinda forces you to. So you can't really push everything into one project.
Doing a cursory google search led me to this, which might be helpful: http://warpedjavaguy.wordpress.com/2011/08/08/how-i-defeated-the-maven-release-plugin-in-a-flat-structured-multi-module-project/
You might also check out the following two online books from Sonatype:
Maven: The Complete Reference and Developing with Eclipse and Maven
Personally, I create Working Sets for each multi-module project and add all the individual projects to it. This enables me to see them all grouped together, this might be to your liking.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset.htm
Once you have created the working set you can enable/disable them in the menu in Project Explorer and configure the project explorer to display the working set as the root element in the tree rather than the project.