Search code examples
mps

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


I see https://github.com/JetBrains/MPS-extensions publishes releases via GitHub, however it does not look convenient for integration of the artifacts to a MPS-based project.

What if my project is built via MPS and it depends on MPS-extensions? It would be great if there was a way to automatically download proper extensions artifact via command line (e.g. ./gradlew downloadExtensions)


Solution

  • The following worked for me:

    build.gradle (see 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"
    }
    

    Then ./gradlew resolve_extensions downloads and unpacks mps-extensions into lib/de.itemis.mps.extensions/... folder.

    Then it can be plugged to MPS instance via Preferences -> Build, Execution, Deployment -> Project Libraries / Global Libraries.

    The following .mps/libraries.xml configures the library as 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>