有没有办法通过 Gradle 使用 mps-extensions?

Is there a way to use mps-extensions via Gradle?

我看到 https://github.com/JetBrains/MPS-extensions 通过 GitHub 发布版本,但是将工件集成到基于 MPS 的项目看起来并不方便。

如果我的项目是通过 MPS 构建的并且它依赖于 MPS 扩展怎么办?如果有一种方法可以通过命令行自动下载适当的扩展工件,那就太好了(例如 ./gradlew downloadExtensions

以下对我有用:

build.gradle(参见 https://github.com/Hardella/ide61131/blob/8088fbd9bcc2780f5772856a962fbfe6954b3e50/build.gradle):

repositories {
    maven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }
    mavenCentral()
}

configurations {
    mpsExtensions
}

dependencies {
    mpsExtensions "de.itemis.mps:extensions:2018.2.+"
}

task resolve_extensions(type: Copy) {
    dependsOn configurations.mpsExtensions
    from {
        configurations.mpsExtensions.resolve().collect { zipTree(it) }
    }
    into "lib"
}

然后 ./gradlew resolve_extensions 下载并解压 mps-extensionslib/de.itemis.mps.extensions/... 文件夹。

然后可以通过 Preferences -> Build, Execution, Deployment -> Project Libraries / Global Libraries.

插入到 MPS 实例

以下.mps/libraries.xml将库配置为Project Library

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectLibraryManager">
    <option name="libraries">
      <map>
        <entry key="mps-extensions">
          <value>
            <Library>
              <option name="name" value="mps-extensions" />
              <option name="path" value="$PROJECT_DIR$/lib/de.itemis.mps.extensions" />
            </Library>
          </value>
        </entry>
      </map>
    </option>
  </component>
</project>