Understanding Gradle Tasks
<p>You may rarely deal with Gradle Tasks , and most of the time, new <code>Task</code>s are added either as a part of a plugin or as a copy-pasted piece of code from libraries’ “How to start” guide. Having no understanding of how Tasks work, their structure, and their lifecycle makes developers more likely to stay away from adding any changes to those tasks, even if there is room for improvement.</p>
<p>In this article, let’s try to understand<strong><em> </em></strong>what are Gradle Tasks, how they are created and used, and what forms can they take.</p>
<p>Basic things you should know about a <code>Task</code>:</p>
<ul>
<li>A <code>Task</code> is an executable piece of code that contains sequences of actions.</li>
<li>Actions are added to a <code>Task</code> via the <code>doFirst{}</code> and <code>doLast{}</code> closures.</li>
<li>A list of available tasks can be accessed by executing <code>./gradlew tasks</code>.</li>
</ul>
<p>To better understand the structure, syntax, and relationship between Gradle project entities, look at <a href="https://medium.com/@dmitriileonov/5-gradle-things-that-get-android-developers-confused-ed606b8e8c92" rel="noopener">my earlier article</a>.</p>
<p>Further in the article, given you are testing code in an Android project or any other project with Gradle wrapper in it, executing task X means running <code>./gradlew X</code> on Mac or <code>gradlew.bat X</code> on Windows.</p>
<h1>What Do Tasks Look Like?</h1>
<p>As you may already know, in Gradle, things come in many different forms, and Tasks are no exception. Task definition can be done in many different ways, most commonly in one like thi</p>
<p><a href="https://betterprogramming.pub/understanding-gradle-tasks-417d6f5e13f4">Visit Now</a></p>