diff options
Diffstat (limited to 'subprojects/language/build.gradle.kts')
-rw-r--r-- | subprojects/language/build.gradle.kts | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/subprojects/language/build.gradle.kts b/subprojects/language/build.gradle.kts new file mode 100644 index 00000000..bac1e586 --- /dev/null +++ b/subprojects/language/build.gradle.kts | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | import tools.refinery.gradle.utils.SonarPropertiesUtils | ||
8 | |||
9 | plugins { | ||
10 | id("tools.refinery.gradle.java-library") | ||
11 | id("tools.refinery.gradle.java-test-fixtures") | ||
12 | id("tools.refinery.gradle.mwe2") | ||
13 | id("tools.refinery.gradle.sonarqube") | ||
14 | id("tools.refinery.gradle.xtext-generated") | ||
15 | } | ||
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 | |||
27 | dependencies { | ||
28 | api(platform(libs.xtext.bom)) | ||
29 | api(libs.ecore) | ||
30 | api(libs.xtext.core) | ||
31 | api(libs.xtext.xbase) | ||
32 | api(project(":refinery-language-model")) | ||
33 | testFixturesApi(libs.xtext.testing) | ||
34 | mwe2(libs.xtext.generator) | ||
35 | mwe2(libs.xtext.generator.antlr) | ||
36 | } | ||
37 | |||
38 | sourceSets { | ||
39 | testFixtures { | ||
40 | java.srcDir("src/testFixtures/xtext-gen") | ||
41 | resources.srcDir("src/testFixtures/xtext-gen") | ||
42 | } | ||
43 | } | ||
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 | |||
59 | tasks { | ||
60 | jar { | ||
61 | from(sourceSets.main.map { it.allSource }) { | ||
62 | include("**/*.xtext") | ||
63 | } | ||
64 | } | ||
65 | |||
66 | syncXtextGeneratedSources { | ||
67 | // We generate Xtext runtime sources directly to {@code src/main/xtext-gen}, so there is no need to copy them | ||
68 | // from an artifact. We expose the {@code generatedIdeSources} and {@code generatedWebSources} artifacts to | ||
69 | // sibling IDE and web projects which can use this task to consume them and copy the appropriate sources to | ||
70 | // their own {@code src/main/xtext-gen} directory. | ||
71 | enabled = false | ||
72 | } | ||
73 | |||
74 | for (taskName in listOf("compileJava", "processResources", "compileTestFixturesJava", | ||
75 | "processTestFixturesResources", "generateEclipseSourceFolders")) { | ||
76 | named(taskName) { | ||
77 | dependsOn(generateXtextLanguage) | ||
78 | } | ||
79 | } | ||
80 | |||
81 | clean { | ||
82 | delete("src/main/xtext-gen") | ||
83 | delete("src/testFixtures/xtext-gen") | ||
84 | } | ||
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) | ||
94 | } | ||
95 | } | ||
96 | |||
97 | sonarqube.properties { | ||
98 | SonarPropertiesUtils.addToList(properties, "sonar.exclusions", "src/textFixtures/xtext-gen/**") | ||
99 | } | ||
100 | |||
101 | eclipse.project.natures.plusAssign("org.eclipse.xtext.ui.shared.xtextNature") | ||