Profiles
Profiles provide the if-else conditional behaviours of the POM . It is basically aimed towards configuring your build and allows for different builds depending on the its properties. A couple of the usual properties used are the JDK, the OS ( Operating System )and the operating system. Furthermore, Profiles profiles can be activated depending on whether a particular file exists or notthe existence of particular files.
Generic Property Activation
...
To activate a profile when a certain property has a certain value (in this case myproperty=myvalue):
| Code Block |
|---|
<profiles>
<profile>
<activation>
<property>
<name>myproperty</name>
<value>myvalue</value>
</property>
</activation>
...
</profile>
...
</profiles>
|
To activate a profile when a certain property exists (regardless of value):
| Code Block |
|---|
<profiles>
<profile>
<activation>
<property>
<name>myproperty</name>
</property>
</activation>
...
</profile>
...
</profiles>
|
...
To configure the activation via the operating system, you can specify at least one out of four (4) things - items - the project name, family, architecture, and version.
The Profile OS Activation part looks like this activation part is shown below:
| Code Block |
|---|
<profiles>
<profile>
<activation>
<os>
<name>windows xp</name>
<family>windows</family>
<arch>x86</arch>
<version>5.1</version>
</os>
</activation>
...
</profile>
...
</profiles>
|
...
| Warning | ||
|---|---|---|
| ||
For Maven versions prior to 2.0.6, you need to declare your OS family, name, arch and version all in small caps (see MNG-2814). |
File Activation
To activate when a certaint file existsControlling activation upon the existence of specific files:
| Code Block |
|---|
<profiles>
<profile>
<activation>
<file>
<exists>myfile</exists>
</file>
</activation>
...
</profile>
...
</profiles>
|
To activate when a certaint file does not existControlling activation upon the absence of specific files:
| Code Block |
|---|
<profiles>
<profile>
<activation>
<missing>
<exists>myfile</exists>
</missing>
</activation>
...
</profile>
...
</profiles>
|
...
Prepend "!" on property name, os family, os name, os version and os arch to negate.
Meaning
| Code Block |
|---|
<profiles>
<profile>
<activation>
<property>
<name>!myproperty</name>
</property>
</activation>
...
</profile>
...
</profiles>
|
gets executed when myproperty is not defined. And
| Code Block |
|---|
<profiles>
<profile>
<activation>
<os>
<name>!windows xp</name>
<family>!windows</family>
<arch>!x86</arch>
<version>!5.1</version>
</os>
</activation>
...
</profile>
...
</profiles>
|
gets evaluated as true when
| Code Block |
|---|
name != "windows xp" AND family != "windows" AND arch != "x86" AND version != 5.1
|
Active by Default
Set to true to activate activate by default
