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 <em>test</em> sources. 028 * 029 * @goal testCompile 030 * @phase test-compile 031 * @requiresDependencyResolution test 032 * @since 1.0-alpha-1 033 * 034 * @version $Id: TestCompileMojo.java 8 2009-07-16 09:15:04Z user57 $ 035 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a> 036 */ 037 public class TestCompileMojo 038 extends AbstractCompileMojo 039 { 040 /** 041 * The directory where generated Java class files will be placed. 042 * 043 * @parameter default-value="${project.build.testOutputDirectory}" 044 * @required 045 * 046 * @noinspection UnusedDeclaration 047 */ 048 private File outputDirectory; 049 050 /** 051 * Flag to allow test compiliation to be skipped. 052 * 053 * @parameter expression="${maven.test.skip}" default-value="false" 054 * 055 * @noinspection UnusedDeclaration 056 */ 057 private boolean skip; 058 059 protected List getProjectClasspathElements() throws DependencyResolutionRequiredException { 060 return project.getTestClasspathElements(); 061 } 062 063 protected File getOutputDirectory() { 064 return outputDirectory; 065 } 066 067 protected List getSourceRoots() { 068 return project.getTestCompileSourceRoots(); 069 } 070 071 protected FileSet[] getDefaultSources() { 072 FileSet set = new FileSet(); 073 074 File basedir = new File(project.getBasedir(), "src/test/groovy"); 075 set.setDirectory(basedir.getAbsolutePath()); 076 set.addInclude("**/*.groovy"); 077 078 return new FileSet[] { set }; 079 } 080 081 protected Set getForcedCompileSources() { 082 return compileState.getForcedCompilationTestSources(project); 083 } 084 085 protected void doExecute() throws Exception { 086 if (skip) { 087 log.info("Test compiliation is skipped"); 088 } 089 else { 090 super.doExecute(); 091 } 092 } 093 }