swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Swagger-core Scala dependencies excessive size

Open raspacorp opened this issue 12 years ago • 8 comments

Before adding swagger tool my war file was 8.7 MB, after adding swagger now it is 39MB. My manager will complain about that, do you have a minified version or something?

It seems that the scala dependencies are the bigger ones: scala-compiler, scala-reflect, scala-library, jackson-module-scala.

I am using swagger-jersey2-jaxrs_2.10 via maven, as I am not using scala in my project should I exclude those jars? I don't know if that would break something.

raspacorp avatar Jul 17 '14 00:07 raspacorp

@raspacorp - swagger-core is written almost exclusively in scala (except for the annotations), so removing the scala dependencies will pretty much break everything.

Currently, there's not much you can do (unless you have several WAR files in which case you can install some dependencies on your application server directly). Actually, even if you have a single WAR, you can deploy these dependencies as part of your environment build-up rather than your WAR (depending on the way you work).

Future (major) versions of swagger-core may migrate completely to Java and remove the scala dependencies, however, no date can be given as to when.

webron avatar Jul 17 '14 09:07 webron

I was able to remove some dependencies and reduced almost 19MB of size, so far the api-docs is working fine, however I will keep testing. This is the dependency with the exclusions (scalap has transitive dependencies so when removed it also removes scala-compiler and scala-reflect):

    <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>

raspacorp avatar Jul 17 '14 17:07 raspacorp

Almost one month using it with removed dependencies and everything seems to work well, with a small API with 20 operations with GET, PUT, POST and DELETE methods. I will close the issue.

raspacorp avatar Aug 12 '14 15:08 raspacorp

Hi @raspacorp,

Please re-open this ticket. The library should be migrated to pure java – pulling in an entire Scala compiler etc is clearly excessive...

Thanks, Viktor

phraktle avatar Aug 20 '15 15:08 phraktle

@phraktle - the only scala dependencies are for testing. It has zero effect on the compiled output. No need to reopen it.

webron avatar Aug 20 '15 15:08 webron

Hi @webron,

Based on the dependency graph below, there are still scala dependencies in the released modules. Or am I using some outdated version?

Thanks, Viktor

+--- com.wordnik:swagger-jersey2-jaxrs_2.11:1.3.12
|    +--- com.wordnik:swagger-jaxrs_2.11:1.3.12
|    |    +--- org.scala-lang:scala-library:2.11.1
|    |    +--- com.wordnik:swagger-core_2.11:1.3.12
|    |    |    +--- org.slf4j:slf4j-api:1.6.3 -> 1.7.7
|    |    |    +--- com.fasterxml.jackson.module:jackson-module-scala_2.11:2.4.1
|    |    |    |    +--- org.scala-lang:scala-library:2.11.1
|    |    |    |    +--- org.scala-lang:scala-reflect:2.11.1
|    |    |    |    |    \--- org.scala-lang:scala-library:2.11.1
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.4.1 -> 2.6.1
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.4.1 -> 2.6.1
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-databind:2.4.1.1 -> 2.6.1 (*)
|    |    |    |    +--- com.thoughtworks.paranamer:paranamer:2.6
|    |    |    |    +--- com.google.code.findbugs:jsr305:2.0.1
|    |    |    |    \--- com.google.guava:guava:15.0 -> 18.0
|    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.4.1 -> 2.6.1
|    |    |    +--- com.fasterxml.jackson.module:jackson-module-jsonSchema:2.4.1
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.4.0 -> 2.6.1
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.4.1 -> 2.6.1
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.4.1 -> 2.6.1 (*)
|    |    |    +--- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.4.1 -> 2.5.4 (*)
|    |    |    +--- com.wordnik:swagger-annotations:1.3.12
|    |    |    +--- org.json4s:json4s-ext_2.11:3.2.11
|    |    |    |    +--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |    +--- joda-time:joda-time:2.3
|    |    |    |    \--- org.joda:joda-convert:1.6
|    |    |    +--- org.json4s:json4s-native_2.11:3.2.11
|    |    |    |    +--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |    \--- org.json4s:json4s-core_2.11:3.2.11
|    |    |    |         +--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |         +--- org.json4s:json4s-ast_2.11:3.2.11
|    |    |    |         |    \--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |         +--- com.thoughtworks.paranamer:paranamer:2.6
|    |    |    |         \--- org.scala-lang:scalap:2.11.0
|    |    |    |              \--- org.scala-lang:scala-compiler:2.11.0
|    |    |    |                   +--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |                   +--- org.scala-lang:scala-reflect:2.11.0 -> 2.11.1 (*)
|    |    |    |                   +--- org.scala-lang.modules:scala-xml_2.11:1.0.1
|    |    |    |                   |    \--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    |                   \--- org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1
|    |    |    |                        \--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |    \--- org.json4s:json4s-jackson_2.11:3.2.11
|    |    |         +--- org.scala-lang:scala-library:2.11.0 -> 2.11.1
|    |    |         +--- org.json4s:json4s-core_2.11:3.2.11 (*)
|    |    |         \--- com.fasterxml.jackson.core:jackson-databind:2.3.1 -> 2.6.1 (*)

phraktle avatar Aug 20 '15 15:08 phraktle

Yes, that's because it's version 1.3.12 which was written in scala, not Java.

The 1.5.x versions are the Java based ones.

webron avatar Aug 20 '15 15:08 webron

Thanks @webron! I have missed that update due to the artifact renaming.

phraktle avatar Aug 20 '15 15:08 phraktle