This is a simple Gradle library/plugin for configuring the right Java toolchain and command line flags for a specific MPS version.
plugins {
id("de.itemis.mps.gradle.launcher")
}
val mpsHome: Provider<File> = ...
val mpsHome: Provider<File> = provider { ... }
tasks.register("myBackendTask", JavaExec::class.java) {
mpsBackendLauncher.builder()
.withMpsHome(mpsHome)
.withMpsVersion(mpsVersion) // Optionally specify the MPS version explicitly
.withJetBrainsJvm() // Optionally request a JetBrains JBR (and fail if it's not available)
.withTemporaryDirectory(mpsTempDir) // Optionally override the directory where MPS will place its logs and caches.
.configure(this)
// Further configuration goes here
}
The configure
method accepts any JavaForkOptions
implementation, such as a JavaExec
or Test
task, or
the project.javaexec
operation. When a task is configured, the temporary directory of the task is used by default
for MPS caches and logs, otherwise it must be set explicitly by withTemporaryDirectory()
.
The plugin will configure the following:
- The correct JVM for the MPS version (using Gradle's JVM toolchain support).
- Additional JVM arguments such as
--add-opens
or-Djna.boot.library.path
, as necessary for a particular MPS version.
For all versions of MPS:
- Working directory is set to the temporary directory of the task (
build/tmp/TASK-NAME
) or the specified directory. idea.config.path
andidea.system.path
JVM properties are set to subdirectories within the temporary directory.
These changes help isolate individual tasks from each other, potentially enabling parallel execution of tasks.
If you need to override the JVM after it was configured by the backend builder, you have the following options.
-
For
JavaExec
task:- Set
javaLauncher
to a different launcher:mpsBackendBuilder .withMpsHome(...) ... .configure(task); task.getJavaLauncher().set(newLauncher);
- Alternatively, set
javaLauncher
to null, then setexecutable
:IfmpsBackendBuilder .withMpsHome(...) ... .configure(task); task.getJavaLauncher().set((JavaLauncher) null); task.executable(newExecutable);
javaLauncher
is not explicitly reset, it takes precedence overexecutable
.
- Set
-
For
project.javaexec
action, setexecutable
:project.javaexec(it -> { mpsBackendBuilder...configure(it); executable(newExecutable); });