0

I have a big group of projects and they depend on each others with pom.xml. I want to get the relationships of these dependencies among projects in a file by shell. mvn dependency:list is the key command, but the result is not satisfied.

https://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html

with the guide, i have use some parameters, but the result is not good enough

now the command is:

mvn dependency:list -DincludeGroupIds=group -DoutputFile=dependency.xml -DappendOutput=true

and the result in dependency.xml is:

group:project1:jar:0.0.1-SNAPSHOT:compile

group:project2:jar:0.0.1-SNAPSHOT:compile

……

I want to select the output of mvn dependency:list with the format like that:

project1

project2

……

Just no jar, SNAPSHOT or complie words, which are unneeded.

So, I want to konw, how can I get the result output to a file in this format?

Can I just get this result by adding the parameters with mvn dependency:list?

Although sed or awk is an option.

Cink Zhang
  • 11
  • 3
  • If a post-processing step is feasible for you. You might run `sed "s/\( *\)[^:]*:\([^:]*\):.*/\1\2/" dependencies.xml` (this prints to the console, only to show the principle). – SubOptimal Jul 26 '19 at 11:35
  • post-processing step, nice word! I have done this by sed. thx, man! – Cink Zhang Jul 27 '19 at 02:43

1 Answers1

1

OK.

before i can repeat the guide from maven dependency plugin, i choose to use sed.

a man give me a word "post-processing step", nice word.

and my solution is :

sed -i "s/group://g" dependency.xml
sed -i "s/:jar:0.0.1-SNAPSHOT:compile//g" dependency.xml
sed -i "s/^[ \t]*//g" dependency.xml
sed -i "s/[ \t]*$//g" dependency.xml
Cink Zhang
  • 11
  • 3