Gradle 4.0 released

New version of Gradle is now available
15 June 2017   998

Gradle 4.0. was recently announced by the Gradle Team.

Here is some great new features and improvements in this release:

First of all, Gradle's Build Cache is now production-ready for Java and Groovy compilation and Java test tasks! This provides great performance, making Gradle builds up to 100x faster than Maven in common cases. It is also improved by overlapping outputs detection, configurable classpath normalization that avoids unnecessary task execution, see more in the full release notes. The caching of other tasks, including even other languages, will be provided in future releases. Here is a guide from the developers for maximizing effectiveness of Gradle Build Cache.

Java

 Popular general-purpose programming language and computing platform

Now let's take a look from a user side: this version has a few improvements in logging and terminal display. Log output is now grouped by project and task when attached to a terminal — output from tasks run in parallel will no longer be interleaved. However, logging behaves the same way as previous Gradle versions in non-interactive environments, and use

 --console=plain

to allow automated tools like CI systems to parse the logs they expect.

Gradle
Gradle

The console output have more info about what exactly is in-progress at the moment, and parallel work in-progress is now displayed by default. Check this guide for more user's info.

Another interesting feature - metadata and artifacts from remote repositories are now downloaded in parallel. Gradle also avoids downloading the same dependency twice even if parallel tasks request the same one simultaneously.

Gradle in actionGradle in action

Also, good news for Kotlin coders - Gradle Script Kotlin v0.9.0 brings cool new features: auto-detection of Kotlin scripts, default import for the whole Gradle API, improved samples and docs with an API reference, better IntelliJ experience.

Kotlin

Statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code

Public type that represents lazily-evaluated properties(aka ConventionMapping) is also added to this release. This is one of the most expected features by plugin creators. You can have more info about PropertyStates here. Great example of it's usage can be found here.

Gradle is great solution which is frequently used in Android development. Version 4.0 brings great performance increase. Can't wait to use in real project!
 

Dmitry Karpunin
Chief Front-End Developer at Evrone

Upgrade Instructions

You can switch your version or Gradle to 4.0 fast by updating your wrapper properties:

./gradlew wrapper --gradle-version=4.0

Standalone download link.

Reporting Problems

Feel free to create issue on GitHub if you will find any bugs.

Source code download link.

How to convert list to map in Kotlin

Two ways to convert list to map in Kotlin, with code examples
31 October 2017   508

For example, you have a list of strings like:

val list = listOf("a", "b", "c", "d")

and you need to convert it to a map, where the strings are the keys.

There are two ways to do this:

The first and most performant is to use associateBy function that takes two lambdas for generating the key and value, and inlines the creation of the map:

val map = friends.associateBy({it.facebookId}, {it.points})

The second, less performant, is to use the standard map function to create a list of Pair which can be used by toMap to generate the final map:

val map = friends.map { it.facebookId to it.points }.toMap()