Skip to content

Instantly share code, notes, and snippets.

@alexanderpann
Created September 29, 2024 07:05
Show Gist options
  • Save alexanderpann/67cc16888f425560990edc2b3f408654 to your computer and use it in GitHub Desktop.
Save alexanderpann/67cc16888f425560990edc2b3f408654 to your computer and use it in GitHub Desktop.
New build script
import de.itemis.mps.gradle.*
import de.itemis.mps.gradle.downloadJBR.*
import de.itemis.mps.gradle.tasks.*
buildscript {
repositories {
maven { url 'https://artifacts.itemis.cloud/repository/maven-mps/' }
}
dependencies {
classpath 'de.itemis.mps.gradle:git-based-versioning:1.1.0'
}
}
plugins {
id 'de.itemis.mps.gradle.common' version '1.28.0.+'
id 'download-jbr' version '1.28.0.+'
id 'maven-publish'
id 'co.riiid.gradle' version '0.4.2'
id 'de.itemis.mps.gradle.launcher' version '2.2.0.+'
}
downloadJbr {
jbrVersion = '17.0.6-b653.34'
defaultJavaExecutable = true
}
ci.determineCI()
jdk.determine(JavaVersion.VERSION_11)
ext.dependencyRepositories = [
itemis.mbeddrGitHub(),
itemis.itemisNexus()
]
ext.mpsVersion = MPSVersion.@Companion.parse("2022.3.2")
ext.projectName = "com.mbeddr.logicalview.checks"
if (ciBuild) {
String branch = GitBasedVersioning.gitBranch
if (branch.startsWith("maintenance") || branch.startsWith("mps")) {
version = GitBasedVersioning.getVersionWithoutMaintenancePrefix(mpsVersion.major,mpsVersion.minorMainPart())
} else {
version = GitBasedVersioning.getVersionWithCount(major, minor, ci.buildNumber())
}
setTeamCityBuildNumber()
} else {
version = mpsVersion.toMavenSnapshot()
println "Local build detected, version will be ${version}"
}
dependencies {
common_mps "com.jetbrains:mps:$mpsVersion"
common_antLib "org.apache.ant:ant-junit:1.10.6"
}
repositories {
mavenCentral()
}
ci.registerDependencyRepositories(project.dependencyRepositories)
// tools needed for compiler support in ant calls
ext.buildScriptClasspath = project.configurations.common_antLib.fileCollection { true } +
project.files("$project.jdk_home/lib/tools.jar")
// ___________________ utilities ___________________
def defaultScriptArgs = [
"mps.home" : mpsHomeDir,
"mps_home" : mpsHomeDir,
"build.jna.library.path" : directories.jnLibraryPath(),
"${projectName}.home" : rootDir,
"build.dir" : layout.buildDirectory,
"version" : version,
"build.date" : new Date(),
]
// enables https://github.com/mbeddr/mps-gradle-plugin#providing-global-defaults
task configureJava {
dependsOn "downloadJbr"
doLast {
project.ext["itemis.mps.gradle.ant.defaultScriptArgs"] = defaultScriptArgs.collect { "-D$it.key=$it.value".toString() }
project.ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = buildScriptClasspath
}
}
// All MPS tasks depend on configureJava and resolveMps
tasks.withType(RunAntScript).configureEach {
dependsOn(configureJava, commonResolveMps)
}
def build_allScripts = tasks.register('build_allScripts', BuildLanguages) {
dependsOn 'downloadJbr', commonResolveMps
script "$rootDir/scripts/build.xml"
}
// All other MPS tasks depend on build_allScripts
tasks.withType(RunAntScript).configureEach {
if (it.name != build_allScripts.name) {
it.dependsOn(build_allScripts)
}
}
def build_languages = tasks.register('build_languages', BuildLanguages) {
mustRunAfter('clean')
dependsOn build_allScripts
script directories.scriptFile('languages/build.xml')
}
task package_project(type: Zip) {
dependsOn build_allScripts
archiveBaseName = projectName
from directories.artifactsDir()
include "${projectName}/**"
}
assemble.dependsOn(tasks.withType(BuildLanguages))
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/mbeddr/mps-logical-view-checks")
credentials {
username = githubAuth.user
password = githubAuth.token
}
}
if (project.hasProperty("artifacts.itemis.cloud.user") && project.hasProperty("artifacts.itemis.cloud.pw")) {
maven {
name = "ItemisNexus"
url = uri("https://artifacts.itemis.cloud/repository/maven-mps-releases")
credentials {
username = project.findProperty("artifacts.itemis.cloud.user")
password = project.findProperty("artifacts.itemis.cloud.pw")
}
}
}
}
publications {
MPSLogicalViewChecks(MavenPublication) {
groupId 'com.mbeddr'
artifactId 'logicalview.checks'
artifact package_project
new Pom().withDep(pom,configurations.common_languageLibs)
new Pom().withDep(pom, configurations.common_mps)
}
}
}
defaultTasks 'build'
task rebuild(dependsOn:[clean, build_languages])
ext.mpsPluginRoots = ['mps-build', 'mps-console', 'mps-trove', 'mps-modelchecker']
.collect { new File(mpsHomeDir, "plugins/$it") }
ext.jbrJavaLauncher = tasks.named('downloadJbr', DownloadJbrForPlatform).flatMap { it.javaLauncher }
tasks.register('migrate', MpsMigrate) {
dependsOn(commonResolveMps, 'downloadJbr', 'build_languages')
javaLauncher = jbrJavaLauncher
mpsHome = mpsHomeDir
folderMacros.put('com.mbeddr.logicalview.checks.home', layout.projectDirectory)
projectDirectories.from('code')
pluginRoots.from(mpsPluginRoots)
haltOnPrecheckFailure = true
haltOnDependencyError = true
}
tasks.register('remigrate', Remigrate) {
dependsOn(commonResolveMps, 'downloadJbr')
mustRunAfter('migrate')
// Technically we don't need to _depend_ on build_all_languages because we can opt to rerun only migrations that
// come from MPS.
mustRunAfter('build_languages')
javaLauncher = jbrJavaLauncher
mpsHome = mpsHomeDir
folderMacros.put('com.mbeddr.logicalview.checks.home', layout.projectDirectory)
projectDirectories.from('code')
pluginRoots.from(mpsPluginRoots)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment