List of dependency jar files in Maven

后端 未结 9 2247
我在风中等你
我在风中等你 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]
    }   
    
    0 讨论(0)
  • 2020-12-04 10:19

    This command will generate the dependencies tree of your maven project:

    $ mvn dependency:tree
    

    I am sure that you will like the result :-)

    0 讨论(0)
  • 2020-12-04 10:20

    Maven can build the classpath in your manifest automatically: http://maven.apache.org/guides/mini/guide-manifest.html

    It's a configuration of the Maven archive plugin.

    0 讨论(0)
提交回复
热议问题