-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from mbeddr/project-loader
RFC: Infrastructure to execute code with a project
- Loading branch information
Showing
36 changed files
with
1,379 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 10 additions & 75 deletions
85
execute-generators/src/main/kotlin/de/itemis/mps/gradle/generate/Main.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
`maven-publish` | ||
`java-gradle-plugin` | ||
} | ||
|
||
group = "de.itemis.mps" | ||
|
||
val mpsVersion: String by project | ||
val kotlinArgParserVersion: String by project | ||
|
||
val pluginVersion = "1" | ||
|
||
version = if (project.hasProperty("forceCI") || project.hasProperty("teamcity")) { | ||
de.itemis.mps.gradle.GitBasedVersioning.getVersion(mpsVersion, pluginVersion) | ||
} else { | ||
"$mpsVersion.$pluginVersion-SNAPSHOT" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { | ||
url = uri("https://projects.itemis.de/nexus/content/repositories/mbeddr") | ||
} | ||
} | ||
|
||
val mpsConfiguration = configurations.create("mps") | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
mpsConfiguration("com.jetbrains:mps:$mpsVersion") | ||
implementation("com.xenomachina:kotlin-argparser:$kotlinArgParserVersion") | ||
compileOnly(mpsConfiguration.resolve().map { zipTree(it) }.first().matching { include("lib/*.jar")}) | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package de.itemis.mps.gradle.project.loader | ||
|
||
import com.xenomachina.argparser.ArgParser | ||
import com.xenomachina.argparser.default | ||
import java.io.File | ||
|
||
private fun <T> splitAndCreate(str: String, creator: (String, String) -> T): T { | ||
val split = str.split(":") | ||
if (split.size < 2) { | ||
throw RuntimeException("string if not of the right format. Expected <key>:<value>") | ||
} | ||
return creator(split[0], split[1]) | ||
} | ||
|
||
private fun toMacro(str: String) = splitAndCreate(str, ::Macro) | ||
private fun toPlugin(str: String) = splitAndCreate(str, ::Plugin) | ||
|
||
/** | ||
* Default set of arguments required to start a "headless" MPS. This class should be used by other users of the | ||
* project-loader in order to establish a somewhat standardised command line interface. Passing instances of this or | ||
* subclasses to [executeWithProject] is directly supported. | ||
*/ | ||
open class Args(parser: ArgParser) { | ||
|
||
val plugins by parser.adding("--plugin", | ||
help = "plugin to to load. The format is --plugin=<path>:<id>") | ||
{ toPlugin(this) } | ||
|
||
val macros by parser.adding("--macro", | ||
help = "macro to define. The format is --macro=<name>:<value>") | ||
{ toMacro(this) } | ||
|
||
val pluginLocation by parser.storing("--plugin-location", | ||
help = "location to load additional plugins from") { File(this) }.default<File?>(null) | ||
|
||
val buildNumber by parser.storing("--build-number", | ||
help = "build number used to determine if the plugins are compatible").default<String?>(null) | ||
|
||
val project by parser.storing("--project", | ||
help = "project to generate from") { File(this) } | ||
} |
Oops, something went wrong.