Configure default and alternative executions in maven pom using profilesBy neokrates, written on June 2, 2010 |
howto |
- neokrates
- Email: uwarov@yahoo.com
- Website: http://www.thinkplexx.com
- Join date: 05-31-09
- Posts: 20
Rate it
Ad
Poll
What build management tool does your project or firm use?
- Buildr (47%, 15 Votes)
- Maven 2 (6%, 2 Votes)
- Ant (6%, 2 Votes)
- Maven (3%, 1 Votes)
- Maven 3 (3%, 1 Votes)
- Ivy (0%, 0 Votes)
- GAnt (0%, 0 Votes)
- Gradle (0%, 0 Votes)
- Rake (0%, 0 Votes)
- Raven (0%, 0 Votes)
- Any Make Type Tool (0%, 0 Votes)
Total Voters: 32
Loading ...
Most popular search terms:
Maybe you develop an alternative build chain path. You want all to function default way. But, with one switch you want to be able to change the build chain logic. All steps or just some.
That can be done with maven’s profiles inside the pom. Here is a basic pom, which will execute one build step per default, and another if you give the particular profile name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my.group</groupId> <artifactId>my.id</artifactId> <name>my.name</name> <version>1.1-SNAPSHOT</version> <profiles> <profile> <id>DefaultProfile</id> <activation><activeByDefault>true</activeByDefault></activation> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>DEFAULT-profile</id> <phase>initialize</phase> <configuration> <tasks> <echo> --- Execute default configuration with DEFAULT profile --- </echo> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.codehaus.gant</groupId> <artifactId>gant_groovy1.7</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.7.0</version> </dependency> </dependencies> </plugin> </plugins> </build> </profile> <profile> <id>AltProfile</id> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <execution> <id>ALT-profile</id> <phase>initialize</phase> <configuration> <tasks> <echo> *** Execute alternative configuration with ALT Profile *** </echo> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.codehaus.gant</groupId> <artifactId>gant_groovy1.7</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.7.0</version> </dependency> </dependencies> </plugin> </plugins> </build> </profile> </profiles> </project> |
No profiles, means default is used:
> mvn clean install ... [INFO] [antrun:run {execution: DEFAULT-profile}] [INFO] Executing tasks [echo] --- Execute default configuration with DEFAULT profile --- [INFO] Executed tasks ...
Alternative profile is invoked, default will be disabled:
> mvn clean install -PAltProfile ... [INFO] [antrun:run {execution: ALT-profile}] [INFO] Executing tasks [echo] *** Execute alternative configuration with ALT Profile *** [INFO] Executed tasks ...
|
LEARN MORE (amazon bookstore)
|
|
TAGS
|
|
SOCIAL
|
|
INCOMING SEARCH TERMS
|


















