DZone
Java Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Gradle Goodness: Run Tasks Ignoring Up-to-Date Checks [Code Snippet]

Gradle Goodness: Run Tasks Ignoring Up-to-Date Checks [Code Snippet]

You can use Gradle for builds for incremental tasks, building only when things change. This quick code snippet introduces the assemble and rerun task commands

Hubert Klein Ikkink user avatar by
Hubert Klein Ikkink
·
Dec. 27, 16 · Java Zone · Tutorial
Like (2)
Save
Tweet
7.97K Views

Join the DZone community and get the full member experience.

Join For Free

Gradle builds are fast because Gradle supports incremental tasks. This means Gradle can determine if input or output of tasks has changed — before running the task. If nothing has changed, a task is marked as up-to-date and the task is not executed. Otherwise, the task is executed. If we want to execute a task even if it is up-to-date we must use the command line option --rerun-tasks.

In the following example, we run the assemble task for a simple Java project, and we see all tasks are executed. When we invoke the assemble task again we see the tasks are all up-to-date:

$ gradle assemble :compileJava :processResources :classes :jar :assemble 
BUILD SUCCESSFUL Total time: 1.765 secs 
$ gradle assemble 
:compileJava UP-TO-DATE 
:processResources UP-TO-DATE 
:classes UP-TO-DATE 
:jar UP-TO-DATE 
:assemble UP-TO-DATE BUILD SUCCESSFUL 
Total time: 0.715 secs 
$ 

To run all tasks without an up-to-date check we use the option --rerun-tasks:

Written with Gradle 3.2.1.

Task (computing) Gradle Snippet (programming)

Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Submit a Post to DZone
  • 12 Modern CSS Techniques For Older CSS Problems
  • 10 Programming Habits a Web Developer Should Embrace
  • Is NoOps the End of DevOps?

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo