How to force intelliJ to import a maven dependency with classifier as a "Maven Library" instead of "Intellij Module" - maven

In my maven based IntelliJ project I have 2 modules - modules A and B.
The pom.xml of module A creates an uber jar (including dependencies which are not accessible by the project) and attaches it as an artifact with classifier "withdeps"
The pom.xml of module B has a dependency on the classified "withdeps" artifact A
When I import the maven modules IntelliJ adds the module's A source code in the dependencies of module B (ignoring the "withdeps" classifier).
Is it possible to force Intellij to add the module A dependency to B as "maven library" instead of the default "project source code/Intellij module"? If not what can I do to resolve the compilation errors in IntelliJ (Ctrl+F9)
Thanks

Open the pom.xml of module B only when creating the intellij project. Then all dependencies will be as maven dependencies.
The downside is that this way you will have to open module A as separate project in another window, then when you change something you will have to do mvn install and refresh project B.
Much better solution would be to install all depencencies into maven repository, described here in maven docs.

Related

How to add a Dependency via Maven for an Eclipse Plug-In Project

I'm working on a Xtext/Xtend based plugin for Eclipse. My project structure contains of various Plug-In projects. The project was created as a maven project and converted to an Xtend project. Developing and building works fine but now I'm at a point where I want to add a dependency (org.apache.poi) to one of the plug-in projects.
I added the <dependency> node from maven central to my pom.xml in the parent project and it got downloaded to my local maven repo. So far so good but when I try to import org.apache.poi.xssf.usermodel.XSSFWorkbook in one of the (child) plug-in projects it can't be resolved.
When using maven in a plain Xtend project I have no problems using it. After adding the <dependency> to my pom.xml I'm able to use it afterwards. So I guess the problem lies in the fact, that I'm now dealing with a plug-in project. At the plain Xtend project, for example, I have a "Maven Dependencies" classpath container which I don't have in my plug-in project.
What I've tried so far:
added the <dependency> to the pom.xml in my parent and/or the child plug-in project where I want to use it
added the dependency via Eclipse GUI (opened pom.xml -> Add Dependency)
added the dependency via right MB on plug-in project -> maven -> Add Dependency
Maven Update Project
clean install -U after adding the dependency
clean/build project
In the MANIFEST.MF I can't add the dependency as it is not shown in the list of dependencies to choose.
What's the way of adding maven dependencies to a plug-in project in Eclipse?

Maven default evaluation of the pom xml file

We do not have project design in parent and module way.We have project A and project B . Project A has dependency of project B . we passing the version of the dependency jar by command prompt in eclipse, Its compiling and install properly. but its pom shows always error.and error is like
Missing artifact
com.testdependency:testdependency:jar:org.apache.maven.model.Build#5ae16e48
Passed the build parameter by command line like -Dbuild. Is there any way resolve this ?
pom.xml would need the dependencies present in your local .m2 repository. If you don't install the dependencies to your local repository, pom.xml can't find them. So, run a build on your dependency project with goals selected as clean install, which should insall the artifact to your local repository. Then in your eclipse, right click on the main project and execute Maven -> Update Project. This should resolve your issue.
Refer to this link for the details on the repositories

IntelliJ IDEA, the Libraries added to the Intellij are not automatically updating pom.xml

In intelliJ IDEA,
I add libraries dependencies in
pom.xml
and "Project Structure -> Project Settings -> libraries -> add ->from maven"
but now, how to write the '2' dependencies to pom.xml automatically?
because there aren't '2' libraries dependency in pom.xml. they aren't synchronization.
I already set Settings > Maven > Importing > Import maven project automatically, Don't work.
note: I want to the Libraries added in the Intellij which can automatically updating pom.xml file.
In settings / Maven, you can switch to "import maven project automatically".
Then, when you modify a pom.xml, it will update your project (ie download new dependencies) automatically
I dont think pom.xml is something which will automatically generate dependencies, If so there wont be any point to maven build type itslef.

how to run only specific maven module

how to run only specific maven module from maven eclipse project.
I have few modules in my EAR maven project and when I build whole project it fails at one module WAR,saying this war artifact module not found in repository.
Your multi module project must e having a common parent. First install that parent pom in your local repository. Now go to child module project and maven build the project.
It should work given that all its dependencies are present.

IntelliJ - How to link modules for maven goal

I have successfully imported a parent pom with child modules into IntelliJ. The child modules have dependencies between themselves and IntelliJ has correctly set up the classpaths so that changes to module A are reflected in module B. However these dependencies are not maintained when I execute a maven goal in IntelliJ (compile, jetty:run etc). Here is my structure:
client_libs
-- servlet-filter
-- filter-example
filter-example depends on servlet-filter. However when I run maven compile on filter-example I get:
The POM for com.cloudseal.client:servlet-filter:jar:1.0-SNAPSHOT is missing, no dependency information available
I can work around this by manually installing servlet-filter into my local repo before I execute a maven goal but obviously this is not ideal. How can I get IntelliJ to maintain the relationships between the modules when I execute a maven goal?
You shall be able to just run mvn package but from place/path where your parent pom is.
If this's not working for you, please post your pom.xml files.

Resources