Scope in Maven Dependencies

Scope in Maven Dependencies

I am very sure a lot of times this question might have come to your mind, what exactly the scope is in our Pom.xml file why to use and what is the purpose of this. In this blog, I will try my best to answer these questions.

As per official maven documentation, Scope Tag in maven dependency is used to use to limit the transitivity of dependency or in simpler terms to define the scope or phase in which that dependency will actually work.

The <Scope> the element can take six values in our pom.xml file:

Ø  Compile 
Ø  Provided
Ø  Runtime
Ø  Test
Ø  System
Ø  Import



Now Let’s look into more details for all these six Scopes.

Compile

This is the maven default scope. This dependency is needed for the purpose of build, test and runs the project.
Compile dependencies are available in all classpaths of a project. These dependencies are also transferred to dependent projects.
For e.g, we need the JAR for compiling and running the web application

Provided

Provided is quite similar to compile and is used during build and test the project. This is also required to run, but should not be exported, because the dependency will be provided at the runtime by JDK or a container.

e.g We need JAR for compiling the project, but at run time there is already a JAR provided by the environment so we don't need it to packaged again with our web application.



RunTime

This dependency is not required for build or compilation, but is required to test and run our project.

Test

Test are not needed to build and run the project. They are needed to compile and run the unit tests.

System

This is similar to provided and the only difference is system dependencies are not retrieved from remote repository. They are present under some project’s subdirectory and are referenced from there.

For e.g some dependencies we might have created by our own and wanted to use it in our project.

Import

This scope is only supported on a dependency of type pom in the dependencyManagement section. Maven 2.0.9 or later replaces pom with dependencymanagement Section.





SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
August 4, 2020 at 8:51 AM

The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Projects for CSE.

Software management seeks for decision support to identify technologies like JavaScript that meet best the goals and characteristics of a software project or improvement programme. JavaScript Training in Chennai Accessible experiences and repositories that effectively guide that technology selection are still lacking.

Aim of technology domain analysis is to describe the class of context situations (e.g., kinds of JavaScript software projects) in which a software engineering technology JavaScript Training in Chennai can be applied successfully

The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

Reply
avatar