Maven Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 53: Line 53:


=Lifecycle=
=Lifecycle=
 
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
The default lifecycle consists in the following phases.
:[[Maven Concepts - Lifecycle|Maven Lifecycle]]
 
</blockquote>
More details: External https://maven.apache.org/ref/3.3.9/maven-core/lifecycles.html#
 
==validate==
==initialize==
==generate-sources==
==process-sources==
==generate-resources==
==process-resources==
==compile==
==process-classes==
==generate-test-sources==
==process-test-sources==
==generate-test-resources==
==process-test-resources==
==test-compile==
==process-test-classes==
==test==
==prepare-package==
==package==
==pre-integration-test==
==integration-test==
==post-integration-test==
==verify==
==install==
==deploy==


=System Properties=
=System Properties=

Revision as of 01:06, 31 May 2016

Internal

POM

pom.xml

Profile

A profile is an alternative set of configurations which set or override default values. Profiles allow to customize a build for different environments. Profiles can be defined:

  • per project in the pom.xml file
  • per-user in ${user.home}/.m2/settings.xml
  • global in ${maven.home}/conf/settings.xml

Each profile is identified with an identifier. Profiles customizes the build for different environments (e.g. production or development, different operating systems, different JDK versions, etc.)

An example of profile:

...
<profiles> 
   <profile>
     <id>production</id>
         <build>
            <plugins>
              <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                      <debug>false</debug> 
                      <optimize>true</optimize>
                  </configuration>
                </plugin>
            </plugins>
         </build>
   </profile>
 </profiles>
...

The profile can be activated explicitly on command line with -P:

mvn -Pproduction clear install

A profile can also be triggered through Maven settings, based on environment variables, OS settings, or present or missing files.

More information: http://maven.apache.org/guides/introduction/introduction-to-profiles.html

Lifecycle

Maven Lifecycle

System Properties

System properties can be declared and exposed to the build in the <properties> section of pom.xml. See:

pom.xml <properties>

Dependencies

Maven Dependencies

Multi-Module Maven Projects

Multi-Module Maven Projects