Intellij-idea module dependencies does not contain internal maven dependencies - maven

Problem: make module fails because intellij fails to bring the dependencies of a snaphot dependency. Building the module through maven works fine while it fails when trying to build it through make module.
When looking on the iml file, only the snapshot dependency exists but not the internal dependencies.
The local repository contains the jar and the pom file of the dependency.
In the main pom:
<dependency>
<groupId>com.aa.bb</groupId>
<artifactId>myArtifact-dev</artifactId>
<version>6.3.00-SNAPSHOT</version>
<\dependency>
This dependency exists in the local repository. The iml file does not contanis the dependencies listed in the pom file of this dependency.
I make reimport from the pom file but it doesn't help.
Any idea?

I was able to resolve the problem by:
mvn -X -U idea:idea
This way I was able to see why it failed to parse the pom file and fix the problem in the pom file.

Related

Getting an error "Missing artifact com.beust:jcommander:jar:1.66" in maven pom.xml file.Any suggestion how to resolve this?

I have added the required dependencies in maven pom.xml file.
Downloaded the dependencies in pom.xml file via Maven Install option
Updated the project.
After updating the project, i found the error message "Missing artifact com.beust:jcommander:jar:1.66" in pom.xml file.
I have tried including the dependency of jcommander 1.66 version in pom.xml file but there is no change.
Any suggestions would be of great help. Thanks
Maven does not only need the dependencies in your POM, but also the transitive dependencies, i.e. their dependencies, the dependencies of their dependencies and so on.
This is why you let Maven connect to standard Maven repositories like MavenCentral. Except for unavailable artifacts, manual installation of artifacts should be avoided.

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

How to properly remove a dependency in a Maven project

I have a Java Maven project where I have some dependencies defined in the pom.xml file. Recently I decided to move from Junit to TestNG so I deleted the Junit dependency from my pom.xml and added the TestNG one.
I was expecting to see the Junit jar library disappear from the Maven Dependencies folder as a part of the process but that didn't happen. I can still see the jar file in the dependencies folder and it is still being used by my test cases.
I can see TestNG jar is there as well but it's not being used. I can change it manually of course but that wasn't my intention.
Am I doing something wrong are there any additional steps that I missed that will allow me to remove the old dependency?
The following applies for the global .m2 folder where maven dependencies can be downloaded and is common to your maven projects.
the .m2 folder will not clean by itself as those dependencies could be used in another project so its wrong assumption that replacing a dependency in a a pom file will automatically remove from your repo.
you can look at the depedency plugin and run the following
mvn dependency:purge-local-repository
or
mvn dependency:purge-local-repository -DreResolve=false

Maven Could not resolve dependencies

Now, i have a project which runs fine on my windows computer. But after I copied it to a linux computer, when compiling it reports following error:
Failed to execute goal on project alert: Could not resolve dependencies for project com.cloud.ras:alert.
The POM for com.external:commons-logging:jar:1.0.4.1 is missing, no dependency information available
The POM for com.external:freemarker:jar:2.3.4 is missing, no dependency information available
The POM for com.external:log4j:jar:1.2.14 is missing, no dependency information available
The POM for com.soa.lib:eBoxServiceCommon:jar:2.5.3 is missing, no dependency information available
but i have copied these jars to the maven repository. And can anyone give me a help?
You should NOT copy JARs in the first place. That's Maven job to resolve the dependencies for you.
It would be helpful if you explain the reason why you need to use your own groupId e.g. com.external in the first place i.e. commons-logging is from Apache but you use com.external as its groupId.
If you really insist on wanting to use your own groupId, at least download the JAR and install it using Maven. See here:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html.

What does it mean to say that a pom is installed in local repository?

From the book Maven: The Complete Reference inside the section 3.6.1. Grouping Dependencies it says :
If you create this project in a directory named persistence-deps, all
you need to do is create this pom.xml and run mvn install. Since the
packaging type is pom, this POM is installed in your local repository.
You can now add this project as a dependency and all of its
dependencies will be added as transitive dependencies to your project.
When you declare a dependency on this persistence-deps project, don’t
forget to specify the dependency type as pom.
What does it mean to say that a pom is installed in local repository?
Every time Maven needs to find a a dependency, it first looks in the local repository - commonly located in an .m2 directory in your user home. If it can't find the dependency there, it downloads the dependency into your local repository and uses it from there.
When it says a pom is installed in the local repository, it means the POM file was copied into the correct place in the local repository. Other projects you build locally can then resolve that dependency and use it.

Resources