Skip to content

Commit

Permalink
mps-cli-gradle-plugin: added a application to demonstrate the library
Browse files Browse the repository at this point in the history
  • Loading branch information
ratiud committed Dec 8, 2023
1 parent 2b23d8f commit 767c166
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mps-cli-gradle-plugin/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
5 changes: 5 additions & 0 deletions mps-cli-gradle-plugin/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins {

id 'maven-publish'
id 'com.gradle.plugin-publish' version '1.1.0'
id 'application'
}

// Project versions
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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())
}
}

0 comments on commit 767c166

Please sign in to comment.