<commit_before><!--
  ~ Copyright 2013 the original author or authors.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<chapter id='incremental_tasks'>
    <title>Incremental Tasks</title>
    <note>
        <para>
            Incremental Tasks are an <firstterm>incubating</firstterm> feature (see <xref linkend="sec:incubating_state"/>).
        </para>
    </note>
    <para>
        With Gradle, it's very simple to implement a task that gets skipped when all of it's inputs and outputs are up to date (see <xref linkend="sec:up_to_date_checks"/>).
        However, there are times when only a few input files have changed since the last execution, and you'd like to avoid reprocessing all of the unchanged inputs.
        This can be particularly useful for a transformer task, that converts input files to output files on a 1:1 basis.
    </para>
    <para>
        If you'd like to optimise your build so that only out-of-date inputs are processed, you can do so with an <firstterm>incremental task</firstterm>.
    </para>
    <section>
        <title>Implementing an incremental task</title>
        <para>
            For a task to process inputs incrementally, that task must contain an <firstterm>incremental task action</firstterm>. This is a task action method that contains a
            single <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs"/> parameter, which indicates to Gradle that the action will process the changed inputs only.
        </para>
        <para>
            The incremental task action may supply an <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="outOfDate"/> action for processing any input file that is out-of-date,
            and a <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="removed"/> action that executes for any input file that has been removed since the previous execution.
        </para>
        <sample id="taskDefinition" dir="userguide/tasks/incrementalTask" title="Defining an incremental task action" includeLocation="true">
            <sourcefile file="build.gradle" snippet="incremental-task" />
        </sample>
        <para>
            For a simple transformer task like this, the task action simply needs to generate output files for any out-of-date inputs,
            and delete output files for any removed inputs.
        </para>
        <para>
            A task may only contain a single incremental task action.
        </para>
    </section>
    <section>
        <title>Which inputs are considered out of date?</title>
        <para>
            When Gradle has history of a previous task execution, and the only changes to the task execution context since that execution are to input files,
            then Gradle is able to determine which input files need to be reprocessed by the task.
            In this case, the <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="outOfDate"/> action will be executed any input file that was <emphasis>added</emphasis> or <emphasis>modified</emphasis>,
            and the <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="removed"/> action will be executed for any <emphasis>removed</emphasis> input file.
        </para>
        <para><commit_msg>Fixed one minor typo.<commit_after><!--
  ~ Copyright 2013 the original author or authors.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<chapter id='incremental_tasks'>
    <title>Incremental Tasks</title>
    <note>
        <para>
            Incremental Tasks are an <firstterm>incubating</firstterm> feature (see <xref linkend="sec:incubating_state"/>).
        </para>
    </note>
    <para>
        With Gradle, it's very simple to implement a task that gets skipped when all of it's inputs and outputs are up to date (see <xref linkend="sec:up_to_date_checks"/>).
        However, there are times when only a few input files have changed since the last execution, and you'd like to avoid reprocessing all of the unchanged inputs.
        This can be particularly useful for a transformer task, that converts input files to output files on a 1:1 basis.
    </para>
    <para>
        If you'd like to optimise your build so that only out-of-date inputs are processed, you can do so with an <firstterm>incremental task</firstterm>.
    </para>
    <section>
        <title>Implementing an incremental task</title>
        <para>
            For a task to process inputs incrementally, that task must contain an <firstterm>incremental task action</firstterm>. This is a task action method that contains a
            single <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs"/> parameter, which indicates to Gradle that the action will process the changed inputs only.
        </para>
        <para>
            The incremental task action may supply an <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="outOfDate"/> action for processing any input file that is out-of-date,
            and a <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="removed"/> action that executes for any input file that has been removed since the previous execution.
        </para>
        <sample id="taskDefinition" dir="userguide/tasks/incrementalTask" title="Defining an incremental task action" includeLocation="true">
            <sourcefile file="build.gradle" snippet="incremental-task" />
        </sample>
        <para>
            For a simple transformer task like this, the task action simply needs to generate output files for any out-of-date inputs,
            and delete output files for any removed inputs.
        </para>
        <para>
            A task may only contain a single incremental task action.
        </para>
    </section>
    <section>
        <title>Which inputs are considered out of date?</title>
        <para>
            When Gradle has history of a previous task execution, and the only changes to the task execution context since that execution are to input files,
            then Gradle is able to determine which input files need to be reprocessed by the task.
            In this case, the <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="outOfDate"/> action will be executed for any input file that was <emphasis>added</emphasis> or <emphasis>modified</emphasis>,
            and the <apilink class="org.gradle.api.tasks.incremental.IncrementalTaskInputs" method="removed"/> action will be executed for any <emphasis>removed</emphasis> input file.
        </para>
        <para>
{'fraction_non_alphanumeric': 0.07941252924356641, 'fraction_numerical': 0.0025994281258123215, 'mean_word_length': 3.10181236673774, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4552099', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1934, 'n_words': 867}