Exclude এবং Include করা Dependencies

Java Technologies - অ্যাপাচি আইভি (Apache IVY) Dependency Management |
134
134

Apache Ivy ডিপেনডেন্সি ম্যানেজমেন্ট টুল হিসেবে ব্যবহৃত হয় এবং এটি আপনাকে আপনার প্রোজেক্টের জন্য প্রয়োজনীয় লাইব্রেরি এবং ডিপেনডেন্সি গুলি রেজলভ করতে সহায়তা করে। Ivy-তে Exclude এবং Include কনফিগারেশন ব্যবহার করে আপনি নির্দিষ্ট ডিপেনডেন্সি বা তাদের নির্দিষ্ট ভার্সনগুলিকে অন্তর্ভুক্ত বা বহিষ্কার করতে পারেন।

এটি বিশেষভাবে দরকারি যখন আপনি একটি লাইব্রেরির উপর নির্ভরশীল থাকেন, কিন্তু কিছু নির্দিষ্ট ট্রান্সিটিভ ডিপেনডেন্সি (যেগুলি সেই লাইব্রেরি দ্বারা যুক্ত করা হয়েছে) আপনার প্রোজেক্টের জন্য উপযুক্ত নয়।


Exclude Dependencies in Ivy

Ivy-তে একটি নির্দিষ্ট ডিপেনডেন্সি বা ট্রান্সিটিভ ডিপেনডেন্সি exclude করতে, আপনি <exclude> ট্যাগ ব্যবহার করতে পারেন। এটি নির্দিষ্ট লাইব্রেরি থেকে অপ্রয়োজনীয় ডিপেনডেন্সি সরিয়ে ফেলতে সহায়তা করে।

Exclude Dependencies Example:

<ivy-module version="2.0">
    <info organisation="com.example" module="myproject" revision="1.0"/>
    <dependencies>
        <!-- Include spring-core dependency, but exclude commons-logging -->
        <dependency org="org.springframework" name="spring-core" rev="5.3.10">
            <exclude org="commons-logging" module="commons-logging"/>
        </dependency>
        
        <!-- Another example: Exclude log4j from commons-logging -->
        <dependency org="org.apache.commons" name="commons-logging" rev="1.2">
            <exclude org="log4j" module="log4j"/>
        </dependency>
    </dependencies>
</ivy-module>

এখানে:

  • <exclude org="commons-logging" module="commons-logging"/> ট্যাগটি spring-core লাইব্রেরি থেকে commons-logging লাইব্রেরিটি বাইরে রেখে দেয়।
  • <exclude org="log4j" module="log4j"/> ট্যাগটি commons-logging থেকে log4j লাইব্রেরি বহিষ্কার করবে।

When to Use Exclude:

  • যখন আপনি ট্রান্সিটিভ ডিপেনডেন্সি থেকে কিছু নির্দিষ্ট লাইব্রেরি বাদ দিতে চান, যা আপনার প্রোজেক্টে প্রভাব ফেলবে না বা আপনার জন্য অপ্রয়োজনীয়।
  • উদাহরণস্বরূপ, আপনি যদি একটি লাইব্রেরি ব্যবহার করেন যেটি একটি নির্দিষ্ট লগিং ফ্রেমওয়ার্ক (যেমন log4j) ব্যবহার করে, কিন্তু আপনার প্রকল্পে এটি ব্যবহার করার প্রয়োজন না থাকে, তবে আপনি এটি exclude করতে পারেন।

Include Dependencies in Ivy

<include> ট্যাগ ব্যবহার করে Ivy-তে আপনি কেবলমাত্র নির্দিষ্ট ডিপেনডেন্সি বা ট্রান্সিটিভ ডিপেনডেন্সি অন্তর্ভুক্ত করতে পারেন। এটি আপনাকে নির্দিষ্ট ডিপেনডেন্সি রেজলভ করতে এবং আপনার প্রকল্পে শুধুমাত্র সেই ডিপেনডেন্সি অন্তর্ভুক্ত করতে সহায়তা করে।

Include Dependencies Example:

<ivy-module version="2.0">
    <info organisation="com.example" module="myproject" revision="1.0"/>
    <dependencies>
        <!-- Include spring-core dependency and all transitive dependencies -->
        <dependency org="org.springframework" name="spring-core" rev="5.3.10">
            <include org="org.springframework" module="spring-beans"/>
        </dependency>
        
        <!-- Another example: Include commons-logging and log4j only -->
        <dependency org="org.apache.commons" name="commons-logging" rev="1.2">
            <include org="log4j" module="log4j"/>
        </dependency>
    </dependencies>
