Adding Project Dependancy is not working

Answered

Hi,

Today I've migrated to IDEA from Eclipse and first challenge to solve is adding project dependancy. As per solutions given in below links

https://stackoverflow.com/questions/28865313/intellij-add-project-dependency-like-in-eclipse

https://stackoverflow.com/questions/34832059/how-to-add-a-project-to-build-path-in-intellij-idea?noredirect=1&lq=1

I've tried multiple times but no luck.

I'm using 2017.1.3 version on Mac 10.11.6.

Even after adding module dependancy per above link, I still get compilation error.

Any help with this roadblock in migration is highly appreciated.

Regards,

Vikram

 

1
28 comments

Use the import feature as described in help, IntelliJ IDEA will create .iml files. Then you can import converted modules via .iml files into existing projects.

If your project is Maven based, you should import it from the root pom.xml instead, it would be much easier and will configure all the dependencies automatically.

1

"  I just build single project ( which has got dependency of another )" this statement belongs to Eclipse ONLY.

In Eclipse ( as I had mentioned multiple times earlier ), I don't have to do anything in pom.xml but just add one project as dependent on another.

 

https://stackoverflow.com/questions/10553677/eclipse-how-to-give-dependency-between-projects , check ACCEPTED ANSWER PLEASE

Can you ask somebody else to look into this issue please ?

 

1

@Serge As it's internal project, I won't be able to share code.

Does IntelliJ has sample projects which I can try and update here ?

Thanks,

Vikram

0

Create a new one where module dependencies don't work for you and share it.

0

@Serge, I am back to solve this pending issue.

I found related link https://intellij-support.jetbrains.com/hc/en-us/community/posts/207078395-how-to-add-another-project-to-an-intellij-project-build-path-

 

can you please clarify how can I convert existing Eclipse projects into modules ? 

Thanks,

Vikram

0

 

Refer to above screen shot, I'm not sure why dependent project is shown in RED.

I've common project "appium-framework-noa" and I need this as dependency for other projects e.g. "RiderApp-Automation"

Please clarify

0

sorry your last comment is not pretty clear to me.

1. How to convert eclipse project to IntelliJ IDEA module ?

2. "...then create one new empty project..." why to do this ?

0

Hey Serge,

Sorry my question was not clear I guess.

I did import Eclipse project successfully into IDEA. Now this project A has got dependency on project B of Eclipse.

As per your deleted comment, both the eclipse projects needs to be converted to "modules" first and later I can add one of them as dependent of another.

Please clarify how to convert Eclipse "Project -> IDEA Module", so that I can get this dependency requirement working.

 

 

0

if you refer to this screen shot, I have 2 modules namely RiderApp-Automation & appium-framework.

I've added "appium-framework" under Dependencies for "RiderApp-Automation", but still I get compilation error in later project as it can't recognize class defined in dependent project.

 

0

Is this bug in IJ IDEA ? I ran out of solutions to fix this. Please advice. I've got latest version 2017.1.4 installed

0

Not sure what exactly you mean by the bug. Please send us the sample project via support: https://intellij-support.jetbrains.com/hc/requests/new

and we'll help you with the configuration.

0

Hey Serge,

I've imported both projects with pom.xml and have seen .iml file getting created under individual projects.

Next steps I'm not clear, can you point to help page and explain in detailed steps please

Thanks,

Vikram

 

 

0

If your projects depend on each other and both have separate pom.xml files, you must also have the parent pom.xml file that would define the dependencies between these projects. After you import this root pom.xml file everything will work automatically.

In case you are not aware of this Maven feature, please refer to http://books.sonatype.com/mvnex-book/reference/multimodule.html.

0

In Eclipse I didn't have parent pom.xml and instead used just 2 projects ( with their respective pom.xml ) to create dependancies.

Are you saying IJ IDEA needs 3rd pom.xml ( parent ) to create dependency ?

Can you please point me to help page which explains this feature in IJ IDEA ?

This is how I did in Eclipse which is very straight forward

 

https://stackoverflow.com/questions/10553677/eclipse-how-to-give-dependency-between-projects

".."required project on the build path"..." this did the trick.

 

Please explain how to achieve this simple thing in IDEA ?

 

 

 

0

In Maven projects dependencies manually configured between the modules in IntelliJ IDEA will be discarded on the next Maven project reimport, therefore they must be defined in pom.xml

See https://stackoverflow.com/questions/9282732/how-to-assemble-a-multi-module-project-in-maven. 

0

Serge, I'm really confused now with your last answer. Why does IDEA needs to make this simple tasks so much complicated.

If I migrate to gradle based project how to achieve this dependency ?

 

Isn't there any official help page to explain this basis requirement ?

 

 

0

IntelliJ IDEA imports Gradle and Maven projects in the way they are originally configured. If your project has multiple modules and one of these modules depends on another, and you want to work on them at the same time, it makes perfect sense to have the parent pom.xml or use Gradle multiproject or composite builds feature.

If you have 2 separate Maven projects, they can be imported into IntelliJ IDEA as 2 modules, but IDE will not know how they depend on each other.

How do you build these projects in the command line Maven? How is the dependency on one of the projects is specified in another? Do you just use the snapshot dependency? If that's the case, IntelliJ IDEA will be able to resolve it from your local Maven repository and you should be able to build these module separately.

0

Please find below answers

-  I just build single project ( which has got dependency of another ) I use for running automation cases using command mvn clean verify . There was no need to build both project at least in Eclipse

-  As dependent project is still under WIP, I can't use snapshot solution

-  I'm not sure why IDEA has made it so complicated compared to Eclipse ?

- Why I need to create new project to achieve. one module depending on another ? Can't I achieve this without creating new project ? 

0

It's still not clear how Maven resolves the dependency on another project, please share some example.

0

I'm not sure about Maven dependency on another project, never used it before. can you check your reply "Created "

 

 

 

0

> I'm not sure about Maven dependency on another project, never used it before.

> -  I just build single project ( which has got dependency of another )

These two statements contradict each other.

In order to get help with your problem, please provide any sample project and describe what is not working and what you want to achieve, this way we'll be able to suggest the appropriate setting or configuration.

0

The issue is not clear until a sample project is provided.

0

If you don't understand how to configure the multi project for Maven from the links to the tutorials I've already provided above, see the answer to your other question which is basically the same as this one (for some reason you've submitted it for AppCode project instead of IntelliJ IDEA, we had to move it to the correct forum, please be careful next time).

0

Thanks Serge, I will check the answer and update back here.

0

I am facing the same issue.. 

I have 2 gradle projects. (one is a stand alone component and other is a spring based project). I want to make my Spring based project depend on the component locally. This is to test any changes in the component with the spring based project before I create a jar out of it and push my changes.

In Intellij, after I add my component "module" as a dependency for the spring based module, it does not compile!

Below is the image of the settings.. 

Spring based project --> fngn-ana-authenticator

component --> fngn-authserver-core 

0

>In Intellij, after I add my component "module" as a dependency for the spring based module, it does not compile!

If the project is Gradle-based IDE uses configuration from the build.gradle file to set up project structure, dependencies and build configuration. So you need to make corresponding adjustments in build.gradle fie and then ensure that the project can be built by Gradle from command line. Check gradle documentation about multi-module projects setup: https://docs.gradle.org/current/userguide/multi_project_builds.html

0

Please sign in to leave a comment.