Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger-core Scala dependencies excessive size

I found that after I started using swagger documentation tool for my REST API, the size of my war file increased almost 4.5 times, from 8.7 MB to 39MB. I am using Maven to build the project.

That is because of the Swagger Scala dependencies big size, specially scala-compiler. So I was trying to find out which of those dependencies are not really needed. I created a new issue in the project's Github page: https://github.com/wordnik/swagger-core/issues/624 They answered that it is not a good idea to remove any scala dependency as the framework is written in that language and that could break it. Also recommended as a workaround to put the dependencies in the container/server instead of inside the war.

like image 255
raspacorp Avatar asked Aug 12 '14 16:08

raspacorp


1 Answers

After doing some trial and error work, I found that it is possible to remove some dependencies without breaking it. So far after almost one month of use, the documentation tool seems to work properly. These are the dependencies I removed:

    <dependency>
        <groupId>com.wordnik</groupId>
        <artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
        <version>${swagger-jersey.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>jackson-module-scala_2.10</artifactId>
                <groupId>com.fasterxml.jackson.module</groupId>
            </exclusion>
            <exclusion>
                <artifactId>scalap</artifactId>
                <groupId>org.scala-lang</groupId>
            </exclusion>
        </exclusions>
    </dependency>

This removes basically three big jars: scalap, scala-compiler and scala-reflect. Which means almost 19 MB of reduced size.

I am not saying that you should not follow the advice of the developers from the Swagger team about not removing scala dependencies, but so far this has worked for me and wanted to share it. I made my comments and closed the issue in Github as well: https://github.com/wordnik/swagger-core/issues/624

like image 130
raspacorp Avatar answered Sep 23 '22 06:09

raspacorp