Package org.gradle.api.tasks
Class ScalaRuntime
- java.lang.Object
-
- org.gradle.api.tasks.ScalaRuntime
-
@Incubating public class ScalaRuntime extends Object
Provides information related to the Scala runtime(s) used in a project. Added by theorg.gradle.api.plugins.scala.ScalaBasePlugin
as a project extension namedscalaRuntime
.Example usage:
apply plugin: "scala" repositories { mavenCentral() } dependencies { compile "org.scala-lang:scala-library:2.10.1" } def scalaClasspath = scalaRuntime.inferScalaClasspath(configurations.compile) // The returned class path can be used to configure the 'scalaClasspath' property of tasks // such as 'ScalaCompile' or 'ScalaDoc', or to execute these and other Scala tools directly.
-
-
Constructor Summary
Constructors Constructor Description ScalaRuntime(Project project)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description File
findScalaJar(Iterable<File> classpath, String appendix)
Searches the specified class path for a Scala Jar file (scala-compiler, scala-library, scala-jdbc, etc.) with the specified appendix (compiler, library, jdbc, etc.).String
getScalaVersion(File scalaJar)
Determines the version of a Scala Jar file (scala-compiler, scala-library, scala-jdbc, etc.).FileCollection
inferScalaClasspath(Iterable<File> classpath)
Searches the specified class path for a 'scala-library' Jar, and returns a class path containing a corresponding (same version) 'scala-compiler' Jar and its dependencies.
-
-
-
Constructor Detail
-
ScalaRuntime
public ScalaRuntime(Project project)
-
-
Method Detail
-
inferScalaClasspath
public FileCollection inferScalaClasspath(Iterable<File> classpath)
Searches the specified class path for a 'scala-library' Jar, and returns a class path containing a corresponding (same version) 'scala-compiler' Jar and its dependencies.The returned class path may be empty, or may fail to resolve when asked for its contents.
- Parameters:
classpath
- a class path containing a 'scala-library' Jar- Returns:
- a class path containing a corresponding 'scala-compiler' Jar and its dependencies
-
findScalaJar
@Nullable public File findScalaJar(Iterable<File> classpath, String appendix)
Searches the specified class path for a Scala Jar file (scala-compiler, scala-library, scala-jdbc, etc.) with the specified appendix (compiler, library, jdbc, etc.). If no such file is found,null
is returned.- Parameters:
classpath
- the class path to searchappendix
- the appendix to search for- Returns:
- a Scala Jar file with the specified appendix
-
getScalaVersion
@Nullable public String getScalaVersion(File scalaJar)
Determines the version of a Scala Jar file (scala-compiler, scala-library, scala-jdbc, etc.). If the version cannot be determined, or the file is not a Scala Jar file,null
is returned.Implementation note: The version is determined by parsing the file name, which is expected to match the pattern 'scala-[component]-[version].jar'.
- Parameters:
scalaJar
- a Scala Jar file- Returns:
- the version of the Scala Jar file
-
-