Jvm

mill.util.Jvm
object Jvm extends CoursierSupport

Attributes

Source
Jvm.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Jvm.type

Members list

Value members

Concrete methods

@Scaladoc(value = "/**\n * Runs a JVM subprocess with the given configuration and returns a\n * [[os.CommandResult]] with it\'s aggregated output and error streams.\n *\n * @param mainClass The main class to run\n * @param mainArgs Args passed to the `mainClass` main method\n * @param javaHome Optional Java Home override\n * @param jvmArgs Arguments given to the forked JVM\n * @param classPath The classpath\n * @param cpPassingJarPath When `None`, the `-cp` parameter is used to pass the classpath\n * to the forked JVM.\n * When `Some`, a temporary empty JAR is created\n * which contains a `Class-Path` manifest entry containing the actual classpath.\n * This might help with long classpaths on OS\'es (like Windows)\n * which only supports limited command-line length\n * @param env Environment variables used when starting the forked JVM\n * @param propagateEnv If `true` then the current process\' environment variables are propagated to subprocess\n * @param cwd The working directory to be used by the forked JVM\n * @param stdin Standard input\n * @param stdout Standard output\n * @param stderr Standard error\n * @param mergeErrIntoOut If `true` then the error output is merged into standard output\n * @param timeout how long to wait in milliseconds for the subprocess to complete (-1 for no timeout)\n * @param shutdownGracePeriod if the timeout is enabled, how long in milliseconds for the subprocess\n * to gracefully terminate before attempting to forcibly kill it\n * (-1 for no kill, 0 for always kill immediately)\n * @param destroyOnExit Destroy on JVM exit\n * @param check if `true`, an exception will be thrown if process exits with a non-zero exit code\n */")
def callProcess(mainClass: String, mainArgs: Iterable[String], javaHome: Option[Path], jvmArgs: Iterable[String], classPath: Iterable[Path], cpPassingJarPath: Option[Path], env: Map[String, String], propagateEnv: Boolean, cwd: Path, stdin: ProcessInput, stdout: ProcessOutput, stderr: ProcessOutput, mergeErrIntoOut: Boolean, timeout: Long, shutdownGracePeriod: Long, destroyOnExit: Boolean, check: Boolean): CommandResult

Runs a JVM subprocess with the given configuration and returns a os.CommandResult with it's aggregated output and error streams.

Runs a JVM subprocess with the given configuration and returns a os.CommandResult with it's aggregated output and error streams.

Value parameters

check

if true, an exception will be thrown if process exits with a non-zero exit code

classPath

The classpath

cpPassingJarPath

When None, the -cp parameter is used to pass the classpath to the forked JVM. When Some, a temporary empty JAR is created which contains a Class-Path manifest entry containing the actual classpath. This might help with long classpaths on OS'es (like Windows) which only supports limited command-line length

cwd

The working directory to be used by the forked JVM

destroyOnExit

Destroy on JVM exit

env

Environment variables used when starting the forked JVM

javaHome

Optional Java Home override

jvmArgs

Arguments given to the forked JVM

mainArgs

Args passed to the mainClass main method

mainClass

The main class to run

mergeErrIntoOut

If true then the error output is merged into standard output

propagateEnv

If true then the current process' environment variables are propagated to subprocess

shutdownGracePeriod

if the timeout is enabled, how long in milliseconds for the subprocess to gracefully terminate before attempting to forcibly kill it (-1 for no kill, 0 for always kill immediately)

stderr

Standard error

stdin

Standard input

stdout

Standard output

timeout

how long to wait in milliseconds for the subprocess to complete (-1 for no timeout)

Attributes

Source
Jvm.scala
@Scaladoc(value = "/**\n * Creates a `java.net.URLClassLoader` with specified parameters\n * @param classPath URLs from which to load classes and resources\n * @param parent parent class loader for delegation\n * @param sharedLoader loader used for shared classes\n * @param sharedPrefixes package prefix for classes that will be loaded by the `sharedLoader`\n * @return new classloader\n */")
def createClassLoader(classPath: Iterable[Path], parent: ClassLoader, sharedLoader: ClassLoader, sharedPrefixes: Iterable[String]): URLClassLoader

Creates a java.net.URLClassLoader with specified parameters

Creates a java.net.URLClassLoader with specified parameters

Value parameters

classPath

URLs from which to load classes and resources

parent

parent class loader for delegation

sharedLoader

loader used for shared classes

sharedPrefixes

package prefix for classes that will be loaded by the sharedLoader

Attributes

Returns

new classloader

Source
Jvm.scala
def createClasspathPassingJar(jar: Path, classpath: Seq[Path]): Unit

Attributes

