Maven - Detect Multiple Versions of the Same Dependency

后端 未结 6 1111
眼角桃花
眼角桃花 2021-02-01 06:19

I just experienced a case of two direct dependencies of my maven project having two different versions of a particular transitive dependency.

In my particular case I had

6条回答
  •  攒了一身酷
    2021-02-01 07:14

    @Vitaly

    my quickly hand-made command line to detect multiple versions of the same dependency :

    mvn dependency:tree | grep ":compile" | sed 's/.* \(.*\):compile/\1/' | sort -u | cut -d ':' -f '1 2' | uniq -c | grep -vE "^ *1"
    

    then, we can use the following command line to get used versions of theses dependencies (it isn't an optimized command line ;) : 

    for dep in $(mvn dependency:tree | grep ":compile" | sed 's/.* \(.*\):compile/\1/' | sort -u | cut -d ':' -f '1 2' | uniq -c | grep -vE "^ *1" | cut -d ' ' -f 8); 
    do 
      echo $dep; 
      mvn dependency:tree | grep $dep; 
      echo 
    done
    

提交回复
热议问题