Skip to content

Instantly share code, notes, and snippets.

@coolya
Last active September 26, 2022 11:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolya/46706883a6563f0d63527baed8091d75 to your computer and use it in GitHub Desktop.
Save coolya/46706883a6563f0d63527baed8091d75 to your computer and use it in GitHub Desktop.
Minimal MPS Build
import de.itemis.mps.gradle.downloadJBR.DownloadJbrForPlatform
import de.itemis.mps.gradle.BuildLanguages
buildscript {
repositories {
maven { url = uri("https://projects.itemis.de/nexus/content/repositories/mbeddr") }
mavenCentral()
}
dependencies {
classpath("de.itemis.mps:mps-gradle-plugin:1.5.269.964f94a")
}
}
plugins {
id("download-jbr") version "1.5.269.964f94a"
}
repositories {
maven { url = uri("https://projects.itemis.de/nexus/content/repositories/mbeddr") }
mavenCentral()
}
val mpsDependencies: Configuration by configurations.creating
val mps: Configuration by configurations.creating
val buildDependencies: Configuration by configurations.creating
dependencies {
mpsDependencies("com.mbeddr:platform:2020.3.+")
mps("com.jetbrains:mps:2020.3.5")
buildDependencies("org.apache.ant:ant-junit:1.10.6")
}
val mpsDir = file("$buildDir/mps")
val artifactsDir = file("$buildDir/artifacts")
val jbrDir = file("$buildDir/jbr")
downloadJbr {
jbrVersion = "11_0_10-b1145.96"
downloadDir = jbrDir
}
val extractMps by tasks.registering(Copy::class) {
from({ mps.resolve().map { zipTree(it) } })
into(mpsDir)
}
val extractMpsDependencies by tasks.registering(Copy::class) {
from({ mpsDependencies.resolve().map { zipTree(it) } })
into(artifactsDir)
}
fun antVar(name: String, value: String) = "-D$name=$value"
val setup by tasks.registering {
group = "Setup"
description = "Download and extract MPS and the projects MPS dependencies."
dependsOn(extractMps)
dependsOn(extractMpsDependencies)
val downloadJbrForPlatform = tasks.getByName("downloadJbr", DownloadJbrForPlatform::class)
dependsOn(downloadJbrForPlatform)
ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = downloadJbrForPlatform.javaExecutable
ext["itemis.mps.gradle.ant.defaultScriptArgs"] =
listOf(
antVar("mps_home", mpsDir.absolutePath),
antVar("artifacts_home", artifactsDir.absolutePath),
antVar("mps.generator.skipUnmodifiedModels", "true")
)
ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = buildDependencies.fileCollection { true }
}
val buildScripts by tasks.registering(BuildLanguages::class) {
dependsOn(setup)
script = "$projectDir/build-allScripts.xml"
}
val buildLanguages by tasks.registering(BuildLanguages::class) {
group = "build"
description = "Build all languages in the MPS project"
script = "$buildDir/scripts/build.xml"
dependsOn(buildScripts)
}
pluginManagement {
repositories {
maven { url = uri("https://projects.itemis.de/nexus/content/repositories/mbeddr") }
gradlePluginPortal()
}
}
rootProject.name = "my-mps-build"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment