DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Trending

  • Microservices: Externalized Configuration
  • Optimizing Databricks Spark Pipelines Using Declarative Patterns
  • Design Patterns for GenAI Creative Systems in Advertising
  • A Comprehensive Guide to Prompt Engineering
  1. DZone
  2. Coding
  3. Tools
  4. Composite Builds With Gradle and IntelliJ IDEA

Composite Builds With Gradle and IntelliJ IDEA

One of the new features in IntelliJ IDEA 2017.1 is full support for Gradle Composite Builds. See what they are, how they work, and why you might want to use them.

By 
Trisha Gee user avatar
Trisha Gee
·
Mar. 21, 17 · Presentation
Likes (6)
Comment
Save
Tweet
Share
21.3K Views

Join the DZone community and get the full member experience.

Join For Free

One of the new features in IntelliJ IDEA 2017.1 is full support for Gradle Composite Builds. We were fortunate to have Stefan Oehme from Gradle presenting a webinar, showing what composite builds are, how they work and why you might want to use them. In the second part of the webinar, I (Trisha Gee) cover the support for Gradle composite builds in IntelliJ IDEA 2017.1. Take a look at the end of this post for the full video.

Support for composite builds was first introduced in IntelliJ IDEA 2016.3. With this, you had the ability to add additional Gradle builds to your project, and configure them as a dependency for your composite build.  You can see this functionality at the start of the section showing the IntelliJ IDEA features, but let’s take a quick refresher course in what Gradle Composite Builds are.

Imagine you have a project set up to be dependent upon some libraries:

Application dependent upon libraries

You may have access to the source code for this library, and even be able to make changes and commit them, but this traditionally required you to use a different IntelliJ IDEA project to make the changes, then build it and somehow deploy the updated library. But now with Gradle’s Composite Builds, you can easily update and test the library code. All you need to do is to change settings.gradle to include the location of the build for the library code.

Include build in settings.gradle

Now Gradle is using composite builds, i.e. it can build multiple independent projects together. IntelliJ IDEA recognizes this, and as you can see from the screenshot above, it not only updates the Gradle window to reflect the multiple builds, but imports the code for the included build as an additional IntelliJ IDEA module.

Stefan talked about the use cases that really benefit from using Gradle’s composite builds. Composite build support in IntelliJ IDEA means you can work very naturally with code from other libraries, modules, or plugins you may be dependent upon. You can make changes to the library code, and even commit these changes to the library’s own repository.

If your projects are already using composite builds, IntelliJ IDEA has full support for importing, building and running these projects.  The behavior inside the IDE is what you would expect, you get the included Gradle builds imported as IntelliJ IDEA modules.

For example, if you import a Gradle project that depends on included builds (like the one defined in the composite folder in this sample), the Gradle included builds will be identified and imported as IntelliJ IDEA modules, so you can work with all of the code that makes up the composite build, as if it were a single project.

Another use case for composite builds is to bundle together projects, possibly from different repositories, that are effectively separate modules that work together.  This use case may be particularly useful if your team is moving from a single repo “monolith” type of application to something that’s made up of independent modules or services. Gradle lets you include the builds for all the different modules (see the settings.gradle in this sample code for an example) into a composite build, and IntelliJ IDEA will find all those Gradle projects and treat them as IntelliJ IDEA modules.

The final example shown in the webinar is how valuable composite builds can be for Gradle plugin developers. Whether you’re developing a plugin and have an example project that uses the plugin to test it, or whether you’re working on an application that uses a plugin that you may want to experiment with, you can create a project from the “consumer” of the plugin (like in this sample code) and see the plugin code also imported as an IntelliJ IDEA module.

In summary, you’ll see that if you’re using composite builds with Gradle, IntelliJ IDEA will figure out the right project and module structure for you to be able to work naturally with the builds you’ve included, with the ability to see the code for the included projects, navigate to it, use refactoring and everything else works as if you were working with an ordinary IntelliJ IDEA module.

See the webinar in its full glory here.

intellij Build (game engine) Gradle

Published at DZone with permission of Trisha Gee. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Introduction to Tactical DDD With Java: Steps to Build Semantic Code
  • How to Build and Optimize AI Models for Real-World Applications
  • Part I: The Build You Can’t See Is the One That Will Kill You: Software Supply Chains, SBOMs, and the Long Reckoning After SolarWinds
  • Java Developers: Build Something Awesome with Copilot CLI and Win Big Prizes!

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook