Skip to content

Commit 67ec69e

Browse files
1.26.0: Introduce MpsTask interface
1 parent f74c02c commit 67ec69e

16 files changed

+115
-156
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
33
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## 1.26.0
6+
7+
### Changed
8+
9+
- All MPS tasks now implement `MpsTask` interface which defines common properties. As a result, some tasks were
10+
affected:
11+
- `MpsCheck`: `pluginRoots` type was changed from `SetProperty<Directory>` to `ConfigurableFileCollection` because
12+
the latter is easier to work with from Gradle. **This is a breaking change.**
13+
- `MpsExecute`: `folderMacros` are now supported and will be passed to MPS.
14+
15+
### Deprecated
16+
17+
- `MpsCheck`, `MpsGenerate`, `MpsExecute`: `varMacros` (or `macros` in case of `MpsExecute`) are now deprecated and will
18+
be removed in a later release. Only folder macros (pointing to an existing directory) are supported by MPS, any
19+
non-folder macros would not have worked properly anyway.
20+
521
## 1.25.2
622

723
### Fixed

api/mps-gradle-plugin.api

+12-24
Original file line numberDiff line numberDiff line change
@@ -302,29 +302,25 @@ public final class de/itemis/mps/gradle/runmigrations/RunMigrationsMpsProjectPlu
302302
public final fun getMIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE ()Lnet/swiftzer/semver/SemVer;
303303
}
304304

