List of dependency jar files in Maven

后端 未结 9 2272
我在风中等你
我在风中等你 2020-12-04 09:50

Using Maven 2, is there a way I can list out the jar dependencies as just the file names?

mvn dependency:build-classpath 

can list the jar

9条回答
  •  半阙折子戏
    2020-12-04 10:17

    Here is an awk script to pipe mvn dependency:list:

    mvn dependency:list | awk -f mvnfmt.awk
    

    You can | sort if you want to sort by name, or | tr '\n' ':' to format it to a classpath.

    mvnfmt.awk is:

    BEGIN {
        found = 0
    }
    
    /The following files have been resolved/ {
        found = 1
        next
    }
    
    /^\[INFO\] \$/ {
        print "Empty " found
        if (found != 0) found = 0
    }
    
    {
        if (!found) next
        n = split($0, a, " ")
        if (n != 2) {
            found = 0
            next
        }
        split(a[2], a, ":")
        print a[2] "-" a[4] "." a[3]
    }   
    

提交回复
热议问题