Package scala_maven
Class ScalaMojoSupport
java.lang.Object
org.apache.maven.plugin.AbstractMojo
scala_maven.ScalaMojoSupport
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ScalaConsoleMojo,ScalaHelpMojo,ScalaRunMojo,ScalaScriptMojo,ScalaSourceMojoSupport
public abstract class ScalaMojoSupport
extends org.apache.maven.plugin.AbstractMojo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate VersionNumberprotected StringAlternative method for specifying javac arguments (when using incremental compiler).protected StringAdditional parameter to use to call the main class.protected String[]compiler additional argumentsprivate org.apache.maven.artifact.resolver.ArtifactCollectorThe artifact collector to use.private org.apache.maven.artifact.factory.ArtifactFactoryThe artifact factory to use.private org.apache.maven.artifact.metadata.ArtifactMetadataSourceThe artifact metadata source to use.protected booleanCheck if every dependencies use the same version of scala-library or scala.compat.version.protected BasicArtifact[]Compiler plugin dependencies to use when compiling.protected BasicArtifact[]Additional dependencies/jar to add to classpath to run "scalaClassName" (scope and optional field not supported) ex :private org.apache.maven.shared.dependency.graph.DependencyGraphBuilderThe dependency tree builder to use.booleanDisplay the command line called ? (property 'maven.scala.displayCmd' replaced by 'displayCmd')protected StringThe -encoding argument for the Java compiler.protected org.apache.maven.repository.RepositorySystemUsed to look up Artifacts in the remote repository.protected booleanDetermines if a detection of multiple scala versions in the dependencies will cause the build to fail.protected booleanForce the use of an external ArgFile to run any forked process.protected booleanForks the execution of scalac into a separate process.protected static final StringConstantStringfor "jar".protected String[]Arguments for javac (when using incremental compiler).protected booleanWhether to instruct javac to generate debug symbols (when using incremental compiler)protected String[]Jvm Arguments.protected org.apache.maven.artifact.repository.ArtifactRepositoryLocation of the local repository.private org.apache.maven.artifact.repository.ArtifactRepositoryThe artifact repository to use.protected org.apache.maven.project.MavenProjectBuilderArtifact factory, needed to download source jars.private List<org.apache.maven.artifact.Artifact> List of artifacts to run pluginprotected static final StringConstantStringfor "pom".protected org.apache.maven.project.MavenProjectThe maven project.protected List<org.apache.maven.project.MavenProject> Contains the full list of projects in the reactor.protected List<org.apache.maven.artifact.repository.ArtifactRepository> List of Remote Repositories used by the resolverprotected org.apache.maven.artifact.resolver.ArtifactResolverUsed to look up Artifacts in the remote repository.static final Stringstatic final Stringprotected StringclassName (FQN) of the scala tool to provide asprivate StringScala 's version to use to check binary compatibility (like suffix in artifactId of dependency).private StringPath to Scala installation to use instead of the artifact (define as dependencies).private StringOrganization/group ID of the Scala used in the project.private StringScala 's version to use.protected org.apache.maven.execution.MavenSessionThe Maven Session Objectprotected StringThe -source argument for the Java compiler (when using incremental compiler).protected StringThe -target argument for the Java compiler (when using incremental compiler).protected org.apache.maven.toolchain.ToolchainManagerThe toolchain manager to use.protected booleanShould use CanonicalPath to normalize path (true => getCanonicalPath, false => getAbsolutePath)Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds appropriate compiler plugins to the scalac command.protected voidaddCompilerToClasspath(Set<String> classpath) protected voidaddLibraryToClasspath(Set<String> classpath) voidaddToClasspath(String groupId, String artifactId, String version, String classifier, Set<String> classpath, boolean addDependencies) added for classifier support.voidvoidaddToClasspath(String groupId, String artifactId, String version, Set<String> classpath, boolean addDependencies) protected voidaddToClasspath(org.apache.maven.artifact.Artifact artifact, Set<String> classpath, boolean addDependencies) private voidcheckArtifactForScalaVersion(VersionNumber requiredScalaVersion, org.apache.maven.shared.dependency.graph.DependencyNode rootNode) Visits a node (and all dependencies) to see if it contains duplicate scala versionsprivate voidcheckCorrectVersionsOfScalaLibrary(String scalaDefVersion) this method checks to see if there are multiple versions of the scala libraryprotected voidprivate org.apache.maven.artifact.resolver.ArtifactResolutionRequestcreateArtifactResolutionRequest(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) Create aArtifactResolutionRequest.private org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilterprotected abstract voidvoidexecute()protected VersionNumberprivate Stringprotected StringfindVersionFromDependencies(String groupId, String artifactId) protected StringfindVersionFromPluginArtifacts(String groupId, String artifactId) protected Set<org.apache.maven.artifact.Artifact> getAllDependencies(String groupId, String artifactId, String version) protected FilegetArtifactJar(String groupId, String artifactId, String version) protected FilegetArtifactJar(String groupId, String artifactId, String version, String classifier) protected FileRetrieves a list of paths to scala compiler plugins.protected List<org.apache.maven.model.Dependency> protected final JavaMainCallergetEmptyScalaCommand(String mainClass) Get aJavaMainCallerused invoke a Java process.protected JavaMainCallergetEmptyScalaCommand(String mainClass, boolean forkOverride) Get aJavaMainCallerused invoke a Java process.protected Fileprotected FilegetPluginArtifactJar(String groupId, String artifactId, String version) protected FilegetPluginArtifactJar(String groupId, String artifactId, String version, String classifier) protected JavaMainCallerprotected final JavaMainCallergetScalaCommand(boolean forkOverride, String mainClass) Get aJavaMainCallerused invoke a Java process.private Stringprotected booleanprotected final Set<org.apache.maven.artifact.Artifact> resolveArtifactDependencies(org.apache.maven.artifact.Artifact artifact) This method resolves all transitive dependencies of an artifact.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) This method resolves all transitive dependencies of an artifact.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) This method resolves all transitive dependencies of an artifact.protected final org.apache.maven.artifact.ArtifactscalaCompilerArtifact(String scalaVersion) Constructs anArtifactfor Scala Compiler.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
SCALA_LIBRARY_ARTIFACTID
- See Also:
-
SCALA_COMPILER_ARTIFACTID
- See Also:
-
POM
ConstantStringfor "pom". Used to specify the Maven POM artifact type.- See Also:
-
JAR
ConstantStringfor "jar". Used to specify the Maven JAR artifact type.- See Also:
-
project
@Parameter(property="project", required=true, readonly=true) protected org.apache.maven.project.MavenProject projectThe maven project. -
session
@Parameter(property="session", required=true, readonly=true) protected org.apache.maven.execution.MavenSession sessionThe Maven Session Object -
reactorProjects
@Parameter(defaultValue="${reactorProjects}", readonly=true, required=true) protected List<org.apache.maven.project.MavenProject> reactorProjectsContains the full list of projects in the reactor. -
factory
@Component protected org.apache.maven.repository.RepositorySystem factoryUsed to look up Artifacts in the remote repository. -
resolver
@Component protected org.apache.maven.artifact.resolver.ArtifactResolver resolverUsed to look up Artifacts in the remote repository. -
localRepo
@Parameter(property="localRepository", readonly=true, required=true) protected org.apache.maven.artifact.repository.ArtifactRepository localRepoLocation of the local repository. -
remoteRepos
@Parameter(property="project.remoteArtifactRepositories", readonly=true, required=true) protected List<org.apache.maven.artifact.repository.ArtifactRepository> remoteReposList of Remote Repositories used by the resolver -
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
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
Jvm Arguments. -
args
compiler additional arguments -
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 scalaClassNameclassName (FQN) of the scala tool to provide as -
scalaVersion
Scala 's version to use. (property 'maven.scala.version' replaced by 'scala.version') -
scalaOrganization
@Parameter(property="scala.organization", defaultValue="org.scala-lang") private String scalaOrganizationOrganization/group ID of the Scala used in the project. Default value is 'org.scala-lang'. This is an advanced setting used for clones of the Scala Language. It should be disregarded in standard use cases. -
scalaCompatVersion
Scala 's version to use to check binary compatibility (like suffix in artifactId of dependency). If it is defined then it is used to checkMultipleScalaVersions -
scalaHome
Path to Scala installation to use instead of the artifact (define as dependencies). -
javacArgs
Arguments for javac (when using incremental compiler). -
javacGenerateDebugSymbols
@Parameter(property="javacGenerateDebugSymbols", defaultValue="true") protected boolean javacGenerateDebugSymbolsWhether to instruct javac to generate debug symbols (when using incremental compiler)- See Also:
-
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
The -source argument for the Java compiler (when using incremental compiler). -
target
The -target argument for the Java compiler (when using incremental compiler). -
encoding
The -encoding argument for the Java compiler. (when using incremental compiler). -
displayCmd
@Parameter(property="displayCmd", defaultValue="false", required=true) public boolean displayCmdDisplay the command line called ? (property 'maven.scala.displayCmd' replaced by 'displayCmd') -
fork
@Parameter(defaultValue="true") protected boolean forkForks the execution of scalac into a separate process. -
forceUseArgFile
@Parameter(defaultValue="false") protected boolean forceUseArgFileForce the use of an external ArgFile to run any forked process. -
checkMultipleScalaVersions
@Parameter(property="maven.scala.checkConsistency", defaultValue="true") protected boolean checkMultipleScalaVersionsCheck if every dependencies use the same version of scala-library or scala.compat.version. -
failOnMultipleScalaVersions
@Parameter(defaultValue="false") protected boolean failOnMultipleScalaVersionsDetermines 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 useCanonicalPathShould use CanonicalPath to normalize path (true => getCanonicalPath, false => getAbsolutePath)- See Also:
-
mavenProjectBuilder
@Component protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilderArtifact factory, needed to download source jars. -
localRepository
@Parameter(property="localRepository", required=true, readonly=true) private org.apache.maven.artifact.repository.ArtifactRepository localRepositoryThe artifact repository to use. -
artifactFactory
@Component private org.apache.maven.artifact.factory.ArtifactFactory artifactFactoryThe artifact factory to use. -
artifactMetadataSource
@Component private org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSourceThe artifact metadata source to use. -
artifactCollector
@Component private org.apache.maven.artifact.resolver.ArtifactCollector artifactCollectorThe artifact collector to use. -
dependencyTreeBuilder
@Component private org.apache.maven.shared.dependency.graph.DependencyGraphBuilder dependencyTreeBuilderThe dependency tree builder to use. -
toolchainManager
@Component protected org.apache.maven.toolchain.ToolchainManager toolchainManagerThe toolchain manager to use. -
pluginArtifacts
@Parameter(defaultValue="${plugin.artifacts}") private List<org.apache.maven.artifact.Artifact> pluginArtifactsList of artifacts to run plugin -
_scalaVersionN
-
-
Constructor Details
-
ScalaMojoSupport
public ScalaMojoSupport()
-
-
Method Details
-
getScalaOrganization
-
scalaCompilerArtifact
Constructs anArtifactfor Scala Compiler.- Parameters:
scalaVersion- the version of the Scala Compiler/Library we are using for this execution.- Returns:
- a
Artifactfor 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. -
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- theArtifactused to retrieve dependencies.collectionFilter- anArtifactFilterused to determine which members of the dependency graph should be included in resolution.collectionFilter- anArtifactFilterused to determine which members dependency graph should be downloaded.- Returns:
- resolved
Setof 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- theArtifactused to retrieve dependencies.collectionFilter- anArtifactFilterused to determine which members of the dependency graph should be included in resolution.remoteRepositories- aListof remotevalues to used for dependency resolution of the providedinvalid reference
ArtifactRespositoryArtifact.localRepository- the localArtifactRepositoryto use for dependency resolution of the givenArtifact.collectionFilter- anArtifactFilterused to determine which members dependency graph should be downloaded.- Returns:
- resolved
Setof dependencies. - Throws:
Exception
-
createArtifactResolutionRequest
private org.apache.maven.artifact.resolver.ArtifactResolutionRequest createArtifactResolutionRequest(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) Create aArtifactResolutionRequest.- Parameters:
artifact- theArtifactused to retrieve dependencies.collectionFilter- anArtifactFilterused to determine which members of the dependency graph should be included in resolution.remoteRepositories- aListof remotevalues to used for dependency resolution of the providedinvalid reference
ArtifactRespositoryArtifact.localRepository- the localArtifactRepositoryto use for dependency resolution of the givenArtifact.collectionFilter- anArtifactFilterused to determine which members dependency graph should be downloaded.- Returns:
- an
ArtifactResolutionRequest, typically used for dependency resolution requests against anArtifactResolver.
-
addToClasspath
public void addToClasspath(String groupId, String artifactId, String version, Set<String> classpath) throws Exception - Throws:
Exception
-
addToClasspath
public void addToClasspath(String groupId, String artifactId, String version, Set<String> classpath, boolean addDependencies) throws Exception - Throws:
Exception
-
addToClasspath
public void addToClasspath(String groupId, String artifactId, String version, String classifier, Set<String> classpath, boolean addDependencies) throws Exception added for classifier support.- Throws:
Exception
-
addToClasspath
protected void addToClasspath(org.apache.maven.artifact.Artifact artifact, Set<String> classpath, boolean addDependencies) throws Exception - Throws:
Exception
-
addCompilerToClasspath
- Throws:
Exception
-
addLibraryToClasspath
- Throws:
Exception
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getDependencies
-
findScalaVersion
- Throws:
Exception
-
findScalaVersionFromDependencies
- Throws:
Exception
-
findVersionFromDependencies
- Throws:
Exception
-
checkScalaVersion
- Throws:
Exception
-
checkCorrectVersionsOfScalaLibrary
this method checks to see if there are multiple versions of the scala library- Throws:
Exception
-
createScalaDistroDependencyFilter
private org.apache.maven.shared.dependency.graph.filter.DependencyNodeFilter createScalaDistroDependencyFilter()- Returns:
- A filter to only extract artifacts deployed from scala distributions
-
doExecute
- Throws:
Exception
-
getScalaCommand
- Throws:
Exception
-
getScalaCommand
protected final JavaMainCaller getScalaCommand(boolean forkOverride, String mainClass) throws Exception Get aJavaMainCallerused invoke a Java process. Typically this will be one of the Scala utilities (Compiler, ScalaDoc, REPL, etc.).This method does some setup on the
JavaMainCallerwhich is not done by merely invokingnewon 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 forfork. Currently this should only be set if you are invoking the REPL.mainClass- the JVM main class to invoke.- Returns:
- a
JavaMainCallerto use to invoke the given command. - Throws:
Exception
-
getEmptyScalaCommand
Get aJavaMainCallerused 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
JavaMainCallerto use to invoke the given command. - Throws:
Exception
-
getEmptyScalaCommand
protected JavaMainCaller getEmptyScalaCommand(String mainClass, boolean forkOverride) throws Exception Get aJavaMainCallerused 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 forfork. Currently this should only be set if you are invoking the REPL.- Returns:
- a
JavaMainCallerto use to invoke the given command. - Throws:
Exception
-
getToolClasspath
- Throws:
Exception
-
getScalaOptions
- Throws:
Exception
-
getJavacOptions
- Throws:
Exception
-
getLibraryJar
- Throws:
Exception
-
getCompilerJar
- Throws:
Exception
-
getCompilerDependencies
- Throws:
Exception
-
getArtifactJar
- Throws:
Exception
-
getArtifactJar
protected File getArtifactJar(String groupId, String artifactId, String version, String classifier) throws Exception - Throws:
Exception
-
getAllDependencies
protected Set<org.apache.maven.artifact.Artifact> getAllDependencies(String groupId, String artifactId, String version) throws Exception - Throws:
Exception
-
isJavaSupportedByCompiler
- Returns:
- This returns whether or not the scala version can support having java sent into the compiler
- Throws:
Exception
-
addCompilerPluginOptions
Adds appropriate compiler plugins to the scalac command.- Parameters:
scalac-- Throws:
Exception
-
getCompilerPluginOptions
- Throws:
Exception
-
getCompilerPlugins
Retrieves a list of paths to scala compiler plugins.- Returns:
- The list of plugins
- Throws:
Exception
-
findVersionFromPluginArtifacts
- Throws:
Exception
-
getPluginArtifactJar
protected File getPluginArtifactJar(String groupId, String artifactId, String version) throws Exception - Throws:
Exception
-
getPluginArtifactJar
protected File getPluginArtifactJar(String groupId, String artifactId, String version, String classifier) throws Exception - Throws:
Exception
-