Marty Pitt
Marty Pitt

Reputation: 29280

Determining which jars a project actually requires

I've inherited a project (non-mavenized) which has a lib folder with approx 45 .jar's within it.

I'm fairly certain that not all of those jars are required.

Is there a way I can determine from the source of the project which jar's really are required, and which are adding no value, and are safe to remove?

Ideally I'd like to identify the "direct" dependencies, (ie., non-transitive) so I can extract these to a pom.

Upvotes: 2

Views: 123

Answers (4)

GKelly
GKelly

Reputation: 3919

Just create the POM with direct dependencies on ALL the included JARs, then run mvn dependency:analyze.

This should report those dependencies that are not directly accessed by your source. Then remove those ones.

Upvotes: 2

kiran.kumar M
kiran.kumar M

Reputation: 801

Check this lovely project

http://www.jboss.org/tattletale

Upvotes: 4

onemanandhishat
onemanandhishat

Reputation: 43

You could try setting it up as a project in an IDE like Eclipse without importing the jars and then as the IDE flags up all the compiler errors, import the relevant jar.

You should be left with the unnecessary ones unimported.

That might be a bit of a long-winded approach though, I'm afraid I don't know enough to say if there's a better way.

Upvotes: 0

Thomas
Thomas

Reputation: 88707

You might try and remove the jars (from the build path), then make a clean install and see whether the project compiles. If so, the removed jars should not be direct dependencies.

Upvotes: 0

Related Questions