Package scala_maven

Class 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 Detail

      • outputDir

        @Parameter(property="project.build.directory")
        protected java.io.File outputDir
        The build directory of the project
      • scriptFile

        @Parameter(property="scriptFile")
        protected java.io.File scriptFile
        The file containing script to be executed. Either 'scriptFile' or 'script' must be defined.
      • scriptEncoding

        @Parameter(property="scriptEncoding",
                   defaultValue="UTF-8")
        protected java.lang.String scriptEncoding
        The encoding of file containing script to be executed.
      • script

        @Parameter(property="script")
        protected java.lang.String script
        The script that will be executed. Either 'scriptFile' or ' script' must be defined.
      • keepGeneratedScript

        @Parameter(property="maven.scala.keepGeneratedScript",
                   defaultValue="false")
        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

        @Parameter(property="maven.scala.includeScopes")
        protected java.lang.String 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

        @Parameter(property="maven.scala.excludeScopes")
        protected java.lang.String excludeScopes
        Comma separated list of scopes to remove from the classpath. Eg: test,compile
      • addToClasspath

        @Parameter(property="addToClasspath")
        protected java.lang.String addToClasspath
        Comma seperated list of directories or jars to add to the classpath
      • removeFromClasspath

        @Parameter(property="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
      • _lastScriptIndex

        private static java.util.concurrent.atomic.AtomicInteger _lastScriptIndex
    • Constructor Detail

      • ScalaScriptMojo

        public ScalaScriptMojo()
    • Method Detail

      • scriptBaseNameOf

        private static java.lang.String scriptBaseNameOf​(java.io.File scriptFile,
                                                         int idx)
      • doExecute

        protected void doExecute()
                          throws java.lang.Exception
        Specified by:
        doExecute in class ScalaMojoSupport
        Throws:
        java.lang.Exception
      • runScript

        private void runScript​(boolean mavenProjectDependency,
                               java.net.URLClassLoader loader,
                               java.lang.String baseName)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createScriptClassloader

        private java.net.URLClassLoader createScriptClassloader​(java.io.File scriptDir,
                                                                java.util.Set<java.lang.String> classpath)
                                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • compileScript

        private void compileScript​(java.io.File scriptDir,
                                   java.io.File destFile,
                                   java.net.URLClassLoader loader)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • configureClasspath

        private void configureClasspath​(java.util.Set<java.lang.String> classpath)
                                 throws java.lang.Exception,
                                        org.apache.maven.artifact.DependencyResolutionRequiredException
        Throws:
        java.lang.Exception
        org.apache.maven.artifact.DependencyResolutionRequiredException
      • wrapScript

        private void wrapScript​(java.io.File destFile,
                                boolean mavenProjectDependency)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • delete

        private void delete​(java.io.File scriptDir)