1 package org.kuali.common.impex.spring;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.util.Arrays;
6 import java.util.List;
7
8 import org.kuali.common.util.CollectionUtils;
9 import org.kuali.common.util.MetaInfContext;
10 import org.kuali.common.util.MetaInfUtils;
11 import org.kuali.common.util.spring.SpringUtils;
12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.context.annotation.Bean;
14 import org.springframework.context.annotation.Configuration;
15 import org.springframework.core.env.Environment;
16
17 @Configuration
18 public class MetaInfMpxConfig {
19
20 @Autowired
21 Environment env;
22
23 @Bean
24 public Object scanAndCreateFiles() {
25
26 String csv = SpringUtils.getProperty(env, "impex.metainf.includes", "**/*.mpx");
27 List<String> includes = CollectionUtils.getTrimmedListFromCSV(csv);
28
29
30 File baseDir = new File(SpringUtils.getProperty(env, "project.build.outputDirectory"));
31
32
33
34 File outputFile = new File(SpringUtils.getProperty(env, "impex.metainf.outputFile"));
35
36
37 MetaInfContext context = new MetaInfContext();
38 context.setBaseDir(baseDir);
39 context.setOutputFile(outputFile);
40 context.setIncludes(includes);
41
42 try {
43
44 MetaInfUtils.scanAndCreateFiles(Arrays.asList(context));
45 } catch (IOException e) {
46 throw new IllegalStateException(e);
47 }
48 return null;
49 }
50 }