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.io.File;
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Properties;
22
23 import org.kuali.common.util.execute.Executable;
24 import org.kuali.common.util.execute.ExecutablesExecutable;
25 import org.kuali.common.util.execute.StorePropertiesExecutable;
26 import org.kuali.common.util.execute.StoreRicePropertiesExecutable;
27 import org.kuali.common.util.property.Constants;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.Configuration;
32 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
33 import org.springframework.core.env.ConfigurableEnvironment;
34 import org.springframework.util.Assert;
35
36
37
38
39 @Deprecated
40 @Configuration
41 public class MetaInfProjectPropertiesSetupConfig {
42
43 @Autowired
44 ConfigurableEnvironment env;
45
46 @Bean
47 public static PropertySourcesPlaceholderConfigurer pspc() {
48 return new PropertySourcesPlaceholderConfigurer();
49 }
50
51 @Value(Constants.PROJECT_PROPERTIES_OUTPUTFILE)
52 File outputFile;
53
54 @Value(Constants.RICE_PROJECT_PROPERTIES_OUTPUTFILE)
55 File riceOutputFile;
56
57 @Bean
58 public Properties springProperties() {
59 return PropertySourceUtils.getAllEnumerableProperties(env);
60 }
61
62 @Bean
63 public Executable storePropertiesExecutablesExectuable() {
64
65
66 String encoding = SpringUtils.getProperty(env, "project.encoding");
67
68
69 Assert.hasText(encoding);
70
71
72 List<String> includes = SpringUtils.getNoneSensitiveListFromCSV(env, "project.metainf.includes");
73 List<String> excludes = SpringUtils.getNoneSensitiveListFromCSV(env, "project.metainf.excludes");
74
75
76 Properties properties = springProperties();
77
78
79 StorePropertiesExecutable spe = new StorePropertiesExecutable();
80 spe.setSkip(SpringUtils.getBoolean(env, "project.metainf.skip", false));
81 spe.setSkipIfExists(SpringUtils.getBoolean(env, "project.metainf.skipIfExists", true));
82 spe.setSkipIfEqual(SpringUtils.getBoolean(env, "project.metainf.skipIfEqual", true));
83 spe.setEncoding(encoding);
84 spe.setOutputFile(outputFile);
85 spe.setProperties(properties);
86 spe.setIncludes(includes);
87 spe.setExcludes(excludes);
88
89
90 StoreRicePropertiesExecutable srpe = new StoreRicePropertiesExecutable();
91 spe.setSkip(SpringUtils.getBoolean(env, "project.metainf.skip", false));
92 spe.setSkipIfExists(SpringUtils.getBoolean(env, "project.metainf.skipIfExists", true));
93 spe.setSkipIfEqual(SpringUtils.getBoolean(env, "project.metainf.skipIfEqual", true));
94 srpe.setEncoding(encoding);
95 srpe.setOutputFile(riceOutputFile);
96 srpe.setProperties(properties);
97 srpe.setIncludes(includes);
98 srpe.setExcludes(excludes);
99
100
101 List<Executable> executables = new ArrayList<Executable>();
102 executables.add(spe);
103 executables.add(srpe);
104
105
106 return new ExecutablesExecutable(executables);
107 }
108
109 }