Skip to content

Commit d619311

Browse files
mps-gradle-plugin 2.0.0-pre1
1 parent 6345969 commit d619311

File tree

17 files changed

+1011
-576
lines changed

17 files changed

+1011
-576
lines changed

subprojects/mps-gradle-plugin/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 2.0.0-pre1
9+
10+
Breaking changes are to be expected until the final 2.0.0 release.
11+
12+
### Added
13+
14+
- Path variables can be specified in `mpsDefaults` and will be passed to both MPS and Ant tasks.
15+
- Support for multiple build scripts, including test build scripts.
16+
17+
### 🚨 Changed
18+
19+
- Automatic build script detection was removed, build scripts now have to be explicitly added to the `mpsBuilds`
20+
container.
21+
- The plugin now applies the `jbr-toolchain` plugin and uses the runtime specified by the `jbr` configuration to run
22+
Ant and MPS.
23+
- `stubs` renamed to `bundledDependencies`
24+
- 🚨 `com.specificlanguages.RunAntScript` replaced with `com.specificlanguages.mps.RunAnt` which uses modern Gradle
25+
features: lazy properties and `JavaLauncher` for specifying the JVM to use.
26+
- 🚨 The `com.specificlanguages.mps` plugin no longer applies the `java-base` plugin.
27+
28+
### 🚨 Removed
29+
30+
- `mpsDefaults.javaExecutable` (previously deprecated in favor of `mpsDefaults.javaLauncher`).
31+
832
## 1.9.0
933

1034
### Added

subprojects/mps-gradle-plugin/README.md

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
# MPS Gradle Plugin
1+
# MPS Gradle plugin
22

3-
A Gradle plugin to package and publish MPS plugins. Use it if you have developed a language in MPS and you want to make
4-
it easy for other developers to use your language in their projects.
3+
A Gradle plugin to package and publish MPS libraries. Use it if you have developed a library of plugins in MPS and you
4+
want to make it easy for other developers to use your language in their projects.
55

6-
Publishing MPS-based IDEs (rich client platforms) is out of scope for this plugin.
6+
Publishing MPS-based IDEs (RCPs, or rich client platforms) is out of scope for this plugin.
77

88
This plugin also does not cover publishing to the JetBrains Plugins Repository.
99

1010
## Compatibility
1111

12-
This plugin has been tested with the following combinations of Gradle and MPS:
12+
This plugin has been tested with Gradle 8.13.
1313

14-
* Gradle 7.1 or above is required since version 1.2.0.
15-
* Gradle 7.2 and MPS 2020.3.5 (version 1.1.0),
16-
* Gradle 5.6.2 and MPS 2019.2.4 (version 1.0.0),
17-
* Gradle 5.6.2 and MPS 2019.1.5 (version 0.0.2).
14+
> [!CAUTION]
15+
> The content below this point is outdated and will be rewritten.
1816
19-
## Conventions and Assumptions
17+
## Conventions and assumptions
2018

2119
To simplify the configuration the plugin makes certain assumptions and therefore your project must follow certain
2220
conventions.
2321

2422
The following assumptions will hold if you let the MPS wizard generate your build solution and script:
2523

2624
* The MPS project directory is assumed to coincide with the Gradle project directory.
27-
* The MPS project must contain a build model that is either named `build.mps` or matches `*.build.mps`. The build model
28-
must use default persistence and not file-per-root persistence.
29-
* The build model must generate a `build.xml` file in the project's root directory.
3025
* The variable that specifies the location of MPS in the build script is called `mps_home`.
3126

32-
The following conventions are different from the defaults and require manual adjustment of the generated build script:
27+
The following conventions are different from the defaults and you will have to adjust the generated build script to
28+
accomodate them:
3329

3430
* The default layout should also include the build solution.
35-
* Instead of creating a .zip of all modules or plugins the default layout should just collect them in the top-level
36-
folder:
31+
* Instead of creating a .zip of all modules or plugins the default layout should collect them in the top-level folder:
3732
```
3833
default layout:
3934
module com.mbeddr.mpsutil.common
@@ -45,8 +40,8 @@ The following conventions are different from the defaults and require manual adj
4540
plugin com.mbeddr.mpsutil.common [auto packaging]
4641
<empty>
4742
```
48-
* Any dependencies will be put under `build/dependencies` folder and can be referenced from the project's base directory
49-
(without using any path variables).
43+
* Any external dependencies will be put under `build/dependencies` folder and can be referenced from the project's base
44+
directory (without using any path variables).
5045

5146
### Customizing Conventions
5247

@@ -57,17 +52,16 @@ mpsDefaults {
5752
// Custom MPS home directory
5853
mpsHome.set(File("/my/mps/home"))
5954

60-
// Custom location and name of the build script
61-
buildScript.set(file("build/build.xml"))
62-
6355
// Custom dependencies directory
6456
dependenciesDirectory.set("build/project-libraries")
6557
}
6658
```
6759

68-
## Sample Project
60+
## Sample project
6961

70-
A sample project using the plugin can be found here: https://github.com/specificlanguages/mps-gradle-plugin-sample.
62+
A couple of small projects using the plugin can be found here:
63+
* [mps-json](https://github.com/specificlanguages/mps-json)
64+
* [mps-to-json-exporter](https://github.com/specificlanguages/mps-to-json-exporter), using mps-json as a dependency.
7165

7266
## Configuration
7367

@@ -78,7 +72,7 @@ All code snippets below use Kotlin syntax for Gradle.
7872
```kotlin
7973
// build.gradle.kts
8074
plugins {
81-
id("com.specificlanguages.mps") version "1.8.0"
75+
id("com.specificlanguages.mps") version "2.0.0-pre1"
8276
}
8377
```
8478

@@ -88,16 +82,16 @@ All code snippets below use Kotlin syntax for Gradle.
8882
// settings.gradle.kts
8983
pluginManagement {
9084
repositories {
91-
maven(url = "https://artifacts.itemis.cloud/repository/maven-mps")
85+
maven("https://artifacts.itemis.cloud/repository/maven-mps")
9286

9387
// Gradle plugin portal must be added explicitly when using non-default repositories
9488
gradlePluginPortal()
9589
}
9690
}
9791
```
9892

