org.scala_tools.maven
Class ScalaCompileMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.scala_tools.maven.ScalaCompilerSupport
          extended by org.scala_tools.maven.ScalaCompileMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class ScalaCompileMojo
extends ScalaCompilerSupport

Compiles a directory of Scala source. Corresponds roughly to the compile goal of the maven-compiler-plugin


Field Summary
protected  String[] args
          compiler additionnals arguments
protected  boolean checkMultipleScalaVersions
          Check if every dependencies use the same version of scala-library.
protected  BasicArtifact[] compilerPlugins
          Compiler plugin dependencies to use when compiling.
protected  BasicArtifact[] dependencies
          Additional dependencies/jar to add to classpath to run "scalaClassName" (scope and optional field not supported) ex : <dependencies> <dependency> <groupId>org.scala-tools</groupId> <artifactId>scala-compiler-addon</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies>
protected  boolean displayCmd
          Display the command line called ?
protected  org.apache.maven.artifact.factory.ArtifactFactory factory
          Used to look up Artifacts in the remote repository.
protected  boolean failOnMultipleScalaVersions
          Determines if a detection of multiple scala versions in the dependencies will cause the build to fail.
protected  boolean forceUseArgFile
          Force the use of an external ArgFile to run any forked process.
protected  boolean fork
          Forks the execution of scalac into a separate process.
protected  String[] jvmArgs
          Jvm Arguments.
protected  org.apache.maven.artifact.repository.ArtifactRepository localRepo
          Location of the local repository.
protected  org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
          Artifact factory, needed to download source jars.
protected  File outputDir
           
protected  org.apache.maven.project.MavenProject project
           
protected  List<?> remoteRepos
          List of Remote Repositories used by the resolver
protected  org.apache.maven.artifact.resolver.ArtifactResolver resolver
          Used to look up Artifacts in the remote repository.
static String SCALA_GROUPID
           
static String SCALA_LIBRARY_ARTIFACTID
           
protected  String scalaClassName
          className (FQN) of the scala tool to provide as
protected  String scalaVersion
          Scala 's version to use
protected  File sourceDir
           
 
Fields inherited from class org.scala_tools.maven.ScalaCompilerSupport
loopSleep, sendJavaToScalac
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
ScalaCompileMojo()
           
 
Method Summary
protected  void addToClasspath(org.apache.maven.artifact.Artifact artifact, Set<String> classpath)
           
protected  void addToClasspath(String groupId, String artifactId, String version, Set<String> classpath)
           
protected  void checkScalaVersion()
           
 void execute()
           
protected  List<String> getClasspathElements()
           
protected  List<org.apache.maven.model.Dependency> getDependencies()
           
protected  JavaMainCaller getEmptyScalaCommand(String mainClass)
           
protected  File getOutputDir()
           
protected  JavaMainCaller getScalaCommand()
           
protected  List<String> getSourceDirectories()
          Retreives the list of *all* root source directories.
protected  boolean isJavaSupportedByCompiler()
           
protected  Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact)
          This method resolves all transitive dependencies of an artifact.
protected  Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts(org.apache.maven.project.MavenProject theProject)
          This method resolves the dependency artifacts from the project.
 
Methods inherited from class org.scala_tools.maven.ScalaCompilerSupport
compile, compile, doExecute, normalize
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputDir

protected File outputDir

sourceDir

protected File sourceDir

SCALA_GROUPID

public static final String SCALA_GROUPID
See Also:
Constant Field Values

SCALA_LIBRARY_ARTIFACTID

public static final String SCALA_LIBRARY_ARTIFACTID
See Also:
Constant Field Values

project

protected org.apache.maven.project.MavenProject project

factory

protected org.apache.maven.artifact.factory.ArtifactFactory factory
Used to look up Artifacts in the remote repository.


resolver

protected org.apache.maven.artifact.resolver.ArtifactResolver resolver
Used to look up Artifacts in the remote repository.


localRepo

protected org.apache.maven.artifact.repository.ArtifactRepository localRepo
Location of the local repository.


remoteRepos

protected List<?> remoteRepos
List of Remote Repositories used by the resolver


dependencies

protected BasicArtifact[] dependencies
Additional dependencies/jar to add to classpath to run "scalaClassName" (scope and optional field not supported) ex : <dependencies> <dependency> <groupId>org.scala-tools</groupId> <artifactId>scala-compiler-addon</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies>


compilerPlugins

protected BasicArtifact[] compilerPlugins
Compiler plugin dependencies to use when compiling. ex:


jvmArgs

protected String[] jvmArgs
Jvm Arguments.


args

protected String[] args
compiler additionnals arguments


scalaClassName

protected String scalaClassName
className (FQN) of the scala tool to provide as


scalaVersion

protected String scalaVersion
Scala 's version to use


displayCmd

protected boolean displayCmd
Display the command line called ?


fork

protected boolean fork
Forks the execution of scalac into a separate process.


forceUseArgFile

protected boolean forceUseArgFile
Force the use of an external ArgFile to run any forked process.


checkMultipleScalaVersions

protected boolean checkMultipleScalaVersions
Check if every dependencies use the same version of scala-library.


failOnMultipleScalaVersions

protected boolean failOnMultipleScalaVersions
Determines if a detection of multiple scala versions in the dependencies will cause the build to fail.


mavenProjectBuilder

protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
Artifact factory, needed to download source jars.

Constructor Detail

ScalaCompileMojo

public ScalaCompileMojo()
Method Detail

getSourceDirectories

protected List<String> getSourceDirectories()
                                     throws Exception
Description copied from class: ScalaCompilerSupport
Retreives the list of *all* root source directories. We need to pass all .java and .scala files into the scala compiler

Specified by:
getSourceDirectories in class ScalaCompilerSupport
Throws:
Exception

getClasspathElements

protected List<String> getClasspathElements()
                                     throws Exception
Specified by:
getClasspathElements in class ScalaCompilerSupport
Throws:
Exception

getDependencies

protected List<org.apache.maven.model.Dependency> getDependencies()

getOutputDir

protected File getOutputDir()
                     throws Exception
Specified by:
getOutputDir in class ScalaCompilerSupport
Throws:
Exception

resolveDependencyArtifacts

protected Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts(org.apache.maven.project.MavenProject theProject)
                                                                      throws Exception
This method resolves the dependency artifacts from the project.

Parameters:
theProject - The POM.
Returns:
resolved set of dependency artifacts.
Throws:
org.apache.maven.artifact.resolver.ArtifactResolutionException
org.apache.maven.artifact.resolver.ArtifactNotFoundException
org.apache.maven.project.artifact.InvalidDependencyVersionException
Exception

resolveArtifactDependencies

protected Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact)
                                                                       throws Exception
This method resolves all transitive dependencies of an artifact.

Parameters:
artifact - the artifact used to retrieve dependencies
Returns:
resolved set of dependencies
Throws:
org.apache.maven.artifact.resolver.ArtifactResolutionException
org.apache.maven.artifact.resolver.ArtifactNotFoundException
org.apache.maven.project.ProjectBuildingException
org.apache.maven.project.artifact.InvalidDependencyVersionException
Exception

addToClasspath

protected void addToClasspath(String groupId,
                              String artifactId,
                              String version,
                              Set<String> classpath)
                       throws Exception
Throws:
Exception

addToClasspath

protected void addToClasspath(org.apache.maven.artifact.Artifact artifact,
                              Set<String> classpath)
                       throws Exception
Throws:
Exception

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

checkScalaVersion

protected void checkScalaVersion()
                          throws Exception
Throws:
Exception

getScalaCommand

protected JavaMainCaller getScalaCommand()
                                  throws Exception
Throws:
Exception

getEmptyScalaCommand

protected JavaMainCaller getEmptyScalaCommand(String mainClass)
                                       throws Exception
Throws:
Exception

isJavaSupportedByCompiler

protected boolean isJavaSupportedByCompiler()
Returns:
This returns whether or not the scala version can support having java sent into the compiler


Copyright © 2009-2010 Scala Tools. All Rights Reserved.