View Javadoc
1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.spring;
17  
18  import java.io.File;
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import org.kuali.common.util.CollectionUtils;
23  import org.kuali.common.util.execute.Executable;
24  import org.springframework.beans.factory.annotation.Autowired;
25  import org.springframework.context.annotation.Bean;
26  import org.springframework.context.annotation.Configuration;
27  import org.springframework.core.env.Environment;
28  
29  /**
30   * @deprecated
31   */
32  @Deprecated
33  @Configuration
34  public class MetaInfMpxConfig {
35  
36  	private static final String DEFAULT_INCLUDE_PATTERN = "**/*.mpx";
37  	private static final String DEFAULT_OUTPUT_FILE = "${project.build.outputDirectory}/META-INF/${project.groupId.base.path}/${project.artifactId}/data.resources";
38  	private static final String INCLUDES_KEY = "impex.metainf.includes";
39  	private static final String OUTPUT_FILE_KEY = "impex.metainf.includes";
40  	private static final String BUILD_OUTPUT_DIR_KEY = "project.build.outputDirectory";
41  
42  	@Autowired
43  	Environment env;
44  
45  	@Bean
46  	public Executable mpxMetaInfExecutable() {
47  
48  		// Extract the CSV include patterns and convert to a list
49  		String csv = SpringUtils.getProperty(env, INCLUDES_KEY, DEFAULT_INCLUDE_PATTERN);
50  		List<String> includes = CollectionUtils.getTrimmedListFromCSV(csv);
51  
52  		// This is the base directory to scan
53  		File buildOutputDir = new File(SpringUtils.getProperty(env, BUILD_OUTPUT_DIR_KEY));
54  
55  		// Output file contains one line of text for each file that gets located
56  		// Each line is an entry similar to this "classpath:<groupId>/<artifactId>/<tablename>.mpx"
57  		File outputFile = new File(SpringUtils.getProperty(env, OUTPUT_FILE_KEY, DEFAULT_OUTPUT_FILE));
58  
59  		// Setup the context
60  		org.kuali.common.util.metainf.MetaInfContext context = new org.kuali.common.util.metainf.MetaInfContext();
61  		context.setBaseDir(buildOutputDir);
62  		context.setOutputFile(outputFile);
63  		context.setIncludes(includes);
64  
65  		// Setup and return an executable
66  		org.kuali.common.util.execute.MetaInfExecutable exec = new org.kuali.common.util.execute.MetaInfExecutable();
67  		exec.setContexts(Arrays.asList(context));
68  		return exec;
69  	}
70  
71  }