001 /** 002 * Copyright 2010-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.common.util; 017 018 import java.util.Properties; 019 020 import org.kuali.common.util.spring.service.PropertySourceAddPriority; 021 import org.kuali.common.util.spring.service.PropertySourceContext; 022 import org.kuali.common.util.spring.service.SpringContext; 023 024 /** 025 * Maven utilities that don't depend on Maven libraries 026 * 027 * @deprecated 028 */ 029 @Deprecated 030 public class MavenUtils { 031 032 @Deprecated 033 public static final String POM = org.kuali.common.util.maven.MavenUtils.POM; 034 @Deprecated 035 public static final String PROJECT_VERSION_KEY = org.kuali.common.util.maven.MavenUtils.PROJECT_VERSION_KEY; 036 @Deprecated 037 public static final String PROJECT_ENCODING_KEY = org.kuali.common.util.maven.MavenUtils.PROJECT_ENCODING_KEY; 038 039 public static org.kuali.common.util.service.SpringContext getMavenizedSpringContext(Class<?> propertySourceConfig) { 040 SpringContext context = org.kuali.common.util.maven.MavenUtils.getMavenizedSpringContext(propertySourceConfig); 041 return convert(context); 042 } 043 044 private static final org.kuali.common.util.service.SpringContext convert(SpringContext newContext) { 045 if (newContext == null) { 046 return null; 047 } 048 org.kuali.common.util.service.SpringContext oldContext = new org.kuali.common.util.service.SpringContext(); 049 oldContext.setAnnotatedClasses(newContext.getAnnotatedClasses()); 050 oldContext.setBeanNames(newContext.getBeanNames()); 051 oldContext.setBeans(newContext.getBeans()); 052 oldContext.setDisplayName(newContext.getDisplayName()); 053 oldContext.setId(newContext.getId()); 054 oldContext.setLocations(newContext.getLocations()); 055 oldContext.setPropertySourceContext(convert(newContext.getPropertySourceContext())); 056 return oldContext; 057 } 058 059 private static final org.kuali.common.util.service.PropertySourceContext convert(PropertySourceContext newContext) { 060 if (newContext == null) { 061 return null; 062 } 063 org.kuali.common.util.service.PropertySourceContext oldContext = new org.kuali.common.util.service.PropertySourceContext(); 064 oldContext.setLastOneInWins(newContext.isLastOneInWins()); 065 oldContext.setRemoveExistingSources(newContext.isRemoveExistingSources()); 066 oldContext.setSources(newContext.getSources()); 067 oldContext.setPriority(convert(newContext.getPriority())); 068 return oldContext; 069 } 070 071 private static final org.kuali.common.util.service.PropertySourceAddPriority convert(PropertySourceAddPriority newPriority) { 072 if (newPriority == null) { 073 return null; 074 } 075 return org.kuali.common.util.service.PropertySourceAddPriority.valueOf(newPriority.name()); 076 } 077 078 /** 079 * Return a SpringContext that resolves placeholders using the single <code>PropertySource</code> registered with <code>propertySourceConfig</code> 080 */ 081 public static SpringContext getMavenizedSpringContext(Properties mavenProperties, Class<?> propertySourceConfig) { 082 return org.kuali.common.util.maven.MavenUtils.getMavenizedSpringContext(mavenProperties, propertySourceConfig); 083 } 084 085 /** 086 * 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 087 * build 088 */ 089 public static void augmentProjectProperties(Properties mavenProperties) { 090 org.kuali.common.util.maven.MavenUtils.augmentProjectProperties(mavenProperties); 091 } 092 093 public static org.kuali.common.util.property.ProjectProperties getMavenProjectProperties(Properties mavenProperties) { 094 return org.kuali.common.util.maven.MavenUtils.getMavenProjectProperties(mavenProperties); 095 } 096 097 /** 098 * 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. 099 */ 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 }