حل تعارضات الإصدارات وقيود التبعيات
شخّص تعارضات إصدارات التبعيات وأصلحها باستخدام تقرير التبعيات واستراتيجيات الحل والقيود والإصدارات المفروضة.
حل تعارضات الإصدارات وقيود التبعيات درس مجاني في 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 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Conflict Problem
Two libraries you depend on may each pull in a different version of the same transitive dependency. Gradle must pick one — and the wrong choice causes runtime errors. Managing this is a core skill.
Default: Newest Wins
By default Gradle resolves a conflict by choosing the highest requested version of a dependency across the graph. Usually safe, but not always.
Seeing the Dependency Tree
The dependencies task prints the full resolved graph, showing which version won and why.
gradle dependencies --configuration runtimeClasspathExplaining a Single Dependency
The dependencyInsight task explains exactly how one dependency was resolved and who requested each version.
gradle dependencyInsight --dependency guavaForcing a Version
You can force a specific version, overriding the conflict resolution, with a resolution strategy.
configurations.all {
resolutionStrategy {
force 'com.google.guava:guava:32.1.3-jre'
}
}Dependency Constraints
The modern approach uses constraints to declare an allowed version without adding the dependency directly — cleaner than force.
dependencies {
constraints {
implementation 'com.google.guava:guava:32.1.3-jre'
}
}Excluding Transitives
Sometimes a transitive dependency is unwanted entirely. Exclude it from the bringing dependency.
implementation('org.example:lib:1.0') {
exclude group: 'commons-logging'
}Rejecting Bad Versions
A resolution strategy can reject known-broken versions so Gradle never selects them.
resolutionStrategy {
componentSelection {
all { if (candidate.version == '1.2.0') reject('known bug') }
}
}Failing on Conflict
For strict reproducibility, tell Gradle to fail the build whenever a version conflict occurs, forcing you to resolve it explicitly.
resolutionStrategy { failOnVersionConflict() }Locking Dependencies
Dependency locking writes resolved versions to a lockfile so builds are fully reproducible across machines and time.
gradle dependencies --write-locksPlatforms and BOMs
Import a published BOM with the platform notation to align many related dependencies on one tested version set, avoiding manual version juggling.
dependencies {
implementation platform('org.springframework.boot:spring-boot-dependencies:3.2.0')
implementation 'org.springframework.boot:spring-boot-starter-web'
}Quick Check
Test your conflict resolution knowledge.
Recap
You learned to manage version conflicts:
- Default resolution picks the highest version
- Inspect with
dependenciesanddependencyInsight - Override with
forceor, preferably,constraints excluderemoves unwanted transitives; reject blocks bad versions- Dependency locking makes builds reproducible
تعلم Groovy مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 12
- الدروس
- 48
الأسئلة الشائعة
هل درس «حل تعارضات الإصدارات وقيود التبعيات» مجاني؟
نعم — نص درس «حل تعارضات الإصدارات وقيود التبعيات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Groovy & Gradle: JVM Automation and Build Engineering، انتقل إلى CoddyKit PRO. تتضمن دورة Groovy & Gradle: JVM Automation and Build Engineering 4 دروس في المجموع.
ماذا ستتعلم في «حل تعارضات الإصدارات وقيود التبعيات»؟
شخّص تعارضات إصدارات التبعيات وأصلحها باستخدام تقرير التبعيات واستراتيجيات الحل والقيود والإصدارات المفروضة. تتمرن على 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- التصريح بتبعيات المشروع
- حل التبعيات والتخزين المؤقت
- المستودعات المخصصة وBOMs
- حل تعارضات الإصدارات وقيود التبعيات