Source
Jvm.scala
@Scaladoc(value = "/**\n * Create a JAR file with default inflation level.\n *\n * @param jar The final JAR file\n * @param inputPaths The input paths resembling the content of the JAR file.\n * Files will be directly included in the root of the archive,\n * whereas for directories their content is added to the root of the archive.\n * @param manifest The JAR Manifest\n * @param fileFilter A filter to support exclusions of selected files\n * @param includeDirs If `true` the JAR archive will contain directory entries.\n * According to the ZIP specification, directory entries are not required.\n * In the Java ecosystem, most JARs have directory entries, so including them may reduce compatibility issues.\n * Directory entry names will result with a trailing `/`.\n * @param timestamp If specified, this timestamp is used as modification timestamp (mtime) for all entries in the JAR file.\n * Having a stable timestamp may result in reproducible files, if all other content, including the JAR Manifest, keep stable.\n */")
def createJar(jar: Path, inputPaths: Seq[Path], manifest: JarManifest, fileFilter: (Path, RelPath) => Boolean, includeDirs: Boolean, timestamp: Option[Long]): Path

Create a JAR file with default inflation level.

Create a JAR file with default inflation level.

Value parameters

fileFilter

A filter to support exclusions of selected files

includeDirs

If true the JAR archive will contain directory entries. According to the ZIP specification, directory entries are not required. In the Java ecosystem, most JARs have directory entries, so including them may reduce compatibility issues. Directory entry names will result with a trailing /.

inputPaths

The input paths resembling the content of the JAR file. Files will be directly included in the root of the archive, whereas for directories their content is added to the root of the archive.

jar

The final JAR file

manifest

The JAR Manifest

timestamp

If specified, this timestamp is used as modification timestamp (mtime) for all entries in the JAR file. Having a stable timestamp may result in reproducible files, if all other content, including the JAR Manifest, keep stable.

Attributes

Source
Jvm.scala
def createLauncher(mainClass: String, classPath: Seq[Path], jvmArgs: Seq[String])(implicit ctx: Dest): PathRef

Attributes

Source
Jvm.scala
def createManifest(mainClass: Option[String]): JarManifest

Attributes

Source
Jvm.scala
def javaExe(javaHome: Option[Path]): String

Attributes

Source
Jvm.scala
def javaExe: String

Attributes

Source
Jvm.scala
@Scaladoc(value = "/**\n * Resolves a tool to a path under the currently used JDK (if known).\n */")
def jdkTool(toolName: String, javaHome: Option[Path]): String

Resolves a tool to a path under the currently used JDK (if known).

Resolves a tool to a path under the currently used JDK (if known).

Attributes

Source
Jvm.scala
def jdkTool(toolName: String): String

Attributes

Source
Jvm.scala
def launcherUniversalScript(mainClass: String, shellClassPath: Seq[String], cmdClassPath: Seq[String], jvmArgs: Seq[String], shebang: Boolean, shellJvmArgs: Seq[String], cmdJvmArgs: Seq[String]): String

Attributes

Source
Jvm.scala
@Scaladoc(value = "/**\n * Runs a JVM subprocess with the given configuration and streams\n * it\'s stdout and stderr to the console.\n *\n * @param mainClass The main class to run\n * @param mainArgs Args passed to the `mainClass` main method\n * @param javaHome Optional Java Home override\n * @param jvmArgs Arguments given to the forked JVM\n * @param classPath The classpath\n * @param cpPassingJarPath When `None`, the `-cp` parameter is used to pass the classpath\n * to the forked JVM.\n * When `Some`, a temporary empty JAR is created\n * which contains a `Class-Path` manifest entry containing the actual classpath.\n * This might help with long classpaths on OS\'es (like Windows)\n * which only supports limited command-line length\n * @param env Environment variables used when starting the forked JVM\n * @param propagateEnv If `true` then the current process\' environment variables are propagated to subprocess\n * @param cwd The working directory to be used by the forked JVM\n * @param stdin Standard input override\n * @param stdout Standard output override\n * @param stderr Standard error override\n * @param mergeErrIntoOut If `true` then the error output is merged into standard output\n * @param shutdownGracePeriod if the timeout is enabled, how long in milliseconds for the subprocess\n * to gracefully terminate before attempting to forcibly kill it\n * (-1 for no kill, 0 for always kill immediately)\n * @param destroyOnExit Destroy on JVM exit\n */")
def spawnProcess(mainClass: String, mainArgs: Iterable[String], javaHome: Option[Path], jvmArgs: Iterable[String], classPath: Iterable[Path], cpPassingJarPath: Option[Path], env: Map[String, String], propagateEnv: Boolean, cwd: Path, stdin: ProcessInput, stdout: ProcessOutput, stderr: ProcessOutput, mergeErrIntoOut: Boolean, shutdownGracePeriod: Long, destroyOnExit: Boolean): SubProcess