99-
This repository is used to
100-
download [mps-build-backends Gradle MPS launcher](https://github.com/mbeddr/mps-build-backends/tree/main/launcher)
93+
This repository is used to download
94+
[mps-build-backends Gradle MPS launcher](https://github.com/mbeddr/mps-build-backends/tree/main/launcher)
10195
that is used to provide proper command line arguments to the backend in the next step, depending on the MPS version
10296
being run.
10397

@@ -106,7 +100,7 @@ All code snippets below use Kotlin syntax for Gradle.
106100
```kotlin
107101
// build.gradle.kts
108102
repositories {
109-
maven(url = "https://artifacts.itemis.cloud/repository/maven-mps")
103+
maven("https://artifacts.itemis.cloud/repository/maven-mps")
110104
mavenCentral()
111105
}
112106
```
@@ -120,7 +114,7 @@ All code snippets below use Kotlin syntax for Gradle.
120114
```kotlin
121115
// build.gradle.kts
122116
dependencies {
123-
"mps"("com.jetbrains:mps:2021.1.4")
117+
mps("com.jetbrains:mps:2024.3.1")
124118
}
125119
```
126120

@@ -129,16 +123,16 @@ All code snippets below use Kotlin syntax for Gradle.
129123
```kotlin
130124
// build.gradle.kts
131125
dependencies {
132-
"generation"("de.itemis.mps:extensions:2021.1.+")
126+
generation("de.itemis.mps:extensions:2024.3.+")
133127
}
134128
```
135129

136130
6. Specify JAR dependencies that are used as stubs and where they should be placed:
137131

138132
```kotlin
139133
// build.gradle.kts
140-
stubs {
141-
register("stubs") {
134+
bundledDependencies {
135+
create("commonsLang") {
142136
destinationDir("solutions/my.stubs/lib")
143137
dependency("org.apache.commons:commons-lang3:3.12.0")
144138
...
@@ -160,15 +154,15 @@ All code snippets below use Kotlin syntax for Gradle.
160154
publications {
161155
register<MavenPublication>("mpsPlugin") {
162156
from(components["mps"])
163-
157+
164158
// Put resolved versions of dependencies into POM files
165159
versionMapping { usage("java-runtime") { fromResolutionOf("generation") } }
166160
}
167161
}
168162
}
169163
```
170164

171-
## Effects of Applying the Plugin
165+
## Effects of applying the plugin
172166

173167
The plugin applies the [Gradle Base plugin](https://docs.gradle.org/current/userguide/base_plugin.html) which creates a
174168
set of _lifecycle tasks_ such as `clean`, `assemble`, `check`, or `build`.
@@ -178,16 +172,12 @@ The plugin creates the following tasks:
178172
* `setup`: unpacks all dependencies of the `generation` configuration into `build/dependencies`. Since 1.2.0 it also
179173
triggers the individual tasks to unpack stubs, see below. Executing the `setup` task is required before the project
180174
can be opened in MPS.
181-
* ~~`resolveMpsForGeneration`: downloads the MPS artifact specified by the `mps` configuration and unpacks it into
182-
`build/mps`.~~ (Removed in 1.4.0.)
183-
* `resolve<StubName>`: a [Sync](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Sync.html) task created
184-
for each stub block (`<StubName>` is the name of the stub entry, capitalized). The task resolves the dependencies
185-
configured in the stub block and copies them into the specified destination directory of the stub, deleting any other
175+
* `resolve<Name>`: a [Sync](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Sync.html) task created
176+
for each 'bundled dependency' object (`<Name>` is the name of the object, capitalized). The task resolves
177+
the dependencies configured in the object and copies them into the specified destination directory, deleting any other
186178
files present in that directory. When copying the dependencies their version numbers are stripped. This makes it
187179
possible to upgrade dependency versions in the Gradle build script without also reconfiguring the MPS stub solutions.
188-
* `generateBuildscript`: generates the build script using MPS. The build model location is detected automatically.
189-
Since 1.2.2 the task specifies all module files (`*.msd`, `*.mpl`, `*.devkit`) as its inputs since build scripts
190-
check their contents against the modules.
180+
* `generateBuildscripts`: generates the build scripts using MPS. The build model location is detected automatically.
191181
* `assembleMps`: runs `generate` and `assemble` targets of the generated Ant script. The `assemble` lifecycle task is
192182
set to depend on `assembleMps`. Since 1.1.1 the version of the project is passed to Ant via `-Dversion=${project.
193183
version}`. Since 1.2.2 the task specifies all `*.mps` files in all directories as its inputs.
@@ -199,23 +189,11 @@ The plugin creates the following tasks:
199189
The plugin creates a software component named `mps` to represent the published code and adds the `default` configuration
200190
to it.
201191

202-
The plugin modifies the `clean` task to delete MPS-generated directories: `source_gen`, `source_gen.caches`,
203-
`classes_gen`, `tests_gen`, and `tests_gen.caches`. This is in addition to the default operation of `clean` task which
204-
deletes the project's build directory (`build`).
205-
206-
## Downloading and Unzipping MPS
207-
208-
Before version 1.4.0 the plugin declared a task, `resolveMpsForGeneration`, to download and unzip the MPS distribution
209-
under `build/mps`. In 1.4.0 and above this is handled via Gradle artifact transforms. This should enable sharing the
210-
MPS distributions between projects that use the same MPS version (for example, among subprojects of a large project).
211-
212-
The task is left empty in 1.4.0 for backwards compatibility purposes.
213-
214-
## Task Dependency Graph
192+
## Task dependency graph
215193

216194
```mermaid
217195
flowchart RL
218-
setup --> resolveStub["resolve{STUB1,...,STUBn}"]
196+
setup --> resolveBundledDependencies["resolve{BD1,...,BDn}"]
219197
setup --> resolveGenerationDependencies
220198
221199
assemble --> assembleMps
Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,77 @@
1-
public abstract interface class com/specificlanguages/MpsDefaultsExtension {
2-
public abstract fun getBuildScript ()Lorg/gradle/api/file/RegularFileProperty;
1+
public abstract class com/specificlanguages/mps/BundledDependency : org/gradle/api/Named {
2+
public fun <init> (Ljava/lang/String;)V
3+
public abstract fun getConfiguration ()Lorg/gradle/api/provider/Property;
4+
public final fun getConfigurationName ()Ljava/lang/String;
5+
public abstract fun getDependency ()Lorg/gradle/api/artifacts/dsl/DependencyCollector;
6+
public abstract fun getDestinationDir ()Lorg/gradle/api/file/DirectoryProperty;
7+
public fun getName ()Ljava/lang/String;
8+
public abstract fun getSyncTask ()Lorg/gradle/api/provider/Property;
9+
}
10+
11+
public abstract class com/specificlanguages/mps/GenerateBuildScripts : org/gradle/api/DefaultTask {
12+
public fun <init> ()V
13+
public abstract fun getBuildSolutionDescriptors ()Lorg/gradle/api/file/ConfigurableFileCollection;
14+
protected abstract fun getExecOperations ()Lorg/gradle/process/ExecOperations;
15+
public abstract fun getGenerateBackendClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
16+
public abstract fun getJavaLauncher ()Lorg/gradle/api/provider/Property;
17+
public abstract fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
18+
protected abstract fun getObjects ()Lorg/gradle/api/model/ObjectFactory;
19+
public abstract fun getPathVariables ()Lorg/gradle/api/provider/MapProperty;
20+
public abstract fun getProjectDirectory ()Lorg/gradle/api/file/DirectoryProperty;
21+
public final fun make ()V
22+
}
23+
24+
public abstract class com/specificlanguages/mps/MainBuild : com/specificlanguages/mps/MpsBuild {
25+
public fun <init> (Ljava/lang/String;)V
26+
public abstract fun getAssembleTask ()Lorg/gradle/api/provider/Property;
27+
public abstract fun getPackageTask ()Lorg/gradle/api/provider/Property;
28+
}
29+
30+
public abstract class com/specificlanguages/mps/MpsBuild : org/gradle/api/Named {
31+
public fun <init> (Ljava/lang/String;)V
32+
public final fun dependsOn ([Lcom/specificlanguages/mps/MainBuild;)V
33+
public abstract fun getArtifactsDirectory ()Lorg/gradle/api/file/DirectoryProperty;
34+
public abstract fun getBuildFile ()Lorg/gradle/api/file/RegularFileProperty;
35+
public abstract fun getBuildProjectName ()Lorg/gradle/api/provider/Property;
36+
public abstract fun getBuildSolutionDescriptor ()Lorg/gradle/api/file/RegularFileProperty;
37+
public abstract fun getDependencies ()Lorg/gradle/api/provider/SetProperty;
38+
public abstract fun getGenerateTask ()Lorg/gradle/api/provider/Property;
39+
public fun getName ()Ljava/lang/String;
40+
}
41+
42+
public abstract interface class com/specificlanguages/mps/MpsDefaultsExtension {
43+
public abstract fun getAntClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
344
public abstract fun getDependenciesDirectory ()Lorg/gradle/api/file/DirectoryProperty;
4-
public abstract fun getJavaExecutable ()Lorg/gradle/api/file/RegularFileProperty;
545
public abstract fun getJavaLauncher ()Lorg/gradle/api/provider/Property;
646
public abstract fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty;
47+
public abstract fun getPathVariables ()Lorg/gradle/api/provider/MapProperty;
748
}
849

9-
public class com/specificlanguages/MpsPlugin : org/gradle/api/Plugin {
50+
public class com/specificlanguages/mps/MpsPlugin : org/gradle/api/Plugin {
1051
public fun <init> (Lorg/gradle/api/component/SoftwareComponentFactory;Lorg/gradle/jvm/toolchain/JavaToolchainService;)V
1152
public synthetic fun apply (Ljava/lang/Object;)V
1253
public fun apply (Lorg/gradle/api/Project;)V
1354
}
1455

15-
public abstract class com/specificlanguages/RunAntScript : org/gradle/api/DefaultTask {
56+
public abstract class com/specificlanguages/mps/RunAnt : org/gradle/api/DefaultTask {
1657
public fun <init> ()V
17-
public fun build ()V
18-
public final fun configureJavaExec (Lorg/gradle/api/Action;)V
19-
public abstract fun getAdditionalConfigurationActions ()Lorg/gradle/api/provider/ListProperty;
20-
public abstract fun getAntProperties ()Lorg/gradle/api/provider/MapProperty;
21-
public abstract fun getBuildScript ()Lorg/gradle/api/file/RegularFileProperty;
22-
public abstract fun getClasspath ()Lorg/gradle/api/provider/Property;
58+
public final fun build ()V
59+
public abstract fun getBuildFile ()Lorg/gradle/api/file/RegularFileProperty;
60+
public abstract fun getClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection;
61+
public abstract fun getEnvironment ()Lorg/gradle/api/provider/MapProperty;
2362
protected abstract fun getExecOperations ()Lorg/gradle/process/ExecOperations;
24-
public abstract fun getJavaExecutable ()Lorg/gradle/api/file/RegularFileProperty;
25-
public abstract fun getScriptArgs ()Lorg/gradle/api/provider/ListProperty;
63+
public abstract fun getJavaLauncher ()Lorg/gradle/api/provider/Property;
64+
public abstract fun getJvmArguments ()Lorg/gradle/api/provider/ListProperty;
65+
public abstract fun getOptions ()Lorg/gradle/api/provider/ListProperty;
66+
public abstract fun getPathProperties ()Lorg/gradle/api/provider/MapProperty;
2667
public abstract fun getTargets ()Lorg/gradle/api/provider/ListProperty;
68+
protected abstract fun getToolchains ()Lorg/gradle/jvm/toolchain/JavaToolchainService;
69+
public abstract fun getValueProperties ()Lorg/gradle/api/provider/MapProperty;
70+
public abstract fun getWorkingDirectory ()Lorg/gradle/api/file/DirectoryProperty;
2771
}
2872

29-
public abstract class com/specificlanguages/StubConfiguration : org/gradle/api/Named {
30-
public fun <init> (Lorg/gradle/api/Project;Ljava/lang/String;)V
31-
public final fun dependency (Ljava/lang/Object;)Lorg/gradle/api/artifacts/Dependency;
32-
public final fun dependency (Ljava/lang/Object;Lgroovy/lang/Closure;)Lorg/gradle/api/artifacts/Dependency;
33-
public final fun dependency (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lorg/gradle/api/artifacts/ExternalModuleDependency;
34-
public final fun dependency (Lorg/gradle/api/artifacts/ModuleDependency;Lkotlin/jvm/functions/Function1;)Lorg/gradle/api/artifacts/ModuleDependency;
35-
public final fun destinationDir (Ljava/lang/Object;)V
36-
public final fun getConfiguration ()Lorg/gradle/api/NamedDomainObjectProvider;
37-
public abstract fun getDestinationDir ()Lorg/gradle/api/file/DirectoryProperty;
38-
public fun getName ()Ljava/lang/String;
39-
public final fun project (Ljava/lang/String;Ljava/lang/String;)Lorg/gradle/api/artifacts/ProjectDependency;
40-
public final fun project (Ljava/util/Map;)Lorg/gradle/api/artifacts/Dependency;
41-
public static synthetic fun project$default (Lcom/specificlanguages/StubConfiguration;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/gradle/api/artifacts/ProjectDependency;
73+
public abstract class com/specificlanguages/mps/TestBuild : com/specificlanguages/mps/MpsBuild {
74+
public fun <init> (Ljava/lang/String;)V
75+
public abstract fun getAssembleAndCheckTask ()Lorg/gradle/api/provider/Property;
4276
}
4377

subprojects/mps-gradle-plugin/build.gradle.kts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@ repositories {
99
dependencies {
1010
implementation(kotlin("stdlib-jdk8"))
1111
implementation(project(":artifact-transforms"))
12+
implementation(project(":jbr-toolchain"))
1213
implementation("de.itemis.mps.build-backends:launcher:2.5.2.120.c791da5")
14+
15+
testImplementation("org.hamcrest:hamcrest:3.0")
16+
testImplementation("org.junit.jupiter:junit-jupiter:5.12.0")
17+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
1318
}
1419

1520
gradlePlugin {
1621
plugins {
1722
register("mps") {
1823
id = "com.specificlanguages.mps"
19-
implementationClass = "com.specificlanguages.MpsPlugin"
24+
implementationClass = "com.specificlanguages.mps.MpsPlugin"
2025
displayName = "MPS Build Plugin"
21-
description = "Builds JetBrains MPS projects using a simple declarative configuration model"
26+
description = "Build JetBrains MPS projects using a simple declarative configuration model"
2227
tags.set(listOf("jetbrainsMps"))
2328
}
2429
}
2530
}
31+
32+
tasks.test {
33+
useJUnitPlatform()
34+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.9.0
1+
version=2.0.0-pre1

0 commit comments

Comments
 (0)