The maven profiles is an element in the POM file that allows customization of the build process .
The profiles element in the POM contains a list of profile elements .Each profile element has an id used in the call for the maven plugin execution and akey value collection: properties that define the profile properties list .
(There is although an <activation> option but its out of this post scope )
For an example lets look in the spring integration hello world demo .
The POM define 2 profiles that define options that define the key: java.main.class value
In the pom xml :
<profiles>
<profile>
<id>hello</id>
<properties>
<java.main.class>org.springframework.integration.samples.helloworld.HelloWorldApp</java.main.class>
</properties>
</profile>
<profile>
<id>poller</id>
<properties>
<java.main.class>org.springframework.integration.samples.helloworld.PollerApp</java.main.class>
</properties>
</profile>
</profiles>
The usage of the properties in the example in the exec-maven-plugin plugin where the main class is configured based on the selected profile property .
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>${java.main.class}</mainClass>
</configuration>
</plugin>
In order to specify the current selected option in the mvn command use the –p for an exmple -p Hello
אין תגובות:
הוסף רשומת תגובה