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.stubgen; 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 025 /** 026 * Generate Java stubs from Groovy sources. 027 * 028 * @goal generateStubs 029 * @phase generate-sources 030 * @requiresDependencyResolution compile 031 * @since 1.0-beta-2 032 * 033 * @version $Id: GenerateStubsMojo.java 8 2009-07-16 09:15:04Z user57 $ 034 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a> 035 */ 036 public class GenerateStubsMojo 037 extends AbstractGenerateStubsMojo 038 { 039 /** 040 * The directory where generated Java stub files will be placed. 041 * 042 * @parameter default-value="${project.build.directory}/generated-sources/groovy-stubs/main" 043 * @required 044 * @noinspection UnusedDeclaration 045 */ 046 private File outputDirectory; 047 048 protected List getProjectClasspathElements() throws DependencyResolutionRequiredException { 049 return project.getCompileClasspathElements(); 050 } 051 052 protected File getOutputDirectory() { 053 return outputDirectory; 054 } 055 056 protected List getSourceRoots() { 057 return project.getCompileSourceRoots(); 058 } 059 060 protected FileSet[] getDefaultSources() { 061 FileSet set = new FileSet(); 062 063 File basedir = new File(project.getBasedir(), "src/main/groovy"); 064 set.setDirectory(basedir.getAbsolutePath()); 065 set.addInclude("**/*.groovy"); 066 067 return new FileSet[] { set }; 068 } 069 070 protected void forceCompile(final File file) { 071 compileState.addForcedCompilationSource(project, file); 072 } 073 }