m2e does not fully work with maven.config version revision property
Closed this issue · 10 comments
I'm trying to extract the static version from pom.xml to the maven.config file. The build works when executing mvn from bash but fails in m2e partly:
When I have all projects open in eclipse, dependent projects are correctly resolved. But when I close some projects, m2e fails to resolve these. I executed mvn install on root project before closing, so all artifacts are present in local repository. When dependent projects are closed, they are supposed to be resolved from local repository I suppose? But that seems to fails when using ${revision} in version tags.
this is my test setup
-parent
--subparent
---module-a (dep on module-b and transitivly on module-c)
--subparent2
---module-b (dep on module-c)
---module-c
When only module-a is open in eclipse, module-b is resolved, but module-c is not resolved. Am i missing something?
the build works when executing mvn from bash
How exactly you execute the build? e.g are your running inside module-c
directory?
i executed the build inside of parent directory with mvn install in bash.
in m2e everything is closed besides module-a
i executed the build inside of parent directory with mvn install in bash.
then this is like having all projects in your maven workspace open... the equivialent to your m2e setup would be running the build from parent/subparent/module-a
folder.
When i run right click module-a -> Run As -> Maven install
i get this error
BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.144 s
[INFO] Finished at: 2023-08-26T10:12:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project module-a: Could not resolve dependencies for project com.revision.test:module-a:jar:1.1.1-SNAPSHOT: Failed to collect dependencies at com.revision.test:module-b:jar:1.1.1-SNAPSHOT: Failed to read artifact descriptor for com.revision.test:module-b:jar:1.1.1-SNAPSHOT: Failure to find com.revision.test:subparent2:pom:${revision} in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
it tells me it cant read descriptor of module-b for what ever reason
it tells me it cant read descriptor of module-b for what ever reason
"it" is maven, so you will get the same result on the commandline ... and the reason is because Ci-Friendly Versions work "special" as you see with Failure to find com.revision.test:subparent2:pom:${revision}
while the installed item in your local repo is most likely com.revision.test:subparent2:pom:1.1.1-SNAPSHOT
Thanks for this information. Does that mean, i cant have everything closed in eclipse except the project that im currently working on? Because that is how I used to work always earlier, without Ci-Friendly Versions
I think you need to define <revision>
in your parent and then you can override it on the commandline, but as said you best try this out with regular maven from the specific folder.
Yes i tried mvn install from module-a it doesnt work, as you said.
i tried to define <revision>1.1.1-SNAPSHOT</revision>
in <properties>
in parent pom but that didnt fix the problem for me.
So is there a way to have everything closed except module-a and m2e is able to resolve all dependent artifacts transitivly? It's ok if not, then I will not use this maven.config revision stuff anymore
Ok i fixed it with flatten-maven-plugin. That way ${revision} is replcaed with project version in lokal maven repo. Now i can close all projects except the one that im working with