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 /* 19 * Licensed to the Apache Software Foundation (ASF) under one 20 * or more contributor license agreements. See the NOTICE file 21 * distributed with this work for additional information 22 * regarding copyright ownership. The ASF licenses this file 23 * to you under the Apache License, Version 2.0 (the 24 * "License"); you may not use this file except in compliance 25 * with the License. You may obtain a copy of the License at 26 * 27 * http://www.apache.org/licenses/LICENSE-2.0 28 * 29 * Unless required by applicable law or agreed to in writing, 30 * software distributed under the License is distributed on an 31 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 32 * KIND, either express or implied. See the License for the 33 * specific language governing permissions and limitations 34 * under the License. 35 */ 36 37 import java.util.Iterator; 38 import java.util.List; 39 import java.util.Properties; 40 41 import org.apache.maven.model.Profile; 42 import org.apache.maven.plugin.MojoExecutionException; 43 44 /** 45 * Writes properties of all active profiles to a file. 46 * 47 * @author <a href="mailto:zarars@gmail.com">Zarar Siddiqi</a> 48 * @version $Id: WriteActiveProfileProperties.java 8861 2009-01-21 15:35:38Z pgier $ 49 * @goal write-active-profile-properties 50 */ 51 public class WriteActiveProfileProperties extends AbstractWritePropertiesMojo { 52 @Override 53 public void execute() throws MojoExecutionException { 54 validateOutputFile(); 55 List<?> list = project.getActiveProfiles(); 56 if (getLog().isInfoEnabled()) { 57 getLog().debug(list.size() + " profile(s) active"); 58 } 59 Properties properties = new Properties(); 60 for (Iterator<?> iter = list.iterator(); iter.hasNext();) { 61 Profile profile = (Profile) iter.next(); 62 if (profile.getProperties() != null) { 63 properties.putAll(profile.getProperties()); 64 } 65 } 66 67 getLog().info("Creating " + outputFile); 68 writeProperties(properties, outputFile); 69 } 70 }