Skip to content

Commit

Permalink
Merge pull request #2678 from mbeddr/refactor/jbr-toolchain
Browse files Browse the repository at this point in the history
build: upgrade to Gradle 8.12, introduce jbr-toolchain
  • Loading branch information
sergej-koscejev authored Jan 14, 2025
2 parents 7244ce1 + 48be38e commit 914f457
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 32 deletions.
3 changes: 3 additions & 0 deletions build-logic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.gradle/
/build/
/.kotlin/
14 changes: 14 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
}

dependencies {
fun plugin(alias: Provider<PluginDependency>) = alias.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }
implementation(plugin(libs.plugins.common))
implementation(plugin(libs.plugins.jbr.toolchain))
}

repositories {
maven("https://artifacts.itemis.cloud/repository/maven-mps")
gradlePluginPortal()
}
7 changes: 7 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
13 changes: 13 additions & 0 deletions build-logic/src/main/kotlin/LazyString.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import org.gradle.api.provider.Provider
import java.io.Serializable

/**
* Allow using a Provider for properties that accept an Object and call toString() on it,
* such as [de.itemis.mps.gradle.RunAntScript.executable].
*/
class LazyString(private val source: Lazy<String>) : Serializable {
constructor(source: () -> String) : this(lazy(source))
constructor(source: Provider<String>) : this(source::get)

override fun toString() = source.value
}
16 changes: 16 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.mps-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import de.itemis.mps.gradle.RunAntScript

plugins {
id("com.specificlanguages.jbr-toolchain")
id("de.itemis.mps.gradle.common")
}

// Use the JBR dependency from the version catalog
dependencies {
jbr(versionCatalogs.named("libs").findLibrary("jbr").get())
}

// Use the specified JBR for all RunAntScript tasks
tasks.withType<RunAntScript>().configureEach {
executable = LazyString(jbrToolchain.javaLauncher.map { it.executablePath.toString() })
}
12 changes: 0 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import de.itemis.mps.gradle.GitBasedVersioning
import de.itemis.mps.gradle.RunAntScript


plugins {
id 'de.itemis.mps.gradle.common' version '1.28.+'
id 'download-jbr' version '1.28.+'
}

repositories {
maven { url 'https://artifacts.itemis.cloud/repository/maven-mps' }
}

downloadJbr {
jbrVersion = '17.0.6-b653.34'
}

ext.defaultSnapshotRepository = 'https://artifacts.itemis.cloud/repository/maven-mps-snapshots/'
ext.defaultReleaseRepository = 'https://artifacts.itemis.cloud/repository/maven-mps-releases/'

Expand All @@ -29,10 +23,6 @@ ext.artifactsDir = new File(rootDir, 'artifacts')

ext.ciBuild = project.findProperty("forceCI") ?: !project.findProperty('mpsHomeDir') && project.hasProperty("teamcity")

afterEvaluate {
ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = tasks.getByName('downloadJbr').javaExecutable
}

def hasNonEmptyProperty(property) {
return project.hasProperty(property) && !project.getProperty(property).empty
}
Expand Down Expand Up @@ -138,7 +128,5 @@ subprojects {
println "Local build detected. mbeddr version $ext.mbeddrBuildNumber, mbeddr platform version $ext.mbeddrPlatformBuildNumber"
}

tasks.withType(RunAntScript).configureEach(task -> { task.dependsOn(':downloadJbr') })

}
}
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[plugins]
common = "de.itemis.mps.gradle.common:1.28.+"
jbr-toolchain = "com.specificlanguages.jbr-toolchain:1.0.0"

[libraries]
jbr = "com.jetbrains.jdk:jbr_jcef:17.0.8.1-b1000.32"
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 1 addition & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pluginManagement {
maven("https://artifacts.itemis.cloud/repository/maven-mps/")
gradlePluginPortal()
}

includeBuild("build-logic")
}

val subprojectPaths = listOf("com.mbeddr",
Expand Down
16 changes: 5 additions & 11 deletions subprojects/com.mbeddr/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import de.itemis.mps.gradle.tasks.MpsMigrate
import de.itemis.mps.gradle.tasks.Remigrate
import de.itemis.mps.gradle.downloadJBR.DownloadJbrForPlatform

plugins {
id 'de.itemis.mps.gradle.common'
id 'buildlogic.mps-conventions'
}

apply plugin: 'download-jbr'

downloadJbr {
jbrVersion = '17.0.8.1-b1000.32'
}
// path variables
// If mpsHomeDir is set explicitly, skip the MPS resolution step and use the explicit path (which may be relative from
// the root directory).
Expand Down Expand Up @@ -185,8 +179,8 @@ List<File> projectDirectoriesInDependencyOrder = projectsInDependencyOrder.colle
}

tasks.register('migrate', MpsMigrate) {
dependsOn(':com.mbeddr:platform:generate_platform_languages', 'downloadJbr')
javaLauncher = tasks.named('downloadJbr', DownloadJbrForPlatform).flatMap { it.javaLauncher }
dependsOn(':com.mbeddr:platform:generate_platform_languages')
javaLauncher = jbrToolchain.javaLauncher

mpsHome = mpsHomeDir
projectDirectories.from(projectDirectoriesInDependencyOrder)
Expand All @@ -199,8 +193,8 @@ tasks.register('migrate', MpsMigrate) {
}

tasks.register('remigrate', Remigrate) {
dependsOn(':com.mbeddr:platform:generate_platform_languages', 'downloadJbr')
javaLauncher = tasks.named('downloadJbr', DownloadJbrForPlatform).flatMap { it.javaLauncher }
dependsOn(':com.mbeddr:platform:generate_platform_languages')
javaLauncher = jbrToolchain.javaLauncher

mpsHome = mpsHomeDir
projectDirectories.from(projectDirectoriesInDependencyOrder)
Expand Down
6 changes: 1 addition & 5 deletions subprojects/com.mbeddr/distribution/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import de.itemis.mps.gradle.*

configurations {
junitAnt
mbeddr
jreWin
}

ext.jdkVersion = '17.0.3-b469.32'
dependencies {
mbeddr "com.mbeddr:mbeddr:$mbeddrBuildNumber"
jreWin "com.jetbrains.jdk:jbr:${jdkVersion}:windows-x64@tgz"
}

task resolve_mbeddr() {
doLast {
doLast {
copy {
from {
configurations.mbeddr.resolve().collect { zipTree(it) }
Expand Down
1 change: 1 addition & 0 deletions subprojects/com.mbeddr/languages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import de.itemis.mps.gradle.*
plugins {
id 'base'
id 'maven-publish'
id 'buildlogic.mps-conventions'
}

// :com.mbeddr.build
Expand Down
1 change: 1 addition & 0 deletions subprojects/com.mbeddr/platform/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'base'
id 'maven-publish'
id 'buildlogic.mps-conventions'
}

import de.itemis.mps.gradle.*
Expand Down

0 comments on commit 914f457

Please sign in to comment.