From 8ffb42e00dbb2d398ae07aa0c5d79f3cd8d983fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Wed, 25 Oct 2023 15:12:54 +0200 Subject: [PATCH] Upgrade to launcher 2.1.0, allowing the use of any JVM vendor in tests --- build.gradle.kts | 2 +- gradle.lockfile | 2 +- .../de/itemis/mps/gradle/generate/Plugin.kt | 5 +++-- .../de/itemis/mps/gradle/modelcheck/Plugin.kt | 5 +++-- .../de/itemis/mps/gradle/tasks/MpsCheck.kt | 18 ++++++++++-------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 10bd9101..98a2924b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -61,7 +61,7 @@ dependencies { api("de.itemis.mps.gradle:git-based-versioning") implementation(kotlin("stdlib", version = kotlinVersion)) implementation("net.swiftzer.semver:semver:1.1.2") - implementation("de.itemis.mps.build-backends:launcher:1.+") + implementation("de.itemis.mps.build-backends:launcher:2.1.0.+") testImplementation("junit:junit:4.13.2") } diff --git a/gradle.lockfile b/gradle.lockfile index 75b155f3..fc2b52eb 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -1,7 +1,7 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -de.itemis.mps.build-backends:launcher:1.0.0.56.8c05881=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath +de.itemis.mps.build-backends:launcher:2.1.0.58.0fb483b=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath junit:junit:4.13.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath net.java.dev.jna:jna:5.6.0=kotlinCompilerClasspath,kotlinKlibCommonizerClasspath net.swiftzer.semver:semver:1.1.2=compileClasspath,implementationDependenciesMetadata,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath diff --git a/src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt b/src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt index 80e94197..40d3822b 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt @@ -1,6 +1,7 @@ package de.itemis.mps.gradle.generate import de.itemis.mps.gradle.* +import de.itemis.mps.gradle.launcher.MpsBackendBuilder import de.itemis.mps.gradle.launcher.MpsBackendLauncher import org.gradle.api.GradleException import org.gradle.api.Plugin @@ -66,8 +67,8 @@ open class GenerateMpsProjectPlugin : Plugin { } generate.configure { - val backendLauncher: MpsBackendLauncher = project.objects.newInstance(MpsBackendLauncher::class) - backendLauncher.configureJavaForMpsVersion(this, mpsLocation, mpsVersion) + val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class) + backendBuilder.withMpsHome(mpsLocation).withMpsVersion(mpsVersion).configure(this) // For backwards compatibility reset the javaLauncher set by the backendLauncher javaLauncher.set(null) diff --git a/src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt b/src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt index bf157d8e..5b86b095 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt @@ -1,6 +1,7 @@ package de.itemis.mps.gradle.modelcheck import de.itemis.mps.gradle.* +import de.itemis.mps.gradle.launcher.MpsBackendBuilder import de.itemis.mps.gradle.launcher.MpsBackendLauncher import org.gradle.api.GradleException import org.gradle.api.Plugin @@ -52,8 +53,8 @@ open class ModelcheckMpsProjectPlugin : Plugin { } checkmodels.configure { - val backendLauncher: MpsBackendLauncher = project.objects.newInstance(MpsBackendLauncher::class) - backendLauncher.configureJavaForMpsVersion(this, mpsLocation, mpsVersion) + val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class) + backendBuilder.withMpsHome(mpsLocation).withMpsVersion(mpsVersion).configure(this) // For backwards compatibility reset the javaLauncher set by the backendLauncher javaLauncher.set(null) diff --git a/src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt b/src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt index 55a7ac46..bc578f03 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt @@ -1,10 +1,14 @@ package de.itemis.mps.gradle.tasks -import de.itemis.mps.gradle.launcher.MpsBackendLauncher +import de.itemis.mps.gradle.launcher.MpsBackendBuilder +import de.itemis.mps.gradle.launcher.MpsVersionDetection import org.gradle.api.GradleException import org.gradle.api.file.* import org.gradle.api.logging.LogLevel -import org.gradle.api.provider.* +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.* import org.gradle.kotlin.dsl.* import org.gradle.language.base.plugins.LifecycleBasePlugin @@ -14,17 +18,13 @@ import java.io.File @CacheableTask abstract class MpsCheck : JavaExec(), VerificationTask { - // Having our own private launcher instance means we don't need to apply the launcher plugin. This works as long - // as the launcher remains stateless. - private val backendLauncher: MpsBackendLauncher = objectFactory.newInstance(MpsBackendLauncher::class) - @get:Internal("covered by mpsVersion, initialModelcheckBackendClasspath()") val mpsHome: DirectoryProperty = objectFactory.directoryProperty() @get:Input @get:Optional val mpsVersion: Property = objectFactory.property() - .convention(backendLauncher.mpsVersionFromMpsHome(mpsHome.asFile)) + .convention(MpsVersionDetection.fromMpsHome(project.layout, providerFactory, mpsHome.asFile)) @get:Internal("only modules and models matter, covered by #sources") val projectLocation: DirectoryProperty = @@ -86,7 +86,9 @@ abstract class MpsCheck : JavaExec(), VerificationTask { } init { - backendLauncher.configureJavaForMpsVersion(this, mpsHome.map { it.asFile }, mpsVersion) + val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class) + backendBuilder.withMpsHomeDirectory(mpsHome).withMpsVersion(mpsVersion).configure(this) + argumentProviders.add(CommandLineArgumentProvider { val result = mutableListOf()