View Javadoc

1   package org.kuali.common.util.metainf.spring;
2   
3   import java.io.File;
4   import java.util.Collections;
5   import java.util.List;
6   
7   import org.kuali.common.util.metainf.model.MetaInfContext;
8   import org.kuali.common.util.metainf.service.MetaInfUtils;
9   import org.kuali.common.util.nullify.NullUtils;
10  import org.kuali.common.util.project.model.Build;
11  import org.kuali.common.util.project.model.Project;
12  import org.kuali.common.util.project.spring.AutowiredProjectConfig;
13  import org.kuali.common.util.spring.SpringUtils;
14  import org.kuali.common.util.spring.env.EnvironmentService;
15  import org.kuali.common.util.spring.service.SpringServiceConfig;
16  import org.springframework.beans.factory.annotation.Autowired;
17  import org.springframework.context.annotation.Bean;
18  import org.springframework.context.annotation.Configuration;
19  import org.springframework.context.annotation.Import;
20  
21  @Configuration
22  @Import({ AutowiredProjectConfig.class, MetaInfExecutableConfig.class, SpringServiceConfig.class })
23  public class MpxConfig implements MetaInfContextsConfig {
24  
25  	private static final String PREFIX = "mpx";
26  	private static final String DEFAULT_INCLUDES = "**/*.mpx";
27  	private static final String DEFAULT_EXCLUDES = NullUtils.NONE;
28  	private static final String INCLUDES_KEY = MetaInfConfigUtils.getIncludesKey(PREFIX);
29  	private static final String EXCLUDES_KEY = MetaInfConfigUtils.getExcludesKey(PREFIX);
30  
31  	private static final boolean DEFAULT_GENERATE_RELATIVE_PATHS = true;
32  	private static final String RELATIVE_KEY = MetaInfUtils.PROPERTY_PREFIX + ".mpx.relative";
33  
34  	@Autowired
35  	EnvironmentService env;
36  
37  	@Autowired
38  	Project project;
39  
40  	@Autowired
41  	Build build;
42  
43  	@Override
44  	@Bean
45  	public List<MetaInfContext> metaInfContexts() {
46  		boolean relativePaths = env.getBoolean(RELATIVE_KEY, DEFAULT_GENERATE_RELATIVE_PATHS);
47  		List<String> includes = SpringUtils.getNoneSensitiveListFromCSV(env, INCLUDES_KEY, DEFAULT_INCLUDES);
48  		List<String> excludes = SpringUtils.getNoneSensitiveListFromCSV(env, EXCLUDES_KEY, DEFAULT_EXCLUDES);
49  		File outputFile = MetaInfUtils.getOutputFile(project, build, MetaInfGroup.DATA);
50  		File scanDir = build.getOutputDir();
51  		String encoding = build.getEncoding();
52  		MetaInfContext context = new MetaInfContext.Builder(outputFile, encoding, scanDir).includes(includes).excludes(excludes).relativePaths(relativePaths).build();
53  		return Collections.singletonList(context);
54  	}
55  
56  }