001/** 002 * Copyright 2010-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.common.util.spring; 017 018import static org.kuali.common.util.maven.MavenConstants.PROPERTIES_BEAN_NAME; 019import static org.kuali.common.util.maven.MavenUtils.augmentProjectProperties; 020 021import java.util.Properties; 022 023import org.springframework.beans.factory.annotation.Autowired; 024import org.springframework.beans.factory.annotation.Qualifier; 025import org.springframework.context.annotation.Bean; 026import org.springframework.context.annotation.Configuration; 027import org.springframework.core.env.PropertiesPropertySource; 028 029/** 030 * Augment the default set of properties that ship with Maven and register them as a Spring <code>PropertySource</code>. 031 * 032 * spring-maven-plugin auto-registers any beans that implement <code>PropertySource</code> as a top level property source 033 */ 034@Configuration 035public class ProjectPropertySourceConfig { 036 037 /** 038 * spring-maven-plugin auto-wires Maven properties by default 039 */ 040 @Autowired 041 @Qualifier(PROPERTIES_BEAN_NAME) 042 Properties mavenProperties; 043 044 @Bean 045 public PropertiesPropertySource projectPropertySource() { 046 047 // organization, group, path and enhanced version properties 048 augmentProjectProperties(mavenProperties); 049 050 // Return the augmented set of Maven properties as a Spring PropertySource 051 return new PropertiesPropertySource(PROPERTIES_BEAN_NAME, mavenProperties); 052 } 053}