org.scala_tools.maven
Class ScalaScriptMojo

Package class diagram package 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  java.lang.String addToClasspath
          Comma seperated list of directories or jars to add to the classpath
protected  java.lang.String[] args
          compiler additionnals arguments
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  java.lang.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  java.lang.String includeScopes
          Comma separated list of scopes to add to the classpath.
protected  java.lang.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  java.io.File outputDir
          The build directory of the project
protected  org.apache.maven.project.MavenProject project
           
protected  java.util.List<?> remoteRepos
          List of Remote Repositories used by the resolver
protected  java.lang.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 java.lang.String SCALA_GROUPID
           
static java.lang.String SCALA_LIBRARY_ARTIFACTID
           
protected  java.lang.String scalaClassName
          className (FQN) of the scala tool to provide as
protected  java.lang.String scalaVersion
          Scala 's version to use
protected  java.lang.String script
          The script that will be executed.
protected  java.io.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, java.util.Set<java.lang.String> classpath)
           
protected  void addToClasspath(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.util.Set<java.lang.String> classpath)
           
protected  void checkScalaVersion()
           
protected  void doExecute()
           
 void execute()
           
protected  java.util.List<org.apache.maven.model.Dependency> getDependencies()
           
protected  JavaCommand getEmptyScalaCommand(java.lang.String mainClass)
           
protected  JavaCommand getScalaCommand()
           
protected  java.util.Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact)
          This method resolves all transitive dependencies of an artifact.
protected  java.util.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 java.io.File outputDir
The build directory of the project


scriptFile

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


script

protected java.lang.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 java.lang.String includeScopes
Comma separated list of scopes to add to the classpath. Eg: test,compile


excludeScopes

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


addToClasspath

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


removeFromClasspath

protected java.lang.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 java.lang.String SCALA_GROUPID
See Also:
Constant Field Values

SCALA_LIBRARY_ARTIFACTID

public static final java.lang.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 java.util.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>


jvmArgs

protected java.lang.String[] jvmArgs
Jvm Arguments.


args

protected java.lang.String[] args
compiler additionnals arguments


scalaClassName

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


scalaVersion

protected java.lang.String scalaVersion
Scala 's version to use


displayCmd

protected boolean displayCmd
Display the command line called ?


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 java.lang.Exception
Throws:
java.lang.Exception

resolveDependencyArtifacts

protected java.util.Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts(org.apache.maven.project.MavenProject theProject)
                                                                                throws java.lang.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
java.lang.Exception

resolveArtifactDependencies

protected java.util.Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact)
                                                                                 throws java.lang.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
java.lang.Exception

addToClasspath

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

addToClasspath

protected void addToClasspath(org.apache.maven.artifact.Artifact artifact,
                              java.util.Set<java.lang.String> classpath)
                       throws java.lang.Exception
Throws:
java.lang.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 java.util.List<org.apache.maven.model.Dependency> getDependencies()

checkScalaVersion

protected void checkScalaVersion()
                          throws java.lang.Exception
Throws:
java.lang.Exception

getScalaCommand

protected JavaCommand getScalaCommand()
                               throws java.lang.Exception
Throws:
java.lang.Exception

getEmptyScalaCommand

protected JavaCommand getEmptyScalaCommand(java.lang.String mainClass)
                                    throws java.lang.Exception
Throws:
java.lang.Exception