From 767c16619289a059a06bcf31b6f8b5d63b60efc0 Mon Sep 17 00:00:00 2001 From: Daniel Ratiu Date: Fri, 8 Dec 2023 23:26:11 +0100 Subject: [PATCH] mps-cli-gradle-plugin: added a application to demonstrate the library --- mps-cli-gradle-plugin/Readme.md | 6 +++++ mps-cli-gradle-plugin/plugin/build.gradle | 5 ++++ .../main/groovy/org/mps_cli/MpsCliDemo.groovy | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/MpsCliDemo.groovy diff --git a/mps-cli-gradle-plugin/Readme.md b/mps-cli-gradle-plugin/Readme.md index 3d61b19..f0b0bc9 100644 --- a/mps-cli-gradle-plugin/Readme.md +++ b/mps-cli-gradle-plugin/Readme.md @@ -38,3 +38,9 @@ The plugin has currently the following limitations: - the extracted meta-information is based solely on the information saved in the model files - e.g. if a concept is not instantiated at all in the set of loaded models, the meta-information will not contain it at all - e.g. if a link of a concept is not set in any of its instances, the meta-information will not contain it at all + +### Demo application + +To quickly test the code, we packaged an application implemented in 'MpsCliDemo.groovy'. +To start the application run +`gradlew run --args PATH_TO_MPS_SOLUTIONS` \ No newline at end of file diff --git a/mps-cli-gradle-plugin/plugin/build.gradle b/mps-cli-gradle-plugin/plugin/build.gradle index 57d9c2c..52240a7 100644 --- a/mps-cli-gradle-plugin/plugin/build.gradle +++ b/mps-cli-gradle-plugin/plugin/build.gradle @@ -15,6 +15,7 @@ plugins { id 'maven-publish' id 'com.gradle.plugin-publish' version '1.1.0' + id 'application' } // Project versions @@ -89,6 +90,10 @@ if (System.env.CI != null && System.env.CI.toBoolean()) { version = "$major.$minor" } +application { + mainClass = 'org.mps_cli.MpsCliDemo' +} + publishing { repositories { maven { diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/MpsCliDemo.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/MpsCliDemo.groovy new file mode 100644 index 0000000..7b90531 --- /dev/null +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/MpsCliDemo.groovy @@ -0,0 +1,23 @@ +package org.mps_cli + +import org.mps_cli.model.SSolutionModule; +import org.mps_cli.model.builder.BuildingDepthEnum +import org.mps_cli.model.builder.SModulesRepositoryBuilder + +class MpsCliDemo { + + static void main(String[] args) { + if (args.length != 1) { + print("Usage: 'gradlew run --args PATH_TO_DIRECTORY_CONTAINING_MPS_SOLUTIONS") + exit(1) + } + println("Loading models from '${args[0]}' ...") + def builder = new SModulesRepositoryBuilder(buildingStrategy: BuildingDepthEnum.COMPLETE_MODEL) + def repo = builder.build(args[0]) + + println("Statistics:") + println("\t number of modules: " + repo.modules.findAll {it instanceof SSolutionModule }.size()) + println("\t number of models: " + repo.allModels().size()) + println("\t number of nodes: " + repo.allNodes().size()) + } +}