When I build my maven Project I get a big jar of 300mb. It has to be under 75mb. Is there a way to not compile unused maven libraries/dependencies? Or is there a way to find out which libraries/dependencies my project doesnt need?
Asked
Active
Viewed 3,431 times
1
-
Provide the code snippet of pom.xml – Sambit May 08 '19 at 18:48
-
A single jar file which is about 300MiB ? How many classes do you have in that module? Are you creating a executable jar? – khmarbaise May 08 '19 at 19:02
2 Answers
1
https://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html is the plugin you are looking for. It will find used+undeclared (=transitive) dependencies and unused+declared dependencies. Just be aware that it cannot detect reflection.

Robert Scholte
- 11,889
- 2
- 35
- 44
1
Sounds like you need to include Skinny WAR option. Could you try the following POM in your project and let us know if that helped to reduce from 300MB to?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${war-plugin-version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>

Dorado
- 411
- 2
- 15