001    /*
002     * Copyright (C) 2006-2007 the original author or authors.
003     *
004     * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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    
017    package org.codehaus.gmaven.runtime.v1_5;
018    
019    import org.codehaus.gmaven.feature.Feature;
020    import org.codehaus.gmaven.feature.Version;
021    import org.codehaus.gmaven.feature.support.ProviderSupport;
022    import org.codehaus.groovy.runtime.InvokerHelper;
023    
024    import java.util.LinkedHashMap;
025    import java.util.Map;
026    
027    /**
028     * Provides support for Groovy 1.5.
029     *
030     * @version $Id: ProviderImpl.java 49 2009-10-16 14:03:56Z user57 $
031     * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
032     */
033    public class ProviderImpl
034        extends ProviderSupport
035    {
036        public static final String KEY = "1.5";
037    
038        public ProviderImpl() {
039            super(KEY);
040        }
041    
042        protected Map detectFeatures() {
043            Feature[] features = {
044                new ClassFactoryFeature(),
045                new ScriptExecutorFeature(),
046                new ClassCompilerFeature(),
047                new StubCompilerFeature(),
048                new ConsoleFeature(),
049                new ShellFeature(),
050                new TraceSanitizerFeature(),
051            };
052    
053            Map map = new LinkedHashMap();
054    
055            for (int i=0; i<features.length; i++) {
056                map.put(features[i].key(), features[i]);
057            }
058    
059            return map;
060        }
061    
062        protected Version detectVersion() {
063            return new Version(1, 5, 8);
064        }
065    
066        public String name() {
067            return "Groovy v" + InvokerHelper.getVersion();
068        }
069    }