Top Ten Maven Plugins Every Coffee Developer Should Know
In the lastly duet of years, Maven has conk the de-facto create tool for Java applications. Though at that spot are challenges exists from tools similar Gradle, but I shout upward the authorization of Maven volition assist it to win the concluding battle. When I started alongside Maven, I was happy alongside exactly dependency management but too then I come upward to know nearly maven plugins which allow you lot customize your create upward to the degree you lot tin exercise alongside ANT. These plugins render truthful ability to Maven to automate most of the create related chore e.g. compilation, testing, packaging, deployment, too fifty-fifty committing the source code into the remote source repository. Many Java developers who purpose Maven daily are commonly non aware of these essential Maven plugins to a greater extent than oftentimes than non because Maven exactly works, or somebody has already done the difficult operate for them.
Maven uses conventions over configuration which agency fifty-fifty if you lot don't know much nearly Maven you lot tin purpose it to create your projection too create out dependency. In club to span that gap, I am going to portion 10 essential Maven plugins for Java developers. Knowing these plugins too what the exercise volition assist you lot to empathise how Maven industrial plant inwards full general too allow you lot ameliorate command your create process.
1. maven-compiler-plugin
This is the most of import maven plugin. You almost ever purpose it unknowingly. This plugin compiles your Java code from the criterion place Maven specifies e.g. /src/main/java too /src/main/resources. You tin customize the default conduct of maven-compiler-plugin past times specifying instructions inwards pom.xml file. For example, inwards next pom.xml file nosotros are telling maven-compiler-plugin to aspect Java seven source, too output Java seven specific classes.
2. maven-surefire-plugin
The Maven Surefire plugin is the default plugin for running unit tests. You tin also customize the conduct of this plugin past times specifying configuration inwards pom.xml. The Surefire Plugin has exclusively i goal: surefire:test runs the unit of measurement tests of an application.
3. maven-assembly-plugin
The Maven Assembly plugin is around other useful maven plugin which allows you lot to create your projection distribution inwards nada or tar format, suitable for deployment inwards Linux environment. We used to exercise this for our project, where tar file contains all config, binary too resources together. Though it's non a skillful sentiment to liberate binary too config together, sometimes it makes a lot of feel inwards smaller projects. Btw, all goals except assembly:single convey been deprecated of maven-assembly-plugin.
4. maven-jetty-plugin
The maven jetty plugin is pretty awesome for Java spider web developers equally it makes Java spider web application evolution much easier. In club to run your Servlet JSP based project, rather than packaging too creating a WAR file too deploying it into tomcat server, you lot tin merely run mvn jetty:run too your spider web application start. It uses embedded Jetty Servlet container to run your Java spider web application.
5. maven-dependency-plugin
The Maven Dependency Plugin is around other mandatory plugin to debug or empathise a POM too how you lot acquire around dependency (transitively). This plugin has several goals but around of the most useful are following:
dependency:analyze - analyzes the dependencies of this projection too determines which are: used too declared; used too undeclared; unused too declared.
dependency:tree - displays the dependency tree for this project
dependency:build-classpath tells Maven to output the path of the dependencies from the local repository inwards a classpath format to live used inwards java -cp. The classpath file may also live attached too installed/deployed along alongside the principal artifact.
6. maven-jar-plugin
This is the plugin which creates a Java Archive (JAR) file from the compiled projection classes too resources. You almost ever purpose this plugin to create JAR files. the latest version of this plugin is 3.0.1
7. maven-war-plugin
This plugin creates a Web Archive (WAR) file from the compiled projection classes, resources, too web.xml. You purpose this plugin spell edifice Java spider web application equally they are deployed into Servlet container similar Tomcat or corporation Server equally WAR file.
8. maven-deploy-plugin
This plugin is responsible for uploading the projection artifacts e.g. JAR, WAR, source code, Java docs etc to the internal remote repository. The electrical flow version of deploy plugin is 2.8.2 released inwards August 2014. See Maven Essentials to acquire to a greater extent than nearly fundamental maven concepts similar local too remote repository.
9. maven-resource-plugin
This Maven resources plugin is responsible for copying of Java projects resources to the output directory. There are 2 dissimilar kinds of resources inwards Maven projects: principal resources too testify resources. The divergence is that the principal resources are used past times the principal production code spell the testify resources are associated alongside the testify source code, which is exclusively used spell running unit test or integration tests.
10. spring-boot-maven-plugin
The Spring Boot maven plugin is i of the useful plugins to prepare Java spider web application using Spring Boot library. It collects all the jars on the classpath too builds a single, runnable "über-jar", which makes it to a greater extent than convenient to execute too carry your service. It also searches for the main() method to flag equally a runnable class, too most importantly it provides a built-in dependency resolver that sets the version number to jibe Spring Boot dependencies.
That's all nearly around of the essential Maven plugins for Java development. There are tens of Maven plugins but you lot don't purpose them always, these are the plugins which you lot are most probable to run across too purpose them inwards your twenty-four hours to twenty-four hours Java evolution work. Knowing a picayune chip to a greater extent than nearly these maven plugins volition non exclusively assist you lot to empathise your pom.xml file but also how things operate inwards Maven surroundings e.g. how your projection gets compiled or how unit of measurement tests are run inwards Maven create environment. This noesis also helps you lot to customize a detail stage of Maven lifecycle to arrange your projects need.
Further Learning
answer)How to growth heap size of Maven? (steps) How to cook Maven Eclipse Dependency search non working issue? (solution) How to install Maven inwards Windows 10? (steps) How to create a Java projection using ANT? (article) How to create or alteration build.xm inwards ANT? (tutorial)
Maven uses conventions over configuration which agency fifty-fifty if you lot don't know much nearly Maven you lot tin purpose it to create your projection too create out dependency. In club to span that gap, I am going to portion 10 essential Maven plugins for Java developers. Knowing these plugins too what the exercise volition assist you lot to empathise how Maven industrial plant inwards full general too allow you lot ameliorate command your create process.
10 Essential Maven Plugins for Java Developers
Here is my listing of useful too essential maven plugins every Java developer should live aware of. There is a skillful adventure that you lot mightiness live using many of them without knowing much nearly them, this article volition assist you lot to explore them better.1. maven-compiler-plugin
This is the most of import maven plugin. You almost ever purpose it unknowingly. This plugin compiles your Java code from the criterion place Maven specifies e.g. /src/main/java too /src/main/resources. You tin customize the default conduct of maven-compiler-plugin past times specifying instructions inwards pom.xml file. For example, inwards next pom.xml file nosotros are telling maven-compiler-plugin to aspect Java seven source, too output Java seven specific classes.
<build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>You tin also see Maven: The Definitive Guide to acquire to a greater extent than nearly this plugin.
2. maven-surefire-plugin
The Maven Surefire plugin is the default plugin for running unit tests. You tin also customize the conduct of this plugin past times specifying configuration inwards pom.xml. The Surefire Plugin has exclusively i goal: surefire:test runs the unit of measurement tests of an application.
3. maven-assembly-plugin
The Maven Assembly plugin is around other useful maven plugin which allows you lot to create your projection distribution inwards nada or tar format, suitable for deployment inwards Linux environment. We used to exercise this for our project, where tar file contains all config, binary too resources together. Though it's non a skillful sentiment to liberate binary too config together, sometimes it makes a lot of feel inwards smaller projects. Btw, all goals except assembly:single convey been deprecated of maven-assembly-plugin.
4. maven-jetty-plugin
The maven jetty plugin is pretty awesome for Java spider web developers equally it makes Java spider web application evolution much easier. In club to run your Servlet JSP based project, rather than packaging too creating a WAR file too deploying it into tomcat server, you lot tin merely run mvn jetty:run too your spider web application start. It uses embedded Jetty Servlet container to run your Java spider web application.
5. maven-dependency-plugin
The Maven Dependency Plugin is around other mandatory plugin to debug or empathise a POM too how you lot acquire around dependency (transitively). This plugin has several goals but around of the most useful are following:
dependency:analyze - analyzes the dependencies of this projection too determines which are: used too declared; used too undeclared; unused too declared.
dependency:tree - displays the dependency tree for this project
dependency:build-classpath tells Maven to output the path of the dependencies from the local repository inwards a classpath format to live used inwards java -cp. The classpath file may also live attached too installed/deployed along alongside the principal artifact.
6. maven-jar-plugin
This is the plugin which creates a Java Archive (JAR) file from the compiled projection classes too resources. You almost ever purpose this plugin to create JAR files. the latest version of this plugin is 3.0.1
7. maven-war-plugin
This plugin creates a Web Archive (WAR) file from the compiled projection classes, resources, too web.xml. You purpose this plugin spell edifice Java spider web application equally they are deployed into Servlet container similar Tomcat or corporation Server equally WAR file.
8. maven-deploy-plugin
This plugin is responsible for uploading the projection artifacts e.g. JAR, WAR, source code, Java docs etc to the internal remote repository. The electrical flow version of deploy plugin is 2.8.2 released inwards August 2014. See Maven Essentials to acquire to a greater extent than nearly fundamental maven concepts similar local too remote repository.
9. maven-resource-plugin
This Maven resources plugin is responsible for copying of Java projects resources to the output directory. There are 2 dissimilar kinds of resources inwards Maven projects: principal resources too testify resources. The divergence is that the principal resources are used past times the principal production code spell the testify resources are associated alongside the testify source code, which is exclusively used spell running unit test or integration tests.
10. spring-boot-maven-plugin
The Spring Boot maven plugin is i of the useful plugins to prepare Java spider web application using Spring Boot library. It collects all the jars on the classpath too builds a single, runnable "über-jar", which makes it to a greater extent than convenient to execute too carry your service. It also searches for the main() method to flag equally a runnable class, too most importantly it provides a built-in dependency resolver that sets the version number to jibe Spring Boot dependencies.
That's all nearly around of the essential Maven plugins for Java development. There are tens of Maven plugins but you lot don't purpose them always, these are the plugins which you lot are most probable to run across too purpose them inwards your twenty-four hours to twenty-four hours Java evolution work. Knowing a picayune chip to a greater extent than nearly these maven plugins volition non exclusively assist you lot to empathise your pom.xml file but also how things operate inwards Maven surroundings e.g. how your projection gets compiled or how unit of measurement tests are run inwards Maven create environment. This noesis also helps you lot to customize a detail stage of Maven lifecycle to arrange your projects need.
Further Learning
answer)
0 Response to "Top Ten Maven Plugins Every Coffee Developer Should Know"
Post a Comment