Package scala_maven
Class ScalaScriptMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
scala_maven.ScalaMojoSupport
scala_maven.ScalaScriptMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="script",
requiresDependencyResolution=RUNTIME,
executionStrategy="always",
threadSafe=true)
public class ScalaScriptMojo
extends ScalaMojoSupport
Run a scala script.
- Since:
- 2.7
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AtomicIntegerprotected StringComma seperated list of directories or jars to add to the classpathprotected StringComma separated list of scopes to remove from the classpath.protected StringComma separated list of scopes to add to the classpath.protected booleanIf set to true the Scala classfile that is generated will not be deleted after the goal completes.protected FileThe build directory of the projectprotected StringComma separated list of directories or jars to remove from the classpath.protected StringThe script that will be executed.protected StringThe encoding of file containing script to be executed.protected FileThe file containing script to be executed.Fields inherited from class scala_maven.ScalaMojoSupport
addJavacArgs, addScalacArgs, args, checkMultipleScalaVersions, compilerPlugins, dependencies, displayCmd, encoding, factory, failOnMultipleScalaVersions, forceUseArgFile, fork, JAR, javacArgs, javacGenerateDebugSymbols, jvmArgs, localRepo, mavenProjectBuilder, POM, project, reactorProjects, remoteRepos, resolver, SCALA_COMPILER_ARTIFACTID, SCALA_LIBRARY_ARTIFACTID, scalaClassName, session, source, target, toolchainManager, useCanonicalPathFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcompileScript(File scriptDir, File destFile, URLClassLoader loader) private voidconfigureClasspath(Set<String> classpath) private URLClassLoadercreateScriptClassloader(File scriptDir, Set<String> classpath) private voidprotected voidprivate voidrunScript(boolean mavenProjectDependency, URLClassLoader loader, String baseName) private static StringscriptBaseNameOf(File scriptFile, int idx) private voidwrapScript(File destFile, boolean mavenProjectDependency) Methods inherited from class scala_maven.ScalaMojoSupport
addCompilerPluginOptions, addCompilerToClasspath, addLibraryToClasspath, addToClasspath, addToClasspath, addToClasspath, addToClasspath, checkScalaVersion, execute, findScalaVersion, findVersionFromDependencies, findVersionFromPluginArtifacts, getAllDependencies, getArtifactJar, getArtifactJar, getCompilerDependencies, getCompilerJar, getCompilerPluginOptions, getDependencies, getEmptyScalaCommand, getEmptyScalaCommand, getJavacOptions, getLibraryJar, getPluginArtifactJar, getPluginArtifactJar, getScalaCommand, getScalaCommand, getScalaOptions, getScalaOrganization, isJavaSupportedByCompiler, resolveArtifactDependencies, resolveDependencyArtifacts, resolveDependencyArtifacts, scalaCompilerArtifactMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
outputDir
The build directory of the project -
scriptFile
The file containing script to be executed. Either 'scriptFile' or 'script' must be defined. -
scriptEncoding
The encoding of file containing script to be executed. -
script
The script that will be executed. Either 'scriptFile' or ' script' must be defined. -
keepGeneratedScript
@Parameter(property="maven.scala.keepGeneratedScript", defaultValue="false") protected boolean keepGeneratedScriptIf 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
Comma separated list of scopes to add to the classpath. The possible scopes are : test,compile, system, runtime, plugin. By default embedded script into pom.xml run with 'plugin' scope and script read from scriptFile run with 'compile, test, runtime' -
excludeScopes
Comma separated list of scopes to remove from the classpath. Eg: test,compile -
addToClasspath
Comma seperated list of directories or jars to add to the classpath -
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 -
_lastScriptIndex
-
-
Constructor Details
-
ScalaScriptMojo
public ScalaScriptMojo()
-
-
Method Details
-
scriptBaseNameOf
-
doExecute
- Specified by:
doExecutein classScalaMojoSupport- Throws:
Exception
-
runScript
private void runScript(boolean mavenProjectDependency, URLClassLoader loader, String baseName) throws Exception - Throws:
Exception
-
createScriptClassloader
private URLClassLoader createScriptClassloader(File scriptDir, Set<String> classpath) throws Exception - Throws:
Exception
-
compileScript
- Throws:
Exception
-
configureClasspath
private void configureClasspath(Set<String> classpath) throws Exception, org.apache.maven.artifact.DependencyResolutionRequiredException - Throws:
Exceptionorg.apache.maven.artifact.DependencyResolutionRequiredException
-
wrapScript
- Throws:
IOException
-
delete
-