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.
Related
I have two gradle java projects imported into Eclipse, one being a dependency of the other.
I would like for Eclipse to use the local dependency code, instead of the compiled dependency in the gradle cache folders, so I can modify and debug both projects simultaneously.
How do I force Eclipse to use a local dependency code?
The feature you are referring to is known as Composite Builds:
Importing into the IDE
One of the most useful features of composite builds is IDE integration. By applying the idea or eclipse plugin to your build, it is possible to generate a single IDEA or Eclipse project that permits all builds in the composite to be developed together.
In addition to these Gradle plugins, recent versions of IntelliJ IDEA and Eclipse Buildship support direct import of a composite build.
Importing a composite build permits sources from separate Gradle builds to be easily developed together. For every included build, each sub-project is included as an IDEA Module or Eclipse Project. Source dependencies are configured, providing cross-build navigation and refactoring.
The most simple way of achieving this is to use includeBuild in your settings.gradle.
rootProject.name = 'my-composite'
includeBuild 'my-app'
includeBuild 'my-utils'
With that in place, there's no need to configure the build path manually in Eclipse.
Gosh this was a trivial one and it took me way too long to figure it out.
Solved the issue by creating a file named external-projects.properties in the root folder of the parent project with the relative or full path to the dependency project folder.
To be precise, for me the folders tree ends up like this:
git-folder/
|__parent-project/
|__external-projects.properties
|__build.gradle.kts
|__rest (src/main, etc)
|__dependency-project/
|__build.gradle.kts
|__rest (src/main, etc)
And the contents of the external-projects.properties file:
dependency-project = ../dependency-project
The dependency project must also be in the build path of the parent project (done by "Right-Click project > Build Path > Configure Build Path" and adding it in the "Projects" tab).
After that, a "Right Click > Gradle > Refresh Gradle Project" did the trick.
IntelliJ is not importing my modules dependencies for some reason. Like it's not taking into account my modules pom.xml. The dependencies added for example in the core module don't figure in the External library of the subject. As I'm not yet that familiar with intelliJ I assume the problem comes from the project structure so here it is:
You need to import the project as a "Maven Project".
Remove the "wallbang" module with the "-" button.
Click "+" -> "Import Module", then select the pom.xml.
Configure it using the wizard.
Click "Ok"
That should open up the Maven view and automatically include all dependencies.
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.
I added this 'org-netbeans-modules-lexer.jar' dependency to a netbeans platform module. But it seems not getting added in the normal way. Imports cannot find its classes as well.
This is how it is shown when added. Any suggestion? Netbeans version 8.0.2
Right click main project properties -> select libraries -> expand 'ide' in platform modules list -> select Lexer module to be included in the project. This resolves the issue.
This method is general for adding any dependencies that can be found only by ticking 'Show Excl. Modules' in dependency adding dialog which can be opened by project module properties -> libraries -> module dependencies -> add dependency.
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.