1 package org.codehaus.mojo.properties;
2
3
4
5
6 import org.apache.maven.model.Profile;
7 import org.apache.maven.plugin.MojoExecutionException;
8
9 import java.util.Iterator;
10 import java.util.List;
11 import java.util.Properties;
12
13 /**
14 * Writes properties of all active profiles to a file
15 *
16 * @author <a href="mailto:zarars@gmail.com">Zarar Siddiqi</a>
17 * @version $Id$
18 * @goal write-active-profile-properties
19 */
20 public class WriteActiveProfileProperties
21 extends AbstractWritePropertiesMojo
22 {
23
24 public void execute()
25 throws MojoExecutionException {
26 validateOutputFile();
27 List list = project.getActiveProfiles();
28 if (getLog().isInfoEnabled()) {
29 getLog().info(list.size() + " profile(s) active");
30 }
31 Properties properties = new Properties();
32 for (Iterator iter = list.iterator(); iter.hasNext();) {
33 Profile profile = (Profile) iter.next();
34 if (profile.getProperties() != null) {
35 properties.putAll(profile.getProperties());
36 }
37 }
38
39 writeProperties(properties, outputFile);
40 }
41 }
42