Gradle Summit
Juggling multiple Java platforms and Jigsaw with Gradle - Cédric Champeau
2016

Who am I

speaker {
    name 'Cédric Champeau'
    company 'Gradle Inc'
    oss 'Apache Groovy committer',
    successes 'Static type checker',
                    'Static compilation',
                    'Traits',
                    'Markup template engine',
                    'DSLs'
        failures Stream.of(bugs),
        twitter '@CedricChampeau',
        github 'melix',
        extraDescription '''Groovy in Action 2 co-author
Misc OSS contribs (Gradle plugins, deck2pdf, jlangdetect, ...)'''
}

Disclaimer

  • Work in progress

  • Will be backported to current model

Project Jigsaw

  • Modularity for the Java platform

    • Reliable configuration (goodbye classpath)

    • Strong encapsulation (goodbye com.sun)

  • Enforce strict boundaries between modules

    • compile-time

    • run-time

Jigsaw modules

Declaring a module

module-info.java
module com.foo.bar {
    requires org.baz.qux;
    exports com.foo.bar.alpha;
    exports com.foo.bar.beta;
}

A module

  • Declares dependencies onto other modules

    • optionally transitive (public)

  • Declares a list of packages it exports

  • will be found on modulepath

Why it’s going to break your apps

  • Exports are package based

  • A non-exported package is not visible to consumers

  • 2 modules cannot export the same packages

  • 2 modules cannot have the same internal packages

Death to split packages.

How Gradle will help?

  • Find a smooth migration path

  • Prepare today, migrate when ready

Gradle’s software model

  • Idea : we’re building software, so let’s model software

  • Describe what rather than how

  • Leverage conventions

  • Work in progress

A simple project

Internal APIs

Internal APIs maintenance nightmare

Declaring internal APIs

Compile avoidance

Compile avoidance benefits

  • Doesn’t recompile dependents if:

    • method body changes

    • parameter names change

    • method order changes

    • private method added/removed

  • In short: if API stable, do nothing

Declaring target platforms

Why does Gradle help?

  • Add targetPlatform 'java9'

  • Generate module descriptor automatically?

  • Profit!

Trying it out

What’s next?

  • Backport to "old" model

  • Automatic toolchain selection

  • Support for modulepath

  • Support for jimage and jlink

  • Support for modulepath

  • Toolchain provisioning

Be involved

Gradle Inc

Motto: Build Happiness

Mission: To revolutionize the way software is built and shipped. We exist to end once-and-for-all the worst things about big software and restore the reason you got into coding in the first place.

We’re Hiring: Gradle is hiring front-end, back-end, and core software engineers. Visit gradle.org/jobs to apply.

Introducing Gradle Cloud Services

The first service, Gradle Build Scans, is now available.

  • Insights into your build

  • View and share via URL

  • Debug, optimize and refine

  • Analyze all of your builds

build scans

Stop by the Gradle Lounge and create a Build Scan!

Thank you!

Learn more at www.gradle.org