diff options
author | 2023-04-26 17:58:36 +0200 | |
---|---|---|
committer | 2023-04-26 17:58:36 +0200 | |
commit | d34b8e0f4db84f1571785592b523e675a1b2f960 (patch) | |
tree | 1e2e123ba2071a11070e8310b7e9e3033f8ffae1 /subprojects/language/build.gradle.kts | |
parent | build: enable parallel Gradle build (diff) | |
download | refinery-d34b8e0f4db84f1571785592b523e675a1b2f960.tar.gz refinery-d34b8e0f4db84f1571785592b523e675a1b2f960.tar.zst refinery-d34b8e0f4db84f1571785592b523e675a1b2f960.zip |
build: improve Xtext project isolation
* Avoid writing generated source files directly into sibling projects.
* Full project isolation cannot be enabled yet, because the frontend plugin
still requires cross-projects task dependencies for Node.js installation.
Diffstat (limited to 'subprojects/language/build.gradle.kts')
-rw-r--r-- | subprojects/language/build.gradle.kts | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/subprojects/language/build.gradle.kts b/subprojects/language/build.gradle.kts index aa799c3b..bac1e586 100644 --- a/subprojects/language/build.gradle.kts +++ b/subprojects/language/build.gradle.kts | |||
@@ -14,6 +14,16 @@ plugins { | |||
14 | id("tools.refinery.gradle.xtext-generated") | 14 | id("tools.refinery.gradle.xtext-generated") |
15 | } | 15 | } |
16 | 16 | ||
17 | val generatedIdeSources: Configuration by configurations.creating { | ||
18 | isCanBeConsumed = true | ||
19 | isCanBeResolved = false | ||
20 | } | ||
21 | |||
22 | val generatedWebSources: Configuration by configurations.creating { | ||
23 | isCanBeConsumed = true | ||
24 | isCanBeResolved = false | ||
25 | } | ||
26 | |||
17 | dependencies { | 27 | dependencies { |
18 | api(platform(libs.xtext.bom)) | 28 | api(platform(libs.xtext.bom)) |
19 | api(libs.ecore) | 29 | api(libs.ecore) |
@@ -32,6 +42,20 @@ sourceSets { | |||
32 | } | 42 | } |
33 | } | 43 | } |
34 | 44 | ||
45 | val generateXtextLanguage by tasks.registering(JavaExec::class) { | ||
46 | mainClass.set("org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher") | ||
47 | classpath(configurations.mwe2) | ||
48 | inputs.file("src/main/java/tools/refinery/language/GenerateProblem.mwe2") | ||
49 | inputs.file("src/main/java/tools/refinery/language/Problem.xtext") | ||
50 | inputs.file("../language-model/src/main/resources/model/problem.ecore") | ||
51 | inputs.file("../language-model/src/main/resources/model/problem.genmodel") | ||
52 | outputs.dir("src/main/xtext-gen") | ||
53 | outputs.dir("src/testFixtures/xtext-gen") | ||
54 | outputs.dir("$buildDir/generated/sources/xtext/ide") | ||
55 | outputs.dir("$buildDir/generated/sources/xtext/web") | ||
56 | args("src/main/java/tools/refinery/language/GenerateProblem.mwe2", "-p", "rootPath=/$projectDir/..") | ||
57 | } | ||
58 | |||
35 | tasks { | 59 | tasks { |
36 | jar { | 60 | jar { |
37 | from(sourceSets.main.map { it.allSource }) { | 61 | from(sourceSets.main.map { it.allSource }) { |
@@ -39,20 +63,16 @@ tasks { | |||
39 | } | 63 | } |
40 | } | 64 | } |
41 | 65 | ||
42 | val generateXtextLanguage by registering(JavaExec::class) { | 66 | syncXtextGeneratedSources { |
43 | mainClass.set("org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher") | 67 | // We generate Xtext runtime sources directly to {@code src/main/xtext-gen}, so there is no need to copy them |
44 | classpath(configurations.mwe2) | 68 | // from an artifact. We expose the {@code generatedIdeSources} and {@code generatedWebSources} artifacts to |
45 | inputs.file("src/main/java/tools/refinery/language/GenerateProblem.mwe2") | 69 | // sibling IDE and web projects which can use this task to consume them and copy the appropriate sources to |
46 | inputs.file("src/main/java/tools/refinery/language/Problem.xtext") | 70 | // their own {@code src/main/xtext-gen} directory. |
47 | outputs.dir("src/main/xtext-gen") | 71 | enabled = false |
48 | outputs.dir("src/testFixtures/xtext-gen") | ||
49 | outputs.dir("../language-ide/src/main/xtext-gen") | ||
50 | outputs.dir("../language-web/src/main/xtext-gen") | ||
51 | args("src/main/java/tools/refinery/language/GenerateProblem.mwe2", "-p", "rootPath=/$projectDir/..") | ||
52 | } | 72 | } |
53 | 73 | ||
54 | for (taskName in listOf("compileJava", "processResources", "processTestFixturesResources", | 74 | for (taskName in listOf("compileJava", "processResources", "compileTestFixturesJava", |
55 | "generateEclipseSourceFolders")) { | 75 | "processTestFixturesResources", "generateEclipseSourceFolders")) { |
56 | named(taskName) { | 76 | named(taskName) { |
57 | dependsOn(generateXtextLanguage) | 77 | dependsOn(generateXtextLanguage) |
58 | } | 78 | } |
@@ -61,8 +81,16 @@ tasks { | |||
61 | clean { | 81 | clean { |
62 | delete("src/main/xtext-gen") | 82 | delete("src/main/xtext-gen") |
63 | delete("src/testFixtures/xtext-gen") | 83 | delete("src/testFixtures/xtext-gen") |
64 | delete("../language-ide/src/main/xtext-gen") | 84 | } |
65 | delete("../language-web/src/main/xtext-gen") | 85 | } |
86 | |||
87 | artifacts { | ||
88 | add(generatedIdeSources.name, file("$buildDir/generated/sources/xtext/ide")) { | ||
89 | builtBy(generateXtextLanguage) | ||
90 | } | ||
91 | |||
92 | add(generatedWebSources.name, file("$buildDir/generated/sources/xtext/web")) { | ||
93 | builtBy(generateXtextLanguage) | ||
66 | } | 94 | } |
67 | } | 95 | } |
68 | 96 | ||