How to find out which maven artifact/plugin is requesting for the download of a no longer available dependency - maven

I was compiling an "old" open sourced project, while encountered this problem:
[ERROR] Failed to execute goal on project .... Can not transfer artifact x:y:z from ...
the artifact x:y:z is not found from all repositories defined in the project pom.xml.
After looked up the effective pom.xml, I could not find any references to x:y:z.
How can I find out which artifact or plugin is requesting a missing dependency without analyze all transitive dependencies?

If you use eclipe - you can see dep tree like this: open pom.xml and tick "Dependency Hierarchy" tab.
Also you can try to use mvn dependency:tree but I am not totally sure that it will work if some of your deps are missing.
UPDATE: seems like both eclipse and dependency:tree require sucessfull artifact resolution to work whch is not your case.
In this case I guess you're left with 3 opttions:
clean your cache (wipe everything under ~/.m2/repository), run your build and do occurence search (search for something like "problematic-artifact-id") on files in your ~/.m2/repository. One or couple of the artifacts should reference the problematic artifact in their pom. This should give you a hint.
clean your cache and run your build with -X switch. This will put maven in verbosity mode and you should find some hints about what might reference dead dependency (point your attention on download order, what artifacts got resolved, check dependencies of resolved artifacts in their poms)
dumb as hell - comment/uncomment deps in your pom and see what causes the mentioned error.

Related

Maven transitive dependency not found. Leads to build error

I'm trying to build a Java project with Maven. My pom.xml includes mainly dependencies, some of which have their own transitive depedencies.
When I run 'mvn compile' most dependencies are loaded fine, but some of the transitive ones are not found, giving the warning "[WARNING] The POM for artifact_name is missing, no dependency information available". This leads to the Maven compile to fail.
The logs show, that the dependencies have been searched from Maven and Jboss public repositories.
What can I do in this situation, when a transitive dependency is not found?
How can I determine what dependency requires this transitive dependency? Command 'mvn dependency:tree' does not work, as it ends in build failure
Thanks in advance!
EDIT: I decided to delete all changes made to the pom.xml and downloaded the original one. After that the warnings with the transitive dependencies went away. So it seems that the issue was possibly with the syntax or some other change in the pom.xml.
I decided to delete all changes made to the pom.xml and downloaded the original one from our repository. After that the warnings with the transitive dependencies went away. So it seems that the issue was probably with the syntax or some other change in the pom.xml

mvn dependency:purge-local-repository fails in multi-module project

We have a maven project structure like this:
Parent
L A
L B
A depends on B
Both have various dependencies on other libs
Building this with mvn clean install works fine, but when we try to prune all dependencies as described here with
mvn dependency:purge-local-repository
We get an error saying that it can't resolve the dependency to B:jar:snapshot-version:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:purge-local-repository (default-cli) on project A: Failed to refresh project dependencies for: A:jar:4.0.1-SNAPSHOT: required artifacts missing:
[ERROR] B:jar:6.0-5
My current interpretation is that during an actual build B gets build first and can get resolved, but during the purge nothing gets build so the resolution fails. But the project is there and its dependencies should get purged. How can I fix this?
-DactTransitively=false
doesn't seem to change anything.
While it doesn't seem to be the exact issue referenced by #Tunaki the example in there let me try this:
mvn dependency:purge-local-repository -DreResolve=false
Which got rid of the exception but failed to actually reload the dependency I had problems with. At which point I came across this answer which made me try
mvn dependency:purge-local-repository -DreResolve=false -DactTransitively=false
which solved the problem although it seems to requesting the opposite of what I wanted to achieve :-/
This looks like a bug with the maven-dependency-plugin (JIRA issue MDEP-405) introduced by a regression in Maven 3.0.4.
From Paul Gier's comment:
I think the reason this happens is because in order to determine the full set of transitive dependencies to delete, the poms need to be available. If the poms were already resolved in the previous module, Maven won't re-resolve them again and just fails. So the dependency doesn't have a problem with the file already being deleted from the local repo, but the maven dependency resolution code fails when trying to resolve the same file twice in the same build.
You might try the build with Maven 3.0.3 because there was a change in this in Maven 3.0.4:
http://mail-archives.apache.org/mod_mbox/maven-dev/201210.mbox/%3C5752023.Vp0WJBo1vZ%40bigmax%3E
This is linked to the regression MNG-5366, that is currently unresolved.
I don't see any real work-around apart from downgrading Maven.

Maven: Command line to download the dependencies described in the pom.xml

I would like to know the maven command line to download the dependencies described in the pom.xml.
It is that : mvn dependency:copy-dependencies ?
Try the dependency:go-offline goal. It's meant to be used to resolve dependencies to the local repo before using the -o switch to go to offline mode. But the goal itself has no bearing on going offline. The name may be misleading.
Goal that resolves all project dependencies, including plugins and reports and their dependencies.
Here's the details about the dependency:copy-dependencies in case you're interested
Anther option is the dependency:resolve goal
Goal that resolves the project dependencies from the repository.

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.

Maven POM error - POM is missing

I am trying to build a maven project. My other team members are able to build it without issues. I get the following errors:
[WARNING] The POM for org.hectorclient:hector-core:jar:1.0-3 is missing, no dependency information
available
[WARNING] The POM for org.hectorclient:hector-test:jar:1.0-3 is missing, no dependency information
available
Then the build fails with the error: Could not resolve dependencies for the project XYZ. What could be possibly going wrong?
Surely the jar is missing from your .m2 local repository.
Assuming the dependency is written in the pom.
What I suggest:
Case: When you have internet
fire mvn install that will follow your POM.xml and it will download all the necessary jars.
then fire mvn compile to build.
Case: You are having restricted internet connection that is restricting / no Internet
Take the repository + POM from other machine that is compiling successfully
then fire mvn -o compile
I assume it will solve your case.
#Vaibs You are correct. Adding to your answer:
"Check the settings.xml of yours and the others. If you are not able to download the dependencies from internet like the one you mentioned due to some reason then you will need to set up maven somewhere else and and fire "mvn install" there to get the latest dependencies and put those .m2 into yours."

Resources