BT

Gradle Releases Version 4.7 with Support for Java 10

| by Michael Redlich Follow 11 Followers on May 31, 2018. Estimated reading time: 2 minutes |

Gradle, a comprehensive polyglot build tool, has released version 4.7 with new features such as:

  • Incremental annotation processing
  • Java 10 runtime support
  • Grouped non-interactive console logs
  • Re-run failed tests first for quicker feedback
  • Kotlin DSL 0.16, featuring new pre-compiled script plugins

We examine a few of these features here.

Incremental Annotation Processing

Gradle's incremental Java compiler, available since version 2.1, has been enhanced to include incremental processing of annotations. Gradle supports two types of annotation processors for incremental compilation: isolating where annotated elements evaluated in isolation, and aggregating where multiple annotated elements aggregated into one or more output files. All other types of annotation processors will trigger a full recompile of annotations.

The example below demonstrates how to add a Dagger annotation processor to a build.gradle file:

    
dependencies {
    // the Dagger compiler will only be found on the annotation class path
    annotationProcessor 'com.google.dagger:dagger-compiler:2.8'

    // the Dagger library is still required on the compile class path
    implementation 'com.google.dagger:dagger:2.8'
    }
    

Non-Interactive Console Logs

Gradle supports two console modes: plain used in IDEs or a CI build agents, and rich used on the command line. Prior to this release, the output from plain mode (as shown in the example below using Gradle 4.4 within IntelliJ IDEA) didn't have the same organized output from rich mode.

In this new release, both plain and rich modes produce the same output. As shown in the command line example below, log information produced by a Gradle task is now grouped together and headers are output preceded with > Task.

Kotlin DSL

Gradle now supports Gradle Kotlin DSL version 0.16.3 featuring precompiled Kotlin DSL scripts with support for Kotlin version 1.2.31 and Java 10, better integration with IntelliJ IDEA, and a more consistent API.

As defined in the release notes:

A precompiled script plugin is a Kotlin script compiled as part of a regular Kotlin source-set, meant to be consumed as a binary Gradle plugin whose identifier is automatically derived from its file name and optional package declaration.

The use of precompiled scripts is enabled in a build.gradle file:

    
plugins {
   'java-gradle-plugin'
   'kotlin-dsl'
   }

apply<org.gradle.kotlin.dsl.plugins.precompiled.PrecompiledScriptPlugins>()
    

Once enabled, scripts defined in src/main/kotlin is automatically exposed as a normal Gradle plugin. In the example below, a script defined as my-plugin.gradle.kts will be known to Gradle simply as my-plugin and may subsequently be used in the build.gradle file.

Languages supported by Gradle include:

  • Java
  • C++
  • Python ({py}gradle)
  • JavaScript
  • Clojure
  • Scala

Resources

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT