1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.spring;
17
18 import java.util.ArrayList;
19 import java.util.Arrays;
20 import java.util.List;
21 import java.util.Properties;
22
23 import org.kuali.common.util.PropertyUtils;
24 import org.kuali.common.util.property.Constants;
25 import org.kuali.common.util.property.processor.ProjectProcessor;
26 import org.kuali.common.util.property.processor.PropertyProcessor;
27 import org.kuali.common.util.property.processor.VersionProcessor;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.beans.factory.annotation.Qualifier;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.Configuration;
32 import org.springframework.core.env.PropertiesPropertySource;
33
34
35
36
37
38
39 @Configuration
40 public class ProjectPropertySourceConfig {
41
42
43
44
45 @Autowired
46 @Qualifier(Constants.DEFAULT_MAVEN_PROPERTIES_BEAN_NAME)
47 Properties mavenProperties;
48
49 @Bean
50 public PropertiesPropertySource projectPropertySource() {
51
52
53 List<PropertyProcessor> processors = new ArrayList<PropertyProcessor>();
54
55
56 processors.add(new ProjectProcessor());
57
58
59
60 processors.add(new VersionProcessor(Arrays.asList("project.version"), true));
61
62
63 PropertyUtils.process(mavenProperties, processors);
64
65
66 String name = Constants.DEFAULT_MAVEN_PROPERTIES_BEAN_NAME;
67 return new PropertiesPropertySource(name, mavenProperties);
68 }
69 }