Package scala_maven

Class ScalaMojoSupport

    • Field Detail

      • project

        @Parameter(property="project",
                   required=true,
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        The maven project.
      • session

        @Parameter(property="session",
                   required=true,
                   readonly=true)
        protected org.apache.maven.execution.MavenSession session
        The Maven Session Object
      • reactorProjects

        @Parameter(defaultValue="${reactorProjects}",
                   readonly=true,
                   required=true)
        protected List<org.apache.maven.project.MavenProject> reactorProjects
        Contains the full list of projects in the reactor.
      • factory

        @Component
        protected org.apache.maven.repository.RepositorySystem factory
        Used to look up Artifacts in the remote repository.
      • resolver

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

        @Parameter(property="localRepository",
                   readonly=true,
                   required=true)
        protected org.apache.maven.artifact.repository.ArtifactRepository localRepo
        Location of the local repository.
      • remoteRepos

        @Parameter(property="project.remoteArtifactRepositories",
                   readonly=true,
                   required=true)
        protected List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepos
        List of Remote Repositories used by the resolver
      • dependencies

        @Parameter
        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

        @Parameter
        protected BasicArtifact[] compilerPlugins
        Compiler plugin dependencies to use when compiling. ex:
         <compilerPlugins>
           <compilerPlugin>
             <groupId>my.scala.plugin</groupId>
             <artifactId>amazingPlugin</artifactId>
             <version>1.0-SNAPSHOT</version>
           </compilerPlugin>
         </compilerPlugins>
         
      • jvmArgs

        @Parameter
        protected String[] jvmArgs
        Jvm Arguments.
      • args

        @Parameter
        protected String[] args
        compiler additional arguments
      • addScalacArgs

        @Parameter(property="addScalacArgs")
        protected String addScalacArgs
        Additional parameter to use to call the main class. Use this parameter only from command line ("-DaddScalacArgs=arg1|arg2|arg3|..."), not from pom.xml. To define compiler arguments in pom.xml see the "args" parameter.
      • scalaClassName

        @Parameter(required=true,
                   property="maven.scala.className",
                   defaultValue="scala.tools.nsc.Main")
        protected String scalaClassName
        className (FQN) of the scala tool to provide as
      • javacArgs

        @Parameter(property="javacArgs")
        protected String[] javacArgs
        Arguments for javac (when using incremental compiler).
      • addJavacArgs

        @Parameter(property="addJavacArgs")
        protected String addJavacArgs
        Alternative method for specifying javac arguments (when using incremental compiler). Can be used from command line with -DaddJavacArgs=arg1|arg2|arg3|... rather than in pom.xml.
      • source

        @Parameter(property="maven.compiler.source")
        protected String source
        The -source argument for the Java compiler (when using incremental compiler).
      • target

        @Parameter(property="maven.compiler.target")
        protected String target
        The -target argument for the Java compiler (when using incremental compiler).
      • encoding

        @Parameter(property="project.build.sourceEncoding",
                   defaultValue="UTF-8")
        protected String encoding
        The -encoding argument for the Java compiler. (when using incremental compiler).
      • displayCmd

        @Parameter(property="displayCmd",
                   defaultValue="false",
                   required=true)
        public boolean displayCmd
        Display the command line called ? (property 'maven.scala.displayCmd' replaced by 'displayCmd')
      • fork

        @Parameter(defaultValue="true")
        protected boolean fork
        Forks the execution of scalac into a separate process.
      • forceUseArgFile

        @Parameter(defaultValue="false")
        protected boolean forceUseArgFile
        Force the use of an external ArgFile to run any forked process.
      • checkMultipleScalaVersions

        @Parameter(property="maven.scala.checkConsistency",
                   defaultValue="true")
        protected boolean checkMultipleScalaVersions
        Check if every dependencies use the same version of scala-library or scala.compat.version.
      • failOnMultipleScalaVersions

        @Parameter(defaultValue="false")
        protected boolean failOnMultipleScalaVersions
        Determines if a detection of multiple scala versions in the dependencies will cause the build to fail.
      • useCanonicalPath

        @Parameter(property="maven.scala.useCanonicalPath",
                   defaultValue="true")
        protected boolean useCanonicalPath
        Should use CanonicalPath to normalize path (true => getCanonicalPath, false => getAbsolutePath)
        See Also:
        https://github.com/davidB/maven-scala-plugin/issues/50
      • mavenProjectBuilder

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

        @Component
        protected org.apache.maven.toolchain.ToolchainManager toolchainManager
        The toolchain manager to use.
    • Constructor Detail

      • ScalaMojoSupport

        public ScalaMojoSupport()
    • Method Detail

      • getScalaOrganization

        public String getScalaOrganization()
      • scalaCompilerArtifact

        protected final org.apache.maven.artifact.Artifact scalaCompilerArtifact​(String scalaVersion)
        Constructs an Artifact for Scala Compiler.
        Parameters:
        scalaVersion - the version of the Scala Compiler/Library we are using for this execution.
        Returns:
        a Artifact for the Scala Compiler.
      • resolveArtifactDependencies

        protected final 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:
        Exception
      • resolveDependencyArtifacts

        protected final Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts​(org.apache.maven.artifact.Artifact artifact,
                                                                                           org.apache.maven.artifact.resolver.filter.ArtifactFilter collectionFilter,
                                                                                           org.apache.maven.artifact.resolver.filter.ArtifactFilter resolutionFilter)
                                                                                    throws Exception
        This method resolves all transitive dependencies of an artifact.
        Parameters:
        artifact - the Artifact used to retrieve dependencies.
        collectionFilter - an ArtifactFilter used to determine which members of the dependency graph should be included in resolution.
        collectionFilter - an ArtifactFilter used to determine which members dependency graph should be downloaded.
        Returns:
        resolved Set of dependencies.
        Throws:
        Exception
      • resolveDependencyArtifacts

        protected final Set<org.apache.maven.artifact.Artifact> resolveDependencyArtifacts​(org.apache.maven.artifact.Artifact artifact,
                                                                                           org.apache.maven.artifact.resolver.filter.ArtifactFilter collectionFilter,
                                                                                           org.apache.maven.artifact.resolver.filter.ArtifactFilter resolutionFilter,
                                                                                           List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories,
                                                                                           org.apache.maven.artifact.repository.ArtifactRepository localRepository)
                                                                                    throws Exception
        This method resolves all transitive dependencies of an artifact.
        Parameters:
        artifact - the Artifact used to retrieve dependencies.
        collectionFilter - an ArtifactFilter used to determine which members of the dependency graph should be included in resolution.
        collectionFilter - an ArtifactFilter used to determine which members dependency graph should be downloaded.
        remoteRepositories - a List of remote ArtifactRespository values to used for dependency resolution of the provided Artifact.
        localRepository - the local ArtifactRepository to use for dependency resolution of the given Artifact.
        Returns:
        resolved Set of dependencies.
        Throws:
        Exception
      • addToClasspath

        protected void addToClasspath​(org.apache.maven.artifact.Artifact artifact,
                                      Set<String> classpath,
                                      boolean addDependencies)
                               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 final JavaMainCaller getScalaCommand​(boolean forkOverride,
                                                       String mainClass)
                                                throws Exception
        Get a JavaMainCaller used invoke a Java process. Typically this will be one of the Scala utilities (Compiler, ScalaDoc, REPL, etc.).

        This method does some setup on the JavaMainCaller which is not done by merely invoking new on one of the implementations. Specifically, it adds any Scala compiler plugin options, JVM options, and Scalac options defined on the plugin.

        Parameters:
        forkOverride - override the setting for fork. Currently this should only be set if you are invoking the REPL.
        mainClass - the JVM main class to invoke.
        Returns:
        a JavaMainCaller to use to invoke the given command.
        Throws:
        Exception
      • getEmptyScalaCommand

        protected final JavaMainCaller getEmptyScalaCommand​(String mainClass)
                                                     throws Exception
        Get a JavaMainCaller used invoke a Java process. Typically this will be one of the Scala utilities (Compiler, ScalaDoc, REPL, etc.).
        Parameters:
        mainClass - the JVM main class to invoke.
        Returns:
        a JavaMainCaller to use to invoke the given command.
        Throws:
        Exception
      • getEmptyScalaCommand

        protected JavaMainCaller getEmptyScalaCommand​(String mainClass,
                                                      boolean forkOverride)
                                               throws Exception
        Get a JavaMainCaller used invoke a Java process. Typically this will be one of the Scala utilities (Compiler, ScalaDoc, REPL, etc.).
        Parameters:
        mainClass - the JVM main class to invoke.
        forkOverride - override the setting for fork. Currently this should only be set if you are invoking the REPL.
        Returns:
        a JavaMainCaller to use to invoke the given command.
        Throws:
        Exception
      • isJavaSupportedByCompiler

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

        protected void addCompilerPluginOptions​(JavaMainCaller scalac)
                                         throws Exception
        Adds appropriate compiler plugins to the scalac command.
        Parameters:
        scalac -
        Throws:
        Exception