Maven
Maven
Ant Maven
Ant doesn’t have formal conventions, so we Maven has a convention to place source
need to provide information about the code, compiled code, etc. So we don’t need
project structure in the build.xml file. to provide information about the project
structure in pom.xml file.
Ant is procedural, you need to provide Maven is declarative, everything you define
information about what to do and when to in the pom.xml file.
do through code. You need to provide
order.
There is no life cycle in Ant. There is a life cycle in Maven.
Ant is a toolbox. Maven is a framework.
It is mainly a build tool. It is mainly a project management tool.
The ant scripts are not reusable. The maven plugins are reusable.
It is less preferred than Maven. It is more preferred than Ant.
NOTE: This is a common Maven Interview Question that you must know.
2. What is Maven?
7. What does it mean when you say Maven uses Convention over Configuration?
o In the case of Configuration, developers have to create the build processes
manually and they have to specify each and every configuration in detail. But,
Maven uses convention where the developers need not create the build
processes manually.
o Also, for convention, users do not need to specify the configuration in detail.
Once a developer creates a project in Maven then Maven will automatically
create a structure. Developers just have to place the files appropriately.
There is no need to specify any configuration details in pom.xml file.
NOTE: This is an important Maven Interview Question that you must know.
project dependencies
plugins
goals
build profiles
project version
developers
mailing list
19. What would the command mvn clean dependency:copy-dependencies package do?
This command will clean the project, copy the dependencies and package the project
(executing all phases up to package).
DevOps Training
DEVOPS CERTIFICATION TRAINING
DevOps Certification Training
Reviews
5(57889)
5(1893)
DOCKER TRAINING AND CERTIFICATION
Docker Training and Certification
Reviews
5(4184)
5(7018)
5(2731)
5(4018)
Next
27. Can you tell me the default location of your local repository?
~/m2./repository.
29. Is there a particular sequence in which Maven searches for dependency libraries?
Following is the search pattern –
Search for dependency in the local repository, if not found, move to step 2 else do
the further processing.
Search for dependency in the central repository first, if not found and the remote
repository is mentioned then move to step 4 else it is downloaded to the local
repository for future reference.
If a remote repository has not been mentioned, Maven simply stops the processing
and throws an error (Unable to find dependency).
Search for dependency in the remote repository first, if found it is downloaded to
the local repository for future reference otherwise Maven is expected to stop
processing and throws an error.
33. What are the things that you must define for each external dependency?
External dependencies (library jar location) can be configured in pom.xml in same way as
other dependencies are configured.
40. How Maven handles and determines what version of dependency will be used
when multiple versions of an artifact are found?
If you find two dependency versions at the same depth in the dependency tree, then you
use the first declared dependency. This is nothing but dependency mediation.
41. What is the dependency scope? Name all the dependency scope.
Dependency scope typically includes dependencies as per the current stage of the build. The
various Dependency scopes are −
compile − This scope indicates that dependency is available in the classpath of the project. It
is the default scope.
provided − This indicates that the dependency is to be provided by JDK or
web-Server/Container at runtime.
runtime − This scope tells that you dont need dependency is for compilation but you need it
for for execution.
test − This scope states that the dependency is only available for the test compilation and
execution phases.
system − This scope indicates that you must provide the system path.
import − This scope is only used when the dependency is of type pom. This scope tells that
the specified POM should be replaced with the dependencies in the POM’s
<dependencyManagement> section.
42. What is the minimal set of information for matching dependency reference against
a dependencyManagement section?
{groupId,artifactId,type,classifier}.
47. If you fail to define any information, where does your pom inherits that
information from?
All POMs are inherited from a parent despite explicitly defined or not. This base POM is
called Super POM and it contains values that are inherited by default.
49. What are the elements in POM that a profile can freely modify when specified in
the POM?
<repositories>, <pluginRepositories>,<dependencies>, <plugins> ,<properties>,
<modules><reporting>,<dependencyManagement>,<distributionManagement>
50. What are the benefit of storing JARS/external dependencies in the local repository
instead of a remote one?
It uses less storage and also makes checking out a project quicker, without the need for
versioning the JAR files.
54. How to run the clean plugin automatically during the build?
For this, you just need to place the clean plugin inside the execution tag in pom.xml file.
55. What is the meaning of the message “You cannot have two plugin executions with
the same or missing elements”?
It simply means that you have executed a plugin multiple times with the same <id>. To
correct this you just need to provide each <execution> with a unique <id>.