1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codehaus.mojo.properties;
17
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.apache.maven.model.Profile;
23 import org.apache.maven.plugin.MojoExecutionException;
24
25
26
27
28
29
30
31
32 public class WriteActiveProfileProperties extends AbstractWritePropertiesMojo {
33 @Override
34 public void execute() throws MojoExecutionException {
35 validateOutputFile();
36 List<?> list = project.getActiveProfiles();
37 if (getLog().isInfoEnabled()) {
38 getLog().debug(list.size() + " profile(s) active");
39 }
40 Properties properties = new Properties();
41 for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
42 Profile profile = (Profile) iter.next();
43 if (profile.getProperties() != null) {
44 properties.putAll(profile.getProperties());
45 }
46 }
47
48 getLog().info("Creating " + outputFile);
49 writeProperties(properties, outputFile);
50 }
51 }