المهام التزايدية وفحوصات حداثة النتائج
اجعل المهام المخصصة سريعة وصحيحة عبر التصريح بمدخلاتها ومخرجاتها، كي يتمكن Gradle من تخطي العمل المنجز والمحدّث بالفعل.
المهام التزايدية وفحوصات حداثة النتائج درس مجاني في Groovy & Gradle: JVM Automation and Build Engineering على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Groovy & Gradle: JVM Automation and Build Engineering، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Groovy & Gradle: JVM Automation and Build Engineering 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why Tasks Get Skipped
Gradle is fast because it does not redo work. If a task ran before and nothing it depends on changed, Gradle marks it UP-TO-DATE and skips it. You enable this by declaring inputs and outputs.
Inputs and Outputs
Every task can declare what it reads (inputs) and what it produces (outputs). Gradle hashes them to decide whether to run.
Declaring File Inputs
Annotate or register input files so Gradle watches them for changes.
tasks.register('process') {
inputs.file 'data/in.txt'
outputs.file 'build/out.txt'
}The Up-to-Date Decision
On each run Gradle compares current input/output hashes to the last run. If both match, the task is skipped; if any input changed, it re-runs.
Property Inputs
Non-file inputs (a flag, a version string) are declared with inputs.property so changing them also invalidates the cache.
tasks.register('gen') {
inputs.property 'version', project.version
outputs.dir 'build/gen'
}Custom Task Types
For reusable logic, write a task class with annotated properties: @InputFile, @OutputFile, @Input. Gradle reads the annotations automatically.
An Annotated Task Class
Annotations tell Gradle how to track each property without manual inputs/outputs wiring.
class Copy extends DefaultTask {
@InputFile File source
@OutputFile File dest
@TaskAction void run() { dest.text = source.text }
}Incremental Inputs
For tasks over many files, @Incremental inputs let the action process only the files that actually changed since last run.
The Build Cache
Beyond up-to-date checks, the build cache can reuse outputs from a previous run on any machine, keyed by the same input hashes — huge for CI.
org.gradle.caching=trueCommon Mistakes
Forgetting to declare an input is the classic bug: Gradle skips a task that should have re-run, producing stale output. Always declare every input that affects the result.
Forcing a Rerun
To verify caching or work around a stale state, run with --rerun-tasks to ignore up-to-date checks for one build, or use outputs.upToDateWhen { false } to mark a task as never up to date.
gradle build --rerun-tasksQuick Check
Test your incremental build knowledge.
Recap
You learned to build fast, correct tasks:
- Gradle skips tasks whose inputs and outputs are unchanged
- Declare files with
inputs.file/outputs.fileand values withinputs.property - Custom task classes use
@InputFile/@OutputFileannotations - The build cache reuses outputs across machines
- Undeclared inputs cause stale, incorrect skips
تعلم Groovy مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 12
- الدروس
- 48
الأسئلة الشائعة
هل درس «المهام التزايدية وفحوصات حداثة النتائج» مجاني؟
نعم — نص درس «المهام التزايدية وفحوصات حداثة النتائج» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Groovy & Gradle: JVM Automation and Build Engineering، انتقل إلى CoddyKit PRO. تتضمن دورة Groovy & Gradle: JVM Automation and Build Engineering 4 دروس في المجموع.
ماذا ستتعلم في «المهام التزايدية وفحوصات حداثة النتائج»؟
اجعل المهام المخصصة سريعة وصحيحة عبر التصريح بمدخلاتها ومخرجاتها، كي يتمكن Gradle من تخطي العمل المنجز والمحدّث بالفعل. تتمرن على Groovy & Gradle: JVM Automation and Build Engineering مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Groovy & Gradle: JVM Automation and Build Engineering؟
لا تُشترط خبرة سابقة. Groovy & Gradle: JVM Automation and Build Engineering على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «المهام التزايدية وفحوصات حداثة النتائج»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Groovy & Gradle: JVM Automation and Build Engineering هذا؟
نعم. كل درس في Groovy & Gradle: JVM Automation and Build Engineering يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- تعريف المهام المخصصة
- أنواع المهام وإجراءاتها
- خصائص المهام وإعدادها
- المهام التزايدية وفحوصات حداثة النتائج