Skip to content

Commit

Permalink
Merge pull request #55 from jenzb/refactor/mps20193
Browse files Browse the repository at this point in the history
Refactor/mps20193
  • Loading branch information
wsafonov authored Mar 6, 2020
2 parents 7a596a7 + 4dec372 commit a4a8f3c
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 31 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Parameters:
* `mpsConfig` - the configuration used to resolve MPS. Currently only vanilla MPS is supported and no custom RCPs.
Custom plugins are supported via the `pluginLocation` parameter.
* `mpsLocation` - optional location where to place the MPS files.
* `javaExec` - optional `java` executable to use.
* `plugins` - optional list of plugins to load before generation is attempted.
The notation is `new Plugin("someID", "somePath")`. Where the first parameter is the plugin id and the second the `short (folder) name`.
* `pluginLocation` - location where to load the plugins from. Structure needs to be a flat folder structure similar to the
Expand Down Expand Up @@ -267,6 +268,7 @@ Parameters:
* `mpsConfig` - the configuration used to resolve MPS. Currently only vanilla MPS is supported and no custom RCPs.
Custom plugins are supported via the `pluginLocation` parameter.
* `mpsLocation` - optional location where to place the MPS files.
* `javaExec` - optional `java` executable to use.
* `plugins` - optional list of plugins to load before model check is attempted.
The notation is `new Plugin("someID", "somePath")`. Where the first parameter is the plugin id and the second the `short (folder) name`.
* `pluginLocation` - location where to load the plugins from. Structure needs to be a flat folder structure similar to the
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

val versionMajor = 1
val versionMinor = 3
val versionMinor = 4

group = "de.itemis.mps"

Expand All @@ -23,7 +23,7 @@ val nexusUsername: String? by project
val nexusPassword: String? by project

val kotlinArgParserVersion by extra { "2.0.7" }
val mpsVersion by extra { "2019.2.4" }
val mpsVersion by extra { "2019.3.3" }


