At the very bare minimum, maven cannot do much except paring xml files, tracking life cycle and using few plugins.
The true power of maven is realized when it makes use of plugin, which I will explain below.
A Maven Plugin is a collection of one or more goals. A jar plugin generates the jar file, compiler plugin will compile the code, surefire plugin will execute test cases and generate report.
Each plugin has number of goals associate to it. For example Compiler plugin has 2 goals:
compiler:compile is bound to the compile phase and is used to compile the main source files.
compiler:testCompile is bound to the test-compile phase and is used to compile the test source files
You can read more here: [https://maven.apache.org/plugins/maven-compiler-plugin/][1]
Now each goal is a unit of task that needs to be executed. For example compiler:compile, the compiler goal has compile plugin to compile the source code.
Now the Maven core that you download initially does not have much to do with the tasks related to your project like compiling, packaging, deplying etc. It delegates this work to Compiler plugin, Jar plugin respectively.
When you use these plugins for the first time, these will be downloaded from maven repository. This way it is easy to modularize the functionalities of different plugins and if there is any update in plugin, it will be downloaded automatically from the repository and you will get the most recent changes of plugin.
Maven Lifecycle
Maven has a build lifecycle. The build lifecycle is an ordered sequence of phases involved in building a project. Put it differently, if you are working on a project it goes through a cycle of compile, test, build, deploy etc.
Maven can support a number of different lifecycles (I did not have need to use any lifecycle, other than default Maven lifecycle), but the one that’s most often used is the default Maven lifecycle, which begins with a phase to validate the basic integrity of the project and ends with a phase that involves deploying a project to production
Life Cycle Image: https://ibb.co/Msmkyjd
Plugin goals can be attached to a lifecycle phase. As Maven moves through the phases in a lifecycle, it will execute the goals attached to each particular phase. Each phase may have zero or more goals bound to it.
Now the package phase is going to create a JAR file for a project with jar packaging. But what of the goals preceding it, such as compiler:compile and preceding package in the Maven lifecycle; executing a phase will first execute all proceeding phases in order, ending with the phase specified on the command line.
Maven walks through the default lifecycle and executes the following goals:
resources:resources
compiler:compile
resources:testResources
compiler:testCompile
surefire:test
jar:jar
Put it simply, when we executed mvn install, Maven executes all phases up to the install phase. Underneath it will make use of default lifecycle and and it executes all goals bound to each phase in the lifecycle.
You can also run the goal individually:
mvn resources:resources
compiler:compile
resources:testResources
compiler:testCompile
surefire:test
jar:jar
install:install
As you can see from this example, it is easy to execute lifecycle phases, then it is to specify explicit goals on the command line. Also by making use of common lifecycle (defaul lifecycle), the developers can switch between different projects without having to worry much about the underlying details of the project.
Hope this helps to clarify your concepts about goals, phases, life cycle, plugins etc.