The POM for <name> is invalid, transitive dependencies (if any) will not be available

匿名 (未验证) 提交于 2019-12-03 01:49:02

问题:

This question is outdated and no longer relevant. I have since moved to Gradle for my project build and can no longer verify that answers do or do not work.

I've run into a few issues with Maven. Let me first describe my project setup:

Framework |  -- Apache Commons Math 3.0 |  -- Bouncy Castle 1.5 |  -- etc.. (lots more) |________ |        Client |        | -- GUI libraries |        | -- etc. | |________          Server          | -- Server Libraries          | -- etc.

So essentially I have a framework that contains most dependancies and then two projects, "Server" and "Client" that contain their own BUT also the framework as a dependancy (being a module of Framework.). I installed the Framework project into my local repository and both my projects can see the Framework-Native code (aka my own logic). HOWEVER they don't seem to be able to use any of the dependancies of the Framework Project. When trying to build either of the "child"-projects I get this:

Invalid POM for de.r2soft.empires.framework:Framework:jar:Alpha-1.2,  transitive dependencies (if any) will not be available,  enable debug logging for more details 

I've tried to find the reason behind this (or better yet a solution) but haven't found anything that fixed my issues. Hope someone here can help. My maven version seems to be 3.2.1 (that's what -version tells me anyways)

Here are my framework-pom.xml and the client-pom.xml on pastebin:

Framework: http://pastebin.com/cceZECaT

Client: http://pastebin.com/1Cuxve5F

Help is appreciated.

回答1:

I had a similar error, In my case remove all related artifacts from the local repository was the workaround...



回答2:

Assuming that the client and server projects poms are invalid because of unsatisfied expansion, then the following should work... If the "client" and "server" projects have their dependency on "Framework" defined in a tag, then you can first install "Framework" using the -N option. First, cd to the Framework directory, then: mvn -N clean install The -N option tells maven to only install the root pom in the local repo and to skip the child modules. Now cd to your child project and rerun your install command in your client or server module. The client or server build should now find the parent pom with the properties that it needs in the local repo.

You can get the same effect by making an explicit file path reference using the relativePath tag in your child pom's parent tag:

../my-parent


回答3:

One reason for this is when you rely on a project for which the parent pom is outdated. This often happens if you are updating the parent pom without installing/deploying it.

To see if this is the case, just run with mvn dependency:tree -X and search for the exact error. It will mention it misses things you know are in the parent pom, not in the artifact you depend on (e.g. a jar version).

The fix is pretty simple: install the parent pom using mvn install -N and re-try



回答4:

I have the same kind of issue and I may have the answer. I have a top level project MyProject and Module1 and Module2. Module2 depends on Module1 and the entry is listed as a (default) dependency. MyProject

 Module1 Module2

mvn dependency:tree from the folder of MyProject is OK: module2 depends on module1

MyProject --- com.acme:Module1:version --- com.acme:Module2:version +com.acme:Module1:version

The problem is if I run mvn dependency:tree inside the Module2 folder. I then get the error message:

The POM for com.acme:Module2:version is invalid,  transitive dependencies (if any) will not be available

After a few investigations I have discovered that the pom file created/copied by the install part of the build as m2/com/acme/myproject/Module1/version/Module1-version.pom is the original pom file. This one uses variables for versions as (duplicated in many other modules not listed here) or a system path (no choice to have a system dependency). These variables are defined in the parent POM file. If I replace all the ${} in the module pom file by their values then everything is fine. Basically when building the whole thing, the values of the variables are available to all the dependent modules as this is the same process. When you build an individual module the variables defined in the parent POM are not available.

Your own framework pom file contains a variable for the systempath of net.sf.javaml. Hardcode the variable or find another solution like a bill of material. https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html



回答5:

Remove repository folder inside .m2 and launch mvn clean install.

Keep us informed by the result and Good luck



回答6:

The the Framework artifact available in your local repository before running an install on the client project because there is no coupling between the two projects (the client artifact is not a module of your Framework project).

So to solve the issue you should run mvn install on your Framework project so the packaged jar is copied to your local repository. Then it is up to maven to discover and find it when you run some maven phase on the client project.

To have your artifacts shared among your organization you should deploy your artifacts (upload) to a nexus hosting mirror.



回答7:

I had the same issue. I am managing all the modules that were referenced by the project that i was trying to build. And the problem turned out that i had to do "mvn deploy" on all the parent projects of the module that was showing this error when using in another modules pom.xml. Here is the whole explanation http://programtalk.com/java/i-used-to-get-this-maven-error-all-time/



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!