Maven Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 11: Line 11:
=Profile=
=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:
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
* per project in the <tt>pom.xml</tt> file
:[[Maven Profile]]
* per-user in <tt>${user.home}/.m2/settings.xml</tt>
</blockquote>
* global in <tt>${maven.home}/conf/settings.xml</tt>
 
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:
 
<pre>
...
<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>
...
</pre>
 
The profile can be activated explicitly on command line with <tt>-P</tt>:
 
<pre>
mvn -Pproduction clear install
</pre>
 
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=
=Lifecycle=

Revision as of 18:42, 26 October 2016

Internal

POM

pom.xml

Profile

Maven Profile

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

Repositories

Maven Repositories

Multi-Module Maven Projects

Multi-Module Maven Projects