What does maven do




















Once you familiarize yourself with one Maven project, you know how all Maven projects build. This saves time when navigating many projects. For example, Maven can provide:. Third party code analysis products also provide Maven plugins that add their reports to the standard information given by Maven. Maven aims to gather current principles for best practices development and make it easy to guide a project in that direction.

For example, specification, execution, and reporting of unit tests are part of the normal build cycle using Maven. Current unit testing best practices were used as guidelines:. Once you learn the layout, you can easily navigate other projects that use Maven.

The prefix archetype is the plugin that provides the goal. If you are familiar with Ant , you may conceive of this as similar to a task. This archetype:generate goal created a simple project based upon a maven-archetype-quickstart archetype. Suffice it to say for now that a plugin is a collection of goals with a general common purpose. For example the jboss-maven-plugin, whose purpose is "deal with various jboss items". Unlike the first command executed archetype:generate , the second is simply a single word - package.

Rather than a goal , this is a phase. A phase is a step in the build lifecycle , which is an ordered sequence of phases. When a phase is given, Maven executes every phase in the sequence up to and including the one defined.

For example, if you execute the compile phase, the phases that actually get executed are:. By default your version of Maven might use an old version of the maven-compiler-plugin that is not compatible with Java 9 or later versions. To target Java 9 or later, you should at least use version 3. In the following example, we have configured our Maven project to use version 3.

To learn more about javac 's --release option, see JEP Although hardly a comprehensive list, these are the most common default lifecycle phases executed. Phases are actually mapped to underlying goals. The specific goals executed per phase is dependant upon the packaging type of the project. For example, package executes jar:jar if the project type is a JAR, and war:war if the project type is - you guessed it - a WAR.

Now, whenever a Maven command processes com. Furthermore, some commands goals specifically handle project aggregation differently. If you have several Maven projects, and they all have similar configurations, you can refactor your projects by pulling out those similar configurations and making a parent project.

Thus, all you have to do is to let your Maven projects inherit that parent project, and those configurations would then be applied to all of them. And if you have a group of projects that are built or processed together, you can create a parent project and have that parent project declare those projects as its modules. By doing so, you'd only have to build the parent and the rest will follow. But of course, you can have both Project Inheritance and Project Aggregation. Meaning, you can have your modules specify a parent project, and at the same time, have that parent project specify those Maven projects as its modules.

You'd just have to apply all three rules:. One of the practices that Maven encourages is don't repeat yourself. However, there are circumstances where you will need to use the same value in several different locations. To assist in ensuring the value is only specified once, Maven allows you to use both your own and pre-defined variables in the POM. For example, to access the project. One factor to note is that these variables are processed after inheritance as outlined above.

This means that if a parent project uses a variable, then its definition in the child, not the parent, will be the one eventually used. Any field of the model that is a single value element can be referenced as a variable.

Refer to the POM reference to see a full list of properties. These variables are all referenced by the prefix " project.



0コメント

  • 1000 / 1000