version = if (!project.hasProperty("useSnapshot") &&
Expand Down
6 changes: 1 addition & 5 deletions project-loader/src/main/kotlin/Loader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ fun <T> executeWithProject(project: File,
val cfg = basicEnvironmentConfig()

plugins.forEach { cfg.addPreInstalledPlugin(it.path, it.id) }
macros.forEach { cfg.addMacro(it.name, File(it.value)) }

val ideaEnvironment = IdeaEnvironment(cfg)

Expand All @@ -109,11 +110,6 @@ fun <T> executeWithProject(project: File,
logger.info("flushing events")
ideaEnvironment.flushAllEvents()

val pathMacros = PathMacros.getInstance()
// macros should not contain any backslashes from Windows-specific paths
// otherwise this might lead to exceptions in MPS (e.g. when loading libraries from paths with macros)
macros.forEach { pathMacros.setMacro(it.name, it.value.replace(File.separatorChar, '/')) }

logger.info("opening project: ${project.absolutePath}")
val ideaProject = ideaEnvironment.openProject(project)

Expand Down
5 changes: 3 additions & 2 deletions src/main/groovy/de/itemis/mps/gradle/CreateDmg.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.itemis.mps.gradle
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.artifacts.Dependency
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
Expand All @@ -21,10 +22,10 @@ class CreateDmg extends DefaultTask {
@OutputFile
File dmgFile

@Optional
@Optional @Input
String signKeyChainPassword

@Optional
@Optional @Input
String signIdentity

@InputFile @Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ package de.itemis.mps.gradle

import groovy.xml.MarkupBuilder
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

class GenerateLibrariesXml extends DefaultTask {
@InputFile
File defaults

@InputFile @Optional
File overrides

@OutputFile
Expand Down
2 changes: 2 additions & 0 deletions src/main/groovy/de/itemis/mps/gradle/GetMpsInBrowser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package de.itemis.mps.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import org.apache.tools.ant.taskdefs.condition.Os

import java.awt.Desktop

class GetMpsInBrowser extends DefaultTask {

@Input
String version

def setVersion(String version) {
Expand Down
10 changes: 9 additions & 1 deletion src/main/kotlin/de/itemis/mps/gradle/Common.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package de.itemis.mps.gradle

import org.apache.log4j.Logger
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.JavaVersion
import org.gradle.api.artifacts.Configuration
import java.io.File

private val logger = Logger.getLogger("de.itemis.mps.gradle.common")

data class Plugin(
var id: String,
var path: String
Expand All @@ -23,6 +26,11 @@ open class BasePluginExtensions {
var macros: List<Macro> = emptyList()
var projectLocation: File? = null
var debug = false
var javaExec: File? = null
}

fun validateDefaultJvm(){
if (JavaVersion.current() != JavaVersion.VERSION_11) logger.error("MPS requires Java 11 but current JVM uses ${JavaVersion.current()}, starting MPS will most probably fail!")
}

fun argsFromBaseExtension(extensions: BasePluginExtensions): MutableList<String> {
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/de/itemis/mps/gradle/RunAntScript.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ package de.itemis.mps.gradle;

import org.gradle.api.DefaultTask
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction

open class RunAntScript : DefaultTask() {
@Input
lateinit var script: Any
@Input
var targets: List<String> = emptyList()
@Optional @InputFiles
var scriptClasspath: FileCollection? = null
@Input
var scriptArgs: List<String> = emptyList()
@Input
var includeDefaultArgs = true
@Input
var includeDefaultClasspath = true
@Optional @Input
var executable: Any? = null

fun targets(vararg targets: String) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/de/itemis/mps/gradle/generate/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.itemis.mps.gradle.generate

import de.itemis.mps.gradle.BasePluginExtensions
import de.itemis.mps.gradle.argsFromBaseExtension
import de.itemis.mps.gradle.validateDefaultJvm
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -91,12 +92,17 @@ open class GenerateMpsProjectPlugin : Plugin<Project> {
tasks.create("generate", JavaExec::class.java) {
dependsOn(fake)
args(args)
if (extension.javaExec != null)
executable(extension.javaExec!!)
else
validateDefaultJvm()
group = "build"
description = "Generates models in the project"
classpath(fileTree(File(mpsLocation, "/lib")).include("**/*.jar"))
// add only minimal number of plugins jars that are required by the generate code
// (to avoid conflicts with plugin classloader if custom configured plugins are loaded)
//classpath(fileTree(File(mpsLocation, "/plugins")).include("<plugin-folder>/**/*.jar"))
// git4idea: has to be on classpath as bundled plugin to be loaded (since 2019.3)
classpath(fileTree(File(mpsLocation, "/plugins")).include("git4idea/**/*.jar"))
classpath(genConfig)
debug = extension.debug
main = "de.itemis.mps.gradle.generate.MainKt"
Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/de/itemis/mps/gradle/modelcheck/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.itemis.mps.gradle.modelcheck

import de.itemis.mps.gradle.BasePluginExtensions
import de.itemis.mps.gradle.argsFromBaseExtension
import de.itemis.mps.gradle.validateDefaultJvm
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -91,6 +92,11 @@ open class ModelcheckMpsProjectPlugin : Plugin<Project> {
tasks.create("checkmodels", JavaExec::class.java) {
dependsOn(resolveMps)
args(args)
if (extension.javaExec != null)
executable(extension.javaExec!!)
else
validateDefaultJvm()

group = "test"
description = "Check models in the project"
if (extension.maxHeap != null) {
Expand All @@ -101,7 +107,8 @@ open class ModelcheckMpsProjectPlugin : Plugin<Project> {
// (to avoid conflicts with plugin classloader if custom configured plugins are loaded)
// mps-httpsupport: we need it to print the node url to the console.
// mps-modelchecker: contains used UnresolvedReferencesChecker
classpath(fileTree(File(mpsLocation, "/plugins")).include("mps-modelchecker/**/*.jar", "mps-httpsupport/**/*.jar"))
// git4idea: has to be on classpath as bundled plugin to be loaded (since 2019.3)
classpath(fileTree(File(mpsLocation, "/plugins")).include("mps-modelchecker/**/*.jar", "mps-httpsupport/**/*.jar", "git4idea/**/*.jar"))
classpath(genConfig)
debug = extension.debug
main = "de.itemis.mps.gradle.modelcheck.MainKt"
Expand Down
7 changes: 3 additions & 4 deletions test/generate-build-solution/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
group = "test.de.itemis.mps.gradle.generate"
version = "1.2-SNAPSHOT"
version = "1.3-SNAPSHOT"

plugins {
id("generate-models") version "1.2-SNAPSHOT"
id("generate-models") version "1.3-SNAPSHOT"
}

repositories {
Expand All @@ -14,8 +14,7 @@ repositories {
}

val mps = configurations.create("mps")

val mpsVersion = "2019.2.4"
val mpsVersion = "2019.3.2"

dependencies {
mps("com.jetbrains:mps:$mpsVersion")
Expand Down
1 change: 1 addition & 0 deletions test/generate-build-solution/mps-prj/.mps/migration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<entry key="jetbrains.mps.ide.mpsmigration.v182.ReapplyPatternMigration" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.SaveAllJavaStubMethodRefsToShortForeignFormat" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.UpdateJavaStubMethodRefs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2019_3.DefaultFacetExplicitPersistence" value="executed" />
</component>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<dependencies>
<dependency reexport="false">422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<dependencies>
<dependency reexport="false">6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)</dependency>
Expand All @@ -18,7 +23,7 @@
<language slang="l:a247e09e-2435-45ba-b8d2-07e93feba96a:jetbrains.mps.baseLanguage.tuples" version="0" />
<language slang="l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core" version="2" />
<language slang="l:446c26eb-2b7b-4bf0-9b35-f83fa582753e:jetbrains.mps.lang.modelapi" version="0" />
<language slang="l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation" version="3" />
<language slang="l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation" version="4" />
<language slang="l:7866978e-a0f0-4cc7-81bc-4d213d9375e1:jetbrains.mps.lang.smodel" version="17" />
<language slang="l:c7fb639f-be78-4307-89b0-b5959c3fa8c8:jetbrains.mps.lang.text" version="0" />
<language slang="l:9ded098b-ad6a-4657-bfd9-48636cfe8bc3:jetbrains.mps.lang.traceable" version="0" />
Expand Down
7 changes: 3 additions & 4 deletions test/generate-simple/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
group = "test.de.itemis.mps.gradle.generate"
version = "1.2-SNAPSHOT"
version = "1.3-SNAPSHOT"

plugins {
id("generate-models") version "1.2-SNAPSHOT"
id("generate-models") version "1.3-SNAPSHOT"
}

repositories {
Expand All @@ -14,8 +14,7 @@ repositories {
}

val mps = configurations.create("mps")

val mpsVersion = "2019.2.4"
val mpsVersion = "2019.3.2"

dependencies {
mps("com.jetbrains:mps:$mpsVersion")
Expand Down
1 change: 1 addition & 0 deletions test/generate-simple/mps-prj/.mps/migration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<entry key="jetbrains.mps.ide.mpsmigration.v182.ReapplyPatternMigration" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.SaveAllJavaStubMethodRefsToShortForeignFormat" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.UpdateJavaStubMethodRefs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2019_3.DefaultFacetExplicitPersistence" value="executed" />
</component>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<dependencies>
<dependency reexport="false">6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)</dependency>
Expand All @@ -18,7 +23,7 @@
<language slang="l:a247e09e-2435-45ba-b8d2-07e93feba96a:jetbrains.mps.baseLanguage.tuples" version="0" />
<language slang="l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core" version="2" />
<language slang="l:446c26eb-2b7b-4bf0-9b35-f83fa582753e:jetbrains.mps.lang.modelapi" version="0" />
<language slang="l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation" version="3" />
<language slang="l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation" version="4" />
<language slang="l:7866978e-a0f0-4cc7-81bc-4d213d9375e1:jetbrains.mps.lang.smodel" version="17" />
<language slang="l:c7fb639f-be78-4307-89b0-b5959c3fa8c8:jetbrains.mps.lang.text" version="0" />
<language slang="l:9ded098b-ad6a-4657-bfd9-48636cfe8bc3:jetbrains.mps.lang.traceable" version="0" />
Expand Down
14 changes: 6 additions & 8 deletions test/modelcheck/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import java.net.URI

group = "test.de.itemis.mps.gradle.modelcheck"
version = "1.2-SNAPSHOT"
version = "1.3-SNAPSHOT"

plugins {
id("modelcheck") version "1.2-SNAPSHOT"
id("modelcheck") version "1.3-SNAPSHOT"
}

repositories {
Expand All @@ -16,8 +16,7 @@ repositories {
}

var mps = configurations.create("mps")

val mpsVersion = "2019.2.4"
val mpsVersion = "2019.3.2"

dependencies{
mps("com.jetbrains:mps:$mpsVersion")
Expand All @@ -26,11 +25,10 @@ dependencies{
modelcheck {
mpsConfig = mps
projectLocation = file("$rootDir/mps-prj")
modules = listOf("my.solution")
/*
//modules = listOf("my.solution")

modules = listOf("my.solution.with.errors")
junitFile = file("$buildDir/TEST-modelcheck-results.xml")
errorNoFail = true
*/
//errorNoFail = true
//debug = true
}
1 change: 1 addition & 0 deletions test/modelcheck/mps-prj/.mps/migration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<entry key="jetbrains.mps.ide.mpsmigration.v182.ReapplyPatternMigration" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.SaveAllJavaStubMethodRefsToShortForeignFormat" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.UpdateJavaStubMethodRefs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2019_3.DefaultFacetExplicitPersistence" value="executed" />
</component>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<languageVersions>
<language slang="l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage" version="9" />
Expand Down
Loading

0 comments on commit a4a8f3c

Please sign in to comment.