Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of dependency jar files in Maven

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 files, but that will include the full path to their location in my local repository. What I need is essentially just a list of the file names (or the file names that the copy-dependencies goal copied).

So the list I need would be something like

activation-1.1.jar,antlr-2.7.6.jar,aopalliance-1.0.jar etc... 

ideally as a maven property, but I guess, a file such as build-classpath can generate will do.

What I am trying to achieve is writing a Bundle-ClassPath to an otherwise manually maintained MANIFEST.MF file for a OSGi bundle. (You shouldn't need to understand this bit to answer the question.)

To clarify: The question is not about how to write manifest headers into the MANIFEST.MF file in a jar (that is easily googleble). I am asking about how to get the data I want to write, namely the list shown above.

like image 934
Sindri Traustason Avatar asked Nov 10 '08 17:11

Sindri Traustason


People also ask

How do I find the dependencies of a jar file?

jar file. Use the -verbose:class option to find class-level dependencies or use the -v or -verbose option to include dependencies from the same JAR file. Use the -R or -recursive option to analyze the transitive dependencies of the com.

Where can I find dependencies in Maven?

In your project's POM, press Ctrl and hover the mouse over the dependency. Click the dependency to open the dependency's POM. In the dependency POM, view the active dependency, its transitive dependencies and their versions. You can check the origin from which the dependency was pulled in.

Which Maven command is to list all dependencies of a project hierarchically?

In Maven, you can use mvn dependency:tree to display the project dependencies in tree format.


1 Answers

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

$ mvn dependency:tree 

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

like image 118
Anis Avatar answered Oct 05 '22 19:10

Anis