gradle install is slower than maven install?

Viewed 265

I have big JAVA system (java 8) which includes more than 50 projects/modules. It was using maven install (Apache Maven 3.6.3). I migrate it to gradle install (version 6.5.1) as follows + manually add all maven transitive dependency to build.gradle of every module:

> gradle init

To compare the install performance, the following was executed for gradle install:

gradle install -x test --parallel

and for maven install:

 mvn clean install -T4C -DskipTests -U

To my surprise, maven is almost 2 times faster than gradle. Perhaps adding duplicate dependency on each project makes install expensive. But I can't skip adding them repeatedly. Do I do something wrong here? Or (gradle seems having promise of better performance). How can I improve the performance of gradle install? Thank you.

1 Answers

The Gradle task install is part of the deprecated Gradle Maven plugin (maven). You should use the modern Gradle Maven Publish plugin (maven-publish) and its task publishToMavenLocal.

Gradle is optimized for subsequent builds. It provides enhanced up-to-date checking which ensures that only the parts of your software are build that changed since the last build. It also uses a daemon process that runs in the background waiting for new builds to reduce the startup time of subsequent builds. This feature however increases the startup time of the first build, so it should be disabled whenever just one build should be run on a machine (e.g. in CI).

Related