I'm trying to write a Windows batch script, that given a path, will search recursively through that directory looking for maven projects. When it has found all the maven project paths, I want to run some of the maven plugins against each of these projects.
My problems is this, I'm not sure of the best way to find the projects roots since I use inheritance in my poms e.g.
-/project
-pom.xml
-/module1
-pom.xml
-/module2
-pom.xml
Really I only want to find the path of /project in this instance and not of module1/2 e.g. where the parent pom is. At the moment I am searching for all pom.xml
and working out which is the parent by scanning for <packaging>pom</packaging>
in the xml file.
This works, but I can't help feeling that there are better methods of finding maven projects/parent poms.
Your strategy sounds good, but perhaps I can simplify your implementation. (tough for me to tell since you didn't show how you are currently doing it).
You could simply process the results of a recursive FINDSTR search with a FOR /F loop.
for /f "eol=: delims=" %%F in (
'findstr /mls "<packaging>pom</packaging>" "yourRootPath\pom.xml"'
) do echo %%~dpF