Skip to content

Commit

Permalink
Upgrade to launcher 2.1.0, allowing the use of any JVM vendor in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Oct 25, 2023
1 parent 49cd15b commit 8ffb42e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.lockfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -66,8 +67,8 @@ open class GenerateMpsProjectPlugin : Plugin<Project> {
}

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)
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -52,8 +53,8 @@ open class ModelcheckMpsProjectPlugin : Plugin<Project> {
}

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)
Expand Down
18 changes: 10 additions & 8 deletions src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String> = objectFactory.property<String>()
.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 =
Expand Down Expand Up @@ -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<String>()

Expand Down

0 comments on commit 8ffb42e

Please sign in to comment.