Gradle 5.0 - what's new

    In the process of developing CUBA, we used all three basic build tools - we started with Ant, then switched to Maven for a short time, and now we use Gradle and it looks like we’ll stay with him soon.


    Not so long ago, Gradle 5.0 was released. This version has a large number of new features that will help developers write more complex scripts and build their projects even faster and more painless.


    image


    Kotlin dsl


    The first innovation - Kotlin DSL . Now you can write build scripts in Kotlin, and this really speeds up work due to auto-completion, basically. Syntax error highlighting and other convenient things from IDEA also work. Of course, IDEA and for Groovy tries to do all this, but still strong typing makes itself felt. It is stated that Kotlin DSL is stable, so that you can use it fearlessly.


    Do I have to go to Kotlin? No, you do not need it, Groovy DSL will be supported, it is not abandoned. Then you need to consider each project separately. To use Kotlin DSL - you need Gradle 5 and JDK at least 8, for some cases it may not be applicable. In addition, Groovy provides greater flexibility in writing scripts due to lax typing. In any case, the decision remains with the developers, but if you still decide to switch to Kotlin, that is , the migration guide .


    Interactive init


    Now, finally, you can not write a bunch of keys during the initial assembly of the project, but choose the type of project, the language of the build script, and even the framework for testing in interactive mode. We write gradle init - and enjoy. Supports project generation on Kotlin!


    Incremental compilation and annotation processing


    The incremental compilation mechanism continues to evolve (including the processing of annotations of Lombok type libraries) - no need to recompile all the code. You can create your own tasks that support incremental compilation.


    Accelerated build processes due to the build cache, optimized work with memory.


    FailFast Testing - the tests will run starting from the last erroneous (if it was, of course).


    Dependency management


    Support BOM files - hooray!


    Tweaking the rules for replacing versions is declared; you can write program code to handle particularly complex cases directly in the assembly file . In the same place - shutdown of transitive dependences.


    You can forcibly install a dependency version and prohibit overlapping it with older versions.


    And, in addition to everything, “freezing” of versions is supported for dependencies.


    New API for tasks


    The process of improvement in the area of ​​creating tasks continues. There are a few new things here that will surely come in handy for many.


    Worker API that allows you to run tasks in parallel and with different levels of isolation (even on different JVMs possible). In addition to just parallel execution, you can make wait for the completion of other tasks.


    Timeout API - for setting the maximum execution time of the task.


    Configuration Avoidance API - allows you not to create or configure tasks that still will not be executed.


    Summing up - a good tool gets even better, for kotlin - a special thank you, now you can write everything on it: front-end, back-end, mobile client and build scripts.


    Also popular now: