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 List<?> list = project.getActiveProfiles();
36 if (getLog().isInfoEnabled()) {
37 getLog().debug(list.size() + " profile(s) active");
38 }
39 Properties properties = new Properties();
40 for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
41 Profile profile = (Profile) iter.next();
42 if (profile.getProperties() != null) {
43 properties.putAll(profile.getProperties());
44 }
45 }
46
47 getLog().info("Creating " + outputFile);
48 writeProperties(properties, outputFile);
49 }
50 }