Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do I need the maven-compiler-plugin?

Tags:

maven

I understand that the maven-compiler plugin is used to compile the code. Some of my project does not have that plugin in the pom file? When is it required?

like image 729
Devs love ZenUML Avatar asked Sep 15 '15 12:09

Devs love ZenUML


People also ask

Is Maven compiler plugin necessary?

Maven Compiler Plugin might be the most important plugin in Maven. It is used to compile the sources of your project, which transform Java files ( *. java ) into class files ( *.

What is the use of compiler plugin?

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax. tools. JavaCompiler (if you are using java 1.6) and is used to compile Java sources.

Why do we need Maven plugin?

"Maven" is really just a core framework for a collection of Maven Plugins. In other words, plugins are where much of the real action is performed, plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on.


2 Answers

I am trying to answer my own question based on what I learned since posted this question. If this answer is correct or incorrect please comment. Thanks.

If this plugin is not defined, the Maven Super POM contains all the default plugins you will be using. It works fine for small and non-serious projects. However, the best practice is to define these plugins in a company-wise POM and so that when you upgrade maven, you would not end up using a different version of plugin.

like image 189
Devs love ZenUML Avatar answered Sep 30 '22 04:09

Devs love ZenUML


Have a look at the Goals Overview Section in Apache Maven Compiler Plugin

The Compiler Plugin has two goals. Both are already bound to their proper phases within the Maven Lifecycle and are therefore, automatically executed during their respective phases.

You only have to add it if you want to change the default parameters

like image 39
Abaddon666 Avatar answered Sep 30 '22 04:09

Abaddon666