Runs a JVM subprocess with the given configuration and streams it's stdout and stderr to the console.

Runs a JVM subprocess with the given configuration and streams it's stdout and stderr to the console.

Value parameters

classPath

The classpath

cpPassingJarPath

When None, the -cp parameter is used to pass the classpath to the forked JVM. When Some, a temporary empty JAR is created which contains a Class-Path manifest entry containing the actual classpath. This might help with long classpaths on OS'es (like Windows) which only supports limited command-line length

cwd

The working directory to be used by the forked JVM

destroyOnExit

Destroy on JVM exit

env

Environment variables used when starting the forked JVM

javaHome

Optional Java Home override

jvmArgs

Arguments given to the forked JVM

mainArgs

Args passed to the mainClass main method

mainClass

The main class to run

mergeErrIntoOut

If true then the error output is merged into standard output

propagateEnv

If true then the current process' environment variables are propagated to subprocess

shutdownGracePeriod

if the timeout is enabled, how long in milliseconds for the subprocess to gracefully terminate before attempting to forcibly kill it (-1 for no kill, 0 for always kill immediately)

stderr

Standard error override

stdin

Standard input override

stdout

Standard output override

Attributes

Source
Jvm.scala
def universalScript(shellCommands: String, cmdCommands: String, shebang: Boolean): String

Attributes

Source
Jvm.scala
@Scaladoc(value = "/**\n * @param classPath URLs from which to load classes and resources\n * @param parent parent class loader for delegation\n * @param sharedPrefixes package prefix for classes that will be loaded by the shared loader\n * @param f function that will be called with newly created classloader\n * @tparam T the return type of this function\n * @return return value of the function `f`\n */")
def withClassLoader[T](classPath: Iterable[Path], parent: ClassLoader, sharedPrefixes: Seq[String])(f: ClassLoader => T): T

Type parameters

T

the return type of this function

Value parameters

classPath

URLs from which to load classes and resources

f

function that will be called with newly created classloader

parent

parent class loader for delegation

sharedPrefixes

package prefix for classes that will be loaded by the shared loader

Attributes

Returns

return value of the function f

Source
Jvm.scala

Inherited methods

def jvmIndex(ctx: Option[Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]]): JvmIndex

Attributes

Inherited from:
CoursierSupport
Source
CoursierSupport.scala
def jvmIndex0(ctx: Option[Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], jvmIndexVersion: String): Task[JvmIndex]

Attributes

Inherited from:
CoursierSupport
Source
CoursierSupport.scala
@Scaladoc(value = "/**\n * Resolve dependencies using Coursier.\n *\n * We do not bother breaking this out into the separate ZincWorkerApi classpath,\n * because Coursier is already bundled with mill/Ammonite to support the\n * `import $ivy` syntax.\n */")
def resolveDependencies(repositories: Seq[Repository], deps: IterableOnce[Dependency], force: IterableOnce[Dependency], sources: Boolean, mapDependencies: Option[Dependency => Dependency], customizer: Option[Resolution => Resolution], ctx: Option[Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], artifactTypes: Option[Set[Type]], resolutionParams: ResolutionParams): Result[Seq[PathRef]]

Resolve dependencies using Coursier.

Resolve dependencies using Coursier.

We do not bother breaking this out into the separate ZincWorkerApi classpath, because Coursier is already bundled with mill/Ammonite to support the import $ivy syntax.

Attributes

Inherited from:
CoursierSupport
Source
CoursierSupport.scala
def resolveDependenciesMetadataSafe(repositories: Seq[Repository], deps: IterableOnce[Dependency], force: IterableOnce[Dependency], mapDependencies: Option[Dependency => Dependency], customizer: Option[Resolution => Resolution], ctx: Option[Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], resolutionParams: ResolutionParams, boms: IterableOnce[BomDependency]): Result[Resolution]

Attributes

Inherited from:
CoursierSupport
Source
CoursierSupport.scala
@Scaladoc(value = "/**\n * Resolve java home using Coursier.\n *\n * The id string has format \"$DISTRIBUTION:$VERSION\". e.g. graalvm-community:23.0.0\n */")
def resolveJavaHome(id: String, ctx: Option[Log], coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]], jvmIndexVersion: String): Result[Path]

Resolve java home using Coursier.

Resolve java home using Coursier.

The id string has format "$DISTRIBUTION:$VERSION". e.g. graalvm-community:23.0.0

Attributes

Inherited from:
CoursierSupport
Source
CoursierSupport.scala