305-
public abstract class de/itemis/mps/gradle/tasks/MpsCheck : org/gradle/api/tasks/JavaExec, org/gradle/api/tasks/VerificationTask {
305+
public abstract class de/itemis/mps/gradle/tasks/MpsCheck : org/gradle/api/tasks/JavaExec, de/itemis/mps/gradle/tasks/MpsTask, org/gradle/api/tasks/VerificationTask {
306306
public fun <init> ()V
307307
public fun exec ()V
308308
public final fun getAdditionalModelcheckBackendClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
309309
protected final fun getCompiledClasses ()Lorg/gradle/api/file/FileTree;
310310
public final fun getExcludeModels ()Lorg/gradle/api/provider/ListProperty;
311311
public final fun getExcludeModules ()Lorg/gradle/api/provider/ListProperty;
312-
public final fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty;
313312
public final fun getJunitFile ()Lorg/gradle/api/file/RegularFileProperty;
314313
public final fun getJunitFormat ()Lorg/gradle/api/provider/Property;
315314
public final fun getModels ()Lorg/gradle/api/provider/ListProperty;
316315
public final fun getModules ()Lorg/gradle/api/provider/ListProperty;
317-
public final fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
318-
public final fun getMpsVersion ()Lorg/gradle/api/provider/Property;
319316
public final fun getParallel ()Lorg/gradle/api/provider/Property;
320-
public final fun getPluginRoots ()Lorg/gradle/api/provider/SetProperty;
321317
public final fun getProjectLocation ()Lorg/gradle/api/file/DirectoryProperty;
322318
protected final fun getSources ()Lorg/gradle/api/file/FileTree;
323319
public final fun getVarMacros ()Lorg/gradle/api/provider/MapProperty;
324320
public final fun getWarningAsError ()Lorg/gradle/api/provider/Property;
325321
}
326322

327-
public abstract class de/itemis/mps/gradle/tasks/MpsExecute : org/gradle/api/tasks/JavaExec {
323+
public abstract class de/itemis/mps/gradle/tasks/MpsExecute : org/gradle/api/tasks/JavaExec, de/itemis/mps/gradle/tasks/MpsTask {
328324
public fun <init> ()V
329325
public fun exec ()V
330326
public final fun getAdditionalExecuteBackendClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
@@ -333,60 +329,52 @@ public abstract class de/itemis/mps/gradle/tasks/MpsExecute : org/gradle/api/tas
333329
public abstract fun getMethod ()Lorg/gradle/api/provider/Property;
334330
public abstract fun getMethodArguments ()Lorg/gradle/api/provider/ListProperty;
335331
public abstract fun getModule ()Lorg/gradle/api/provider/Property;
336-
public abstract fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
337-
public abstract fun getMpsVersion ()Lorg/gradle/api/provider/Property;
338-
public abstract fun getPluginRoots ()Lorg/gradle/api/provider/SetProperty;
339332
public abstract fun getProjectLocation ()Lorg/gradle/api/file/DirectoryProperty;
340333
}
341334

342-
public abstract class de/itemis/mps/gradle/tasks/MpsGenerate : org/gradle/api/tasks/JavaExec {
335+
public abstract class de/itemis/mps/gradle/tasks/MpsGenerate : org/gradle/api/tasks/JavaExec, de/itemis/mps/gradle/tasks/MpsTask {
343336
public fun <init> ()V
344337
public fun exec ()V
345338
public final fun getAdditionalGenerateBackendClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
346339
protected final fun getCompiledClasses ()Lorg/gradle/api/file/FileTree;
347340
public final fun getEnvironmentKind ()Lorg/gradle/api/provider/Property;
348341
public final fun getExcludeModels ()Lorg/gradle/api/provider/ListProperty;
349342
public final fun getExcludeModules ()Lorg/gradle/api/provider/ListProperty;
350-
public final fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty;
351343
public final fun getModels ()Lorg/gradle/api/provider/ListProperty;
352344
public final fun getModules ()Lorg/gradle/api/provider/ListProperty;
353-
public final fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
354-
public final fun getMpsVersion ()Lorg/gradle/api/provider/Property;
355345
public final fun getParallelGenerationThreads ()Lorg/gradle/api/provider/Property;
356-
public final fun getPluginRoots ()Lorg/gradle/api/file/ConfigurableFileCollection;
357346
public final fun getProjectLocation ()Lorg/gradle/api/file/DirectoryProperty;
358347
protected final fun getSources ()Lorg/gradle/api/file/FileTree;
359348
public final fun getStrictMode ()Lorg/gradle/api/provider/Property;
360349
public final fun getVarMacros ()Lorg/gradle/api/provider/MapProperty;
361350
}
362351

363-
public abstract class de/itemis/mps/gradle/tasks/MpsMigrate : org/gradle/api/DefaultTask {
352+
public abstract class de/itemis/mps/gradle/tasks/MpsMigrate : org/gradle/api/DefaultTask, de/itemis/mps/gradle/tasks/MpsTask {
364353
public fun <init> (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/provider/ProviderFactory;)V
365354
public final fun execute ()V
366355
protected final fun getAllProjectFiles ()Lorg/gradle/api/provider/Provider;
367356
public final fun getAntJvmArgs ()Lorg/gradle/api/provider/ListProperty;
368-
public final fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty;
369357
public final fun getHaltOnDependencyError ()Lorg/gradle/api/provider/Property;
370358
public final fun getHaltOnPrecheckFailure ()Lorg/gradle/api/provider/Property;
371359
public final fun getJavaExecutable ()Lorg/gradle/api/file/RegularFileProperty;
372360
public final fun getJavaLauncher ()Lorg/gradle/api/provider/Property;
373361
public final fun getJvmArgs ()Lorg/gradle/api/provider/ListProperty;
374362
public final fun getMaxHeapSize ()Lorg/gradle/api/provider/Property;
375-
public final fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
376-
public final fun getMpsVersion ()Lorg/gradle/api/provider/Property;
377-
public final fun getPluginRoots ()Lorg/gradle/api/file/ConfigurableFileCollection;
378363
public final fun getProjectDirectories ()Lorg/gradle/api/file/ConfigurableFileCollection;
379364
}
380365

381-
public class de/itemis/mps/gradle/tasks/Remigrate : org/gradle/api/tasks/JavaExec {
366+
public abstract interface class de/itemis/mps/gradle/tasks/MpsTask : org/gradle/api/Task {
367+
public abstract fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty;
368+
public abstract fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
369+
public abstract fun getMpsVersion ()Lorg/gradle/api/provider/Property;
370+
public abstract fun getPluginRoots ()Lorg/gradle/api/file/ConfigurableFileCollection;
371+
}
372+
373+
public abstract class de/itemis/mps/gradle/tasks/Remigrate : org/gradle/api/tasks/JavaExec, de/itemis/mps/gradle/tasks/MpsTask {
382374
public fun <init> (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/provider/ProviderFactory;)V
383375
public fun exec ()V
384376
public final fun getAdditionalClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
385377
protected final fun getAllProjectFiles ()Lorg/gradle/api/provider/Provider;
386-
public final fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty;
387-
public final fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
388-
public final fun getMpsVersion ()Lorg/gradle/api/provider/Property;
389-
public final fun getPluginRoots ()Lorg/gradle/api/file/ConfigurableFileCollection;
390378
public final fun getProjectDirectories ()Lorg/gradle/api/file/ConfigurableFileCollection;
391379
}
392380

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
2525
}
2626

27-
val baseVersion = "1.25.2"
27+
val baseVersion = "1.26.0"
2828

2929
group = "de.itemis.mps"
3030

docs/tasks/MpsCheck.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@ Parameters:
3434
backend.
3535
* `folderMacros` - path variables/macros that are necessary to open the project. Path macros are not considered part of
3636
Gradle build cache key.
37-
* `varMacros` - non-path variables/macros that are necessary to open the project. Variable macros *are* considered part
38-
of Gradle build cache key.
37+
* `varMacros` - Deprecated and will be removed (only folder macros are supported by MPS).
3938
* `junitFile` - the JUnit XML file to produce. Defaults to `$buildDir/TEST-${task.name}.xml`
4039
* `junitFormat` - the format of the JUnit XML file. Defaults to `module-and-model`.
4140
* `parallel` (since 1.20) - runs model checker in parallel mode. Supported in MPS 2021.3.4. Default is `false`.
4241
* `mpsHome` - the home directory of the MPS distribution (or RCP) to use for testing.
4342
* `mpsVersion` - the MPS version, such as "2021.3". Autodetected by reading `$mpsHome/build.properties` by default.
44-
* `pluginRoots` - directories containing additional plugins to load
43+
* `pluginRoots` - directories that will be searched (recursively) for additional plugins to load.
4544
* `warningAsError` - whether to treat warnings as errors.
4645
* `ignoreFailures` (inherited from `VerificationTask`) - whether to fail the build if an error is found.
4746

docs/tasks/MpsExecute.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Parameters:
2727

2828
* `projectLocation` - the location of the MPS project. Default is the Gradle project directory.
2929
* `additionalExecuteBackendClasspath` - any extra libraries that should be on the classpath of the execute backend.
30-
* `macros` - variables/macros that are necessary to open the project.
30+
* `folderMacros` - folder/path macros that are necessary to open the project.
3131
* `mpsHome` - the home directory of the MPS distribution (or RCP) to use for testing.
3232
* `mpsVersion` - the MPS version, such as "2021.3". Default is autodetection by reading `$mpsHome/build.properties`.
33-
* `pluginRoots` - directories containing additional plugins to load.
33+
* `pluginRoots` - directories that will be searched (recursively) for additional plugins to load.
3434
* `module` - the module that contains the generated class.
3535
* `className` - fully qualified name of the generated class, that contains the method to execute.
3636
* `method` - name of the method. The method should be public and static. Supported signatures are `(Project)` (from

docs/tasks/MpsGenerate.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ Parameters:
3434
backend.
3535
* `folderMacros` - path variables/macros that are necessary to open the project. Path macros are not considered part of
3636
Gradle build cache key.
37-
* `varMacros` - non-path variables/macros that are necessary to open the project. Variable macros *are* considered part
38-
of Gradle build cache key.
37+
* `varMacros` - Deprecated and will be removed (only folder macros are supported by MPS).
3938
* `mpsHome` - the home directory of the MPS distribution (or RCP) to use for testing.
4039
* `mpsVersion` - the MPS version, such as "2021.3". Autodetected by reading `$mpsHome/build.properties` by default.
41-
* `pluginRoots` - directories with additional plugins to load.
40+
* `pluginRoots` - directories that will be searched (recursively) for additional plugins to load.
4241
* `environmentKind` - the environment to use for generation (`MPS` or `IDEA`). MPS environment is used by default,
4342
matching the standard `<generate>` Ant task. IDEA environment can be used when generating screenshots.
4443
See [MPS vs IDEA environment](../notes/mps-vs-idea-environment.md).

src/main/kotlin/de/itemis/mps/gradle/common.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package de.itemis.mps.gradle
22

3+
import de.itemis.mps.gradle.launcher.MpsVersionDetection
4+
import de.itemis.mps.gradle.tasks.MpsTask
5+
36
/**
47
* A side effect of this plugin is that it lets us use `plugins` block rather than `buildscript` to put the task classes
58
* ([RunAntScript], [BuildLanguages], etc.) onto the classpath.
69
*/
710

11+
tasks.withType(MpsTask::class.java).configureEach {
12+
mpsVersion.convention(MpsVersionDetection.fromMpsHome(project.layout, providers, mpsHome.asFile))
13+
}
14+
815
val modelcheckBackend = configurations.create(BackendConfigurations.MODELCHECK_BACKEND_CONFIGURATION_NAME)
916
val generateBackend = configurations.create(BackendConfigurations.GENERATE_BACKEND_CONFIGURATION_NAME)
1017
val executeBackend = configurations.create(BackendConfigurations.EXECUTE_BACKEND_CONFIGURATION_NAME)

src/main/kotlin/de/itemis/mps/gradle/tasks/MpsCheck.kt

+5-28
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,25 @@
11
package de.itemis.mps.gradle.tasks
22

33
import de.itemis.mps.gradle.BackendConfigurations
4-
import de.itemis.mps.gradle.ErrorMessages
54
import de.itemis.mps.gradle.TaskGroups
65
import de.itemis.mps.gradle.launcher.MpsBackendBuilder
7-
import de.itemis.mps.gradle.launcher.MpsVersionDetection
8-
import org.gradle.api.GradleException
96
import org.gradle.api.Incubating
107
import org.gradle.api.file.*
11-
import org.gradle.api.logging.LogLevel
128
import org.gradle.api.provider.ListProperty
139
import org.gradle.api.provider.MapProperty
1410
import org.gradle.api.provider.Property
15-
import org.gradle.api.provider.SetProperty
1611
import org.gradle.api.tasks.*
1712
import org.gradle.kotlin.dsl.*
18-
import org.gradle.language.base.plugins.LifecycleBasePlugin
1913
import org.gradle.process.CommandLineArgumentProvider
2014

2115
@CacheableTask
2216
@Incubating
23-
abstract class MpsCheck : JavaExec(), VerificationTask {
24-
25-
@get:Internal("covered by mpsVersion, initialModelcheckBackendClasspath()")
26-
val mpsHome: DirectoryProperty = objectFactory.directoryProperty()
27-
28-
@get:Input
29-
@get:Optional
30-
val mpsVersion: Property<String> = objectFactory.property<String>()
31-
.convention(MpsVersionDetection.fromMpsHome(project.layout, providerFactory, mpsHome.asFile))
32-
17+
abstract class MpsCheck : JavaExec(), MpsTask, VerificationTask {
3318
@get:Internal("only modules and models matter, covered by #sources")
3419
val projectLocation: DirectoryProperty =
3520
objectFactory.directoryProperty().convention(project.layout.projectDirectory)
3621

37-
@get:Classpath
38-
val pluginRoots: SetProperty<Directory> = objectFactory.setProperty()
39-
40-
@get:Internal("Folder macros are ignored for the purposes of up-to-date checks and caching")
41-
val folderMacros: MapProperty<String, Directory> = objectFactory.mapProperty()
42-
22+
@Deprecated("All macros should point to directories, property will be removed in a later release")
4323
@get:Input
4424
val varMacros: MapProperty<String, String> = objectFactory.mapProperty()
4525

@@ -97,15 +77,14 @@ abstract class MpsCheck : JavaExec(), VerificationTask {
9777
val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class)
9878
backendBuilder.withMpsHomeDirectory(mpsHome).withMpsVersion(mpsVersion).configure(this)
9979

80+
argumentProviders.add(backendArguments())
10081
argumentProviders.add(CommandLineArgumentProvider {
10182
val result = mutableListOf<String>()
83+
@Suppress("DEPRECATION")
84+
addVarMacros(result, varMacros, this)
10285

10386
result.add("--project=${projectLocation.get().asFile}")
10487

105-
addPluginRoots(result, pluginRoots.get())
106-
addFolderMacros(result, folderMacros)
107-
addVarMacros(result, varMacros)
108-
10988
// Only a limited subset of checkers is registered in MPS environment, IDEA environment is necessary for
11089
// proper checking.
11190
result.add("--environment=IDEA")
@@ -135,8 +114,6 @@ abstract class MpsCheck : JavaExec(), VerificationTask {
135114
result.add("--parallel")
136115
}
137116

138-
addLogLevel(result)
139-
140117
result
141118
})
142119

src/main/kotlin/de/itemis/mps/gradle/tasks/MpsExecute.kt

+6-21
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
11
package de.itemis.mps.gradle.tasks
22

33
import de.itemis.mps.gradle.BackendConfigurations
4-
import de.itemis.mps.gradle.ErrorMessages
54
import de.itemis.mps.gradle.launcher.MpsBackendBuilder
65
import de.itemis.mps.gradle.launcher.MpsVersionDetection
7-
import org.gradle.api.GradleException
86
import org.gradle.api.Incubating
97
import org.gradle.api.file.ConfigurableFileCollection
10-
import org.gradle.api.file.Directory
118
import org.gradle.api.file.DirectoryProperty
12-
import org.gradle.api.logging.LogLevel
139
import org.gradle.api.provider.ListProperty
1410
import org.gradle.api.provider.MapProperty
1511
import org.gradle.api.provider.Property
16-
import org.gradle.api.provider.SetProperty
1712
import org.gradle.api.tasks.*
1813
import org.gradle.kotlin.dsl.newInstance
1914
import org.gradle.work.DisableCachingByDefault
2015

2116

2217
@DisableCachingByDefault(because = "calls arbitrary user code")
2318
@Incubating
24-
abstract class MpsExecute : JavaExec() {
25-
26-
@get:Internal
27-
abstract val mpsHome: DirectoryProperty
28-
29-
@get:Internal
30-
abstract val mpsVersion: Property<String>
31-
19+
abstract class MpsExecute : MpsTask, JavaExec() {
3220
@get:Internal
3321
abstract val projectLocation: DirectoryProperty
3422

35-
@get:Classpath
36-
abstract val pluginRoots: SetProperty<Directory>
37-
23+
@Deprecated("Use [folderMacros].")
3824
@get:Internal
3925
abstract val macros: MapProperty<String, String>
4026

@@ -63,19 +49,18 @@ abstract class MpsExecute : JavaExec() {
6349
.withMpsVersion(mpsVersion)
6450
.configure(this)
6551

52+
argumentProviders.add(backendArguments())
6653
argumentProviders.add {
6754
mutableListOf<String>().apply {
68-
add("--project=${projectLocation.get().asFile}")
55+
@Suppress("DEPRECATION")
56+
addVarMacros(this, macros, this@MpsExecute, "macros")
6957

70-
addPluginRoots(this, pluginRoots.get())
71-
addVarMacros(this, macros)
58+
add("--project=${projectLocation.get().asFile}")
7259

7360
add("--module=${module.get()}")
7461
add("--class=${className.get()}")
7562
add("--method=${method.get()}")
7663
methodArguments.get().forEach { add("--arg=$it") }
77-
78-
addLogLevel(this)
7964
}
8065
}
8166

0 commit comments

Comments
 (0)