</ivy-module>

এখানে:

  • <include org="org.springframework" module="spring-beans"/>: এটি spring-core থেকে spring-beans ট্রান্সিটিভ ডিপেনডেন্সি অন্তর্ভুক্ত করবে।
  • <include org="log4j" module="log4j"/>: এটি commons-logging থেকে log4j অন্তর্ভুক্ত করবে।

When to Use Include:

  • যখন আপনি একটি ডিপেনডেন্সি ইনক্লুড করতে চান যা সাধারণত transitive হিসেবে অন্তর্ভুক্ত থাকে না, অথবা অন্য কোনো কনফিগারেশন/ভার্সন পলিসি অনুসারে বাদ পড়তে পারে।
  • উদাহরণস্বরূপ, আপনি যদি একটি লাইব্রেরি ব্যবহার করেন এবং চান যে নির্দিষ্ট ডিপেনডেন্সি (যেমন log4j) আপনার প্রোজেক্টে অন্তর্ভুক্ত থাকুক, তবে <include> ট্যাগ ব্যবহার করবেন।

Exclude এবং Include এর পার্থক্য

  1. Exclude:
    • এটি ডিপেনডেন্সি থেকে কিছু নির্দিষ্ট লাইব্রেরি বা মডিউল বাদ দিতে ব্যবহৃত হয়।
    • ট্রান্সিটিভ ডিপেনডেন্সি ম্যানেজমেন্টের মাধ্যমে আপনি যদি অপ্রয়োজনীয় লাইব্রেরি প্রোজেক্ট থেকে বাদ দিতে চান, তবে exclude ব্যবহার করবেন।
  2. Include:
    • এটি শুধুমাত্র নির্দিষ্ট লাইব্রেরি বা মডিউল অন্তর্ভুক্ত করতে ব্যবহৃত হয়।
    • include দিয়ে আপনি নির্দিষ্ট ট্রান্সিটিভ ডিপেনডেন্সি রেজলভ করতে পারেন এবং আপনার প্রোজেক্টে তা অন্তর্ভুক্ত করতে পারেন।

Combination of Include and Exclude

Ivy আপনাকে include এবং exclude একসাথে ব্যবহার করার অনুমতি দেয়। উদাহরণস্বরূপ, আপনি একটি লাইব্রেরি থেকে কিছু ট্রান্সিটিভ ডিপেনডেন্সি অন্তর্ভুক্ত করতে পারেন এবং কিছু অপ্রয়োজনীয় ডিপেনডেন্সি বাদ দিতে পারেন।

Include এবং Exclude একসাথে ব্যবহার করা:

<ivy-module version="2.0">
    <info organisation="com.example" module="myproject" revision="1.0"/>
    <dependencies>
        <!-- Include spring-core and exclude commons-logging -->
        <dependency org="org.springframework" name="spring-core" rev="5.3.10">
            <include org="org.springframework" module="spring-beans"/>
            <exclude org="commons-logging" module="commons-logging"/>
        </dependency>
    </dependencies>
</ivy-module>

এখানে:

  • <include> ট্যাগ ব্যবহার করে spring-beans ইনক্লুড করা হয়েছে।
  • <exclude> ট্যাগ ব্যবহার করে commons-logging এক্সক্লুড করা হয়েছে।

সারাংশ

Apache Ivy আপনাকে exclude এবং include ট্যাগ ব্যবহার করে ডিপেনডেন্সি ম্যানেজমেন্টে অনেক ফ্লেক্সিবিলিটি দেয়। আপনি যখন কোনো লাইব্রেরি বা ট্রান্সিটিভ ডিপেনডেন্সি আপনার প্রোজেক্টে অপ্রয়োজনীয় মনে করেন, তখন exclude ব্যবহার করতে পারেন, আর যখন আপনি কোনো নির্দিষ্ট ডিপেনডেন্সি রেজলভ করতে চান যা সাধারণত ডিফল্টরূপে অন্তর্ভুক্ত হয় না, তখন include ব্যবহার করতে পারেন। এটি ডিপেনডেন্সি ম্যানেজমেন্টকে আরও কাস্টমাইজেবল এবং কার্যকরী করে তোলে।

common.content_added_by
টপ রেটেড অ্যাপ

স্যাট অ্যাকাডেমী অ্যাপ

আমাদের অল-ইন-ওয়ান মোবাইল অ্যাপের মাধ্যমে সীমাহীন শেখার সুযোগ উপভোগ করুন।

ভিডিও
লাইভ ক্লাস
এক্সাম
ডাউনলোড করুন
Promotion