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;
17  
18  import java.util.Properties;
19  
20  import org.kuali.common.util.spring.service.PropertySourceAddPriority;
21  import org.kuali.common.util.spring.service.PropertySourceContext;
22  import org.kuali.common.util.spring.service.SpringContext;
23  
24  /**
25   * Maven utilities that don't depend on Maven libraries
26   * 
27   * @deprecated
28   */
29  @Deprecated
30  public class MavenUtils {
31  
32  	@Deprecated
33  	public static final String POM = org.kuali.common.util.maven.MavenUtils.POM;
34  	@Deprecated
35  	public static final String PROJECT_VERSION_KEY = org.kuali.common.util.maven.MavenUtils.PROJECT_VERSION_KEY;
36  	@Deprecated
37  	public static final String PROJECT_ENCODING_KEY = org.kuali.common.util.maven.MavenUtils.PROJECT_ENCODING_KEY;
38  
39  	public static org.kuali.common.util.service.SpringContext getMavenizedSpringContext(Class<?> propertySourceConfig) {
40  		SpringContext context = org.kuali.common.util.maven.MavenUtils.getMavenizedSpringContext(propertySourceConfig);
41  		return convert(context);
42  	}
43  
44  	private static final org.kuali.common.util.service.SpringContext convert(SpringContext newContext) {
45  		if (newContext == null) {
46  			return null;
47  		}
48  		org.kuali.common.util.service.SpringContext oldContext = new org.kuali.common.util.service.SpringContext();
49  		oldContext.setAnnotatedClasses(newContext.getAnnotatedClasses());
50  		oldContext.setBeanNames(newContext.getBeanNames());
51  		oldContext.setBeans(newContext.getBeans());
52  		oldContext.setDisplayName(newContext.getDisplayName());
53  		oldContext.setId(newContext.getId());
54  		oldContext.setLocations(newContext.getLocations());
55  		oldContext.setPropertySourceContext(convert(newContext.getPropertySourceContext()));
56  		return oldContext;
57  	}
58  
59  	private static final org.kuali.common.util.service.PropertySourceContext convert(PropertySourceContext newContext) {
60  		if (newContext == null) {
61  			return null;
62  		}
63  		org.kuali.common.util.service.PropertySourceContext oldContext = new org.kuali.common.util.service.PropertySourceContext();
64  		oldContext.setLastOneInWins(newContext.isLastOneInWins());
65  		oldContext.setRemoveExistingSources(newContext.isRemoveExistingSources());
66  		oldContext.setSources(newContext.getSources());
67  		oldContext.setPriority(convert(newContext.getPriority()));
68  		return oldContext;
69  	}
70  
71  	private static final org.kuali.common.util.service.PropertySourceAddPriority convert(PropertySourceAddPriority newPriority) {
72  		if (newPriority == null) {
73  			return null;
74  		}
75  		return org.kuali.common.util.service.PropertySourceAddPriority.valueOf(newPriority.name());
76  	}
77  
78  	/**
79  	 * Return a SpringContext that resolves placeholders using the single <code>PropertySource</code> registered with <code>propertySourceConfig</code>
80  	 */
81  	public static SpringContext getMavenizedSpringContext(Properties mavenProperties, Class<?> propertySourceConfig) {
82  		return org.kuali.common.util.maven.MavenUtils.getMavenizedSpringContext(mavenProperties, propertySourceConfig);
83  	}
84  
85  	/**
86  	 * Add organization, group, and path properties and tokenize the version number adding properties for each token along with a boolean property indicating if this is a SNAPSHOT
87  	 * build
88  	 */
89  	public static void augmentProjectProperties(Properties mavenProperties) {
90  		org.kuali.common.util.maven.MavenUtils.augmentProjectProperties(mavenProperties);
91  	}
92  
93  	public static org.kuali.common.util.property.ProjectProperties getMavenProjectProperties(Properties mavenProperties) {
94  		return org.kuali.common.util.maven.MavenUtils.getMavenProjectProperties(mavenProperties);
95  	}
96  
97  	/**
98  	 * Always return false if <code>forceMojoExecution</code> is true, otherwise return true only if <code>skip</code> is true or <code>packaging</code> is pom.
99  	 */
100 	public static final boolean skip(boolean forceMojoExecution, boolean skip, String packaging) {
101 		return org.kuali.common.util.maven.MavenUtils.skip(forceMojoExecution, skip, packaging);
102 	}
103 
104 }