View Javadoc

1   /*
2    * Copyright 2007 scala-tools.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing,
11   * software distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions
14   * and limitations under the License.
15   */
16   package org.scala_tools.maven;
17  
18  import java.io.File;
19  import java.util.List;
20  
21  import org.apache.maven.model.Dependency;
22  
23  /**
24   * Compiles a directory of Scala source. Corresponds roughly to the compile goal
25   * of the maven-compiler-plugin
26   *
27   * @phase compile
28   * @goal compile
29   * @requiresDependencyResolution compile
30   */
31  public class ScalaCompileMojo extends ScalaCompilerSupport {
32  
33      /**
34       * @parameter expression="${project.build.outputDirectory}"
35       */
36      protected File outputDir;
37  
38      /**
39       * @parameter expression="${project.build.sourceDirectory}/../scala"
40       */
41      protected File sourceDir;
42  
43      @SuppressWarnings("unchecked")
44      @Override
45      protected List<String> getClasspathElements() throws Exception {
46          return project.getCompileClasspathElements();
47      }
48  
49      @SuppressWarnings("unchecked")
50      @Override
51      protected List<Dependency> getDependencies() {
52          return project.getCompileDependencies();
53      }
54  
55      @Override
56      protected File getOutputDir() throws Exception {
57          return outputDir.getAbsoluteFile();
58      }
59  
60      @Override
61      protected File getSourceDir() throws Exception {
62          return sourceDir.getAbsoluteFile();
63      }
64  }