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.plugin.compile;
018    
019    import org.apache.maven.artifact.DependencyResolutionRequiredException;
020    import org.apache.maven.shared.model.fileset.FileSet;
021    
022    import java.io.File;
023    import java.util.List;
024    import java.util.Set;
025    
026    /**
027     * Compiles Groovy sources.
028     *
029     * @goal compile
030     * @phase compile
031     * @requiresDependencyResolution compile
032     * @since 1.0-alpha-1
033     *
034     * @version $Id: CompileMojo.java 8 2009-07-16 09:15:04Z user57 $
035     * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
036     */
037    public class CompileMojo
038        extends AbstractCompileMojo
039    {
040        /**
041         * The directory where generated Java class files will be placed.
042         *
043         * @parameter default-value="${project.build.outputDirectory}"
044         * @required
045         * @noinspection UnusedDeclaration
046         */
047        private File outputDirectory;
048    
049        protected List getProjectClasspathElements() throws DependencyResolutionRequiredException {
050            return project.getCompileClasspathElements();
051        }
052    
053        protected File getOutputDirectory() {
054            return outputDirectory;
055        }
056    
057        protected List getSourceRoots() {
058            return project.getCompileSourceRoots();
059        }
060    
061        protected FileSet[] getDefaultSources() {
062            FileSet set = new FileSet();
063            
064            File basedir = new File(project.getBasedir(), "src/main/groovy");
065            set.setDirectory(basedir.getAbsolutePath());
066            set.addInclude("**/*.groovy");
067    
068            return new FileSet[] { set };
069        }
070    
071        protected Set getForcedCompileSources() {
072            return compileState.getForcedCompilationSources(project);
073        }
074    }