1

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?

Leo Harmsen
  • 167
  • 3
  • 9

2 Answers2

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