View Javadoc

1   /**
2    * Copyright 2009-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Writes properties of all active profiles to a file.
27   *
28   * @author <a href="mailto:zarars@gmail.com">Zarar Siddiqi</a>
29   * @version $Id: WriteActiveProfileProperties.java 8861 2009-01-21 15:35:38Z pgier $
30   * @goal write-active-profile-properties
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(this.outputFile, properties, this.outputStyle);
49  	}
50  }