org.scala_tools.maven
Class ScalaScriptMojo

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

public class ScalaScriptMojo
extends org.apache.maven.plugin.AbstractMojo

Run a scala script.

Since:
2.7

Field Summary
protected  String addToClasspath
          Comma seperated list of directories or jars to add to the classpath
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  String excludeScopes
          Comma separated list of scopes to remove from the classpath.
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 includeScopes
          Comma separated list of scopes to add to the classpath.
protected  String[] jvmArgs
          Jvm Arguments.
protected  boolean keepGeneratedScript
          If set to true the Scala classfile that is generated will not be deleted after the goal completes.
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
          The build directory of the project
protected  org.apache.maven.project.MavenProject project
           
protected  List<?> remoteRepos
          List of Remote Repositories used by the resolver
protected  String removeFromClasspath
          Comma separated list of directories or jars to remove from the classpath.
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  String script
          The script that will be executed.
protected  File scriptFile
          The file containing script to be executed.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
ScalaScriptMojo()
           
 
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()
           
protected  void doExecute()
           
 void execute()
           
protected  List<org.apache.maven.model.Dependency> getDependencies()
           
protected  JavaMainCaller getEmptyScalaCommand(String mainClass)
           
protected  JavaMainCaller getScalaCommand()
           
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.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
The build directory of the project


scriptFile

protected File scriptFile
The file containing script to be executed. Either 'scriptFile' or 'script' must be defined.


script

protected String script
The script that will be executed. Either 'scriptFile' or ' script' must be defined.


keepGeneratedScript

protected boolean keepGeneratedScript
If set to true the Scala classfile that is generated will not be deleted after the goal completes. This is to allows easier debugging of the script especially since line numbers will be wrong because lines are added to the compiled script (see script examples)


includeScopes

protected String includeScopes
Comma separated list of scopes to add to the classpath. Eg: test,compile


excludeScopes

protected String excludeScopes
Comma separated list of scopes to remove from the classpath. Eg: test,compile


addToClasspath

protected String addToClasspath
Comma seperated list of directories or jars to add to the classpath


removeFromClasspath

protected String removeFromClasspath
Comma separated list of directories or jars to remove from the classpath. This is useful for resolving conflicts in the classpath. For example, the script uses Ant 1.7 and the compiler dependencies pull in Ant 1.5 optional which conflicts and causes a crash


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

ScalaScriptMojo

public ScalaScriptMojo()
Method Detail

doExecute

protected void doExecute()
                  throws Exception
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

getDependencies

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

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.