diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-04-08 22:56:44 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-04-08 22:58:21 +0200 |
commit | 561fac70fd3dc3ebe1cfbc50146757495fb828d5 (patch) | |
tree | 20aa72bbe438aaa70c8de264ff0d366758e7772d /subprojects/language-web | |
parent | refactor: remove TupleLike (diff) | |
download | refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.tar.gz refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.tar.zst refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.zip |
build: convert Gradle scripts to Kotlin
Improves IDE support build scripts in IntelliJ.
There is no Eclipse IDE support, but Eclipse didn't have support for Groovy
either, so there is no degradation of functionality.
Diffstat (limited to 'subprojects/language-web')
-rw-r--r-- | subprojects/language-web/build.gradle | 87 | ||||
-rw-r--r-- | subprojects/language-web/build.gradle.kts | 91 |
2 files changed, 91 insertions, 87 deletions
diff --git a/subprojects/language-web/build.gradle b/subprojects/language-web/build.gradle deleted file mode 100644 index 8d277a5b..00000000 --- a/subprojects/language-web/build.gradle +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'refinery-java-application' | ||
3 | id 'refinery-xtext-conventions' | ||
4 | } | ||
5 | |||
6 | configurations { | ||
7 | webapp { | ||
8 | canBeConsumed = false | ||
9 | canBeResolved = true | ||
10 | } | ||
11 | |||
12 | all { | ||
13 | // Use log4j-over-slf4j instead of log4j 1.x | ||
14 | exclude group: 'log4j', module: 'log4j' | ||
15 | } | ||
16 | } | ||
17 | |||
18 | dependencies { | ||
19 | implementation project(':refinery-language') | ||
20 | implementation project(':refinery-language-ide') | ||
21 | implementation libs.jetty.server | ||
22 | implementation libs.jetty.servlet | ||
23 | implementation libs.jetty.websocket.server | ||
24 | implementation libs.slf4j.api | ||
25 | implementation libs.slf4j.simple | ||
26 | implementation libs.slf4j.log4j | ||
27 | implementation libs.xtext.web | ||
28 | webapp project(path: ':refinery-frontend', configuration: 'productionAssets') | ||
29 | testImplementation testFixtures(project(':refinery-language')) | ||
30 | testImplementation libs.jetty.websocket.client | ||
31 | } | ||
32 | |||
33 | def generateXtextLanguage = project(':refinery-language').tasks.named('generateXtextLanguage') | ||
34 | |||
35 | for (taskName in ['compileJava', 'processResources']) { | ||
36 | tasks.named(taskName) { | ||
37 | dependsOn generateXtextLanguage | ||
38 | } | ||
39 | } | ||
40 | |||
41 | mainClassName = 'tools.refinery.language.web.ServerLauncher' | ||
42 | |||
43 | // Enable JDK 19 preview features for virtual thread support. | ||
44 | application { | ||
45 | applicationDefaultJvmArgs += '--enable-preview' | ||
46 | } | ||
47 | tasks.withType(JavaCompile) { | ||
48 | options.release = 19 | ||
49 | options.compilerArgs += '--enable-preview' | ||
50 | } | ||
51 | tasks.withType(Test) { | ||
52 | jvmArgs += '--enable-preview' | ||
53 | } | ||
54 | |||
55 | tasks.named('jar') { | ||
56 | dependsOn project.configurations.webapp | ||
57 | from(project.configurations.webapp) { | ||
58 | into 'webapp' | ||
59 | } | ||
60 | } | ||
61 | |||
62 | tasks.named('shadowJar') { | ||
63 | dependsOn project.configurations.webapp | ||
64 | from(project.sourceSets.main.output) | ||
65 | configurations = [project.configurations.runtimeClasspath] | ||
66 | exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*', | ||
67 | '.options', '.api_description', '*.profile', 'about.*', 'about_*.html', 'about_files/*', | ||
68 | 'plugin.xml', 'systembundle.properties', 'profile.list', 'META-INF/resources/xtext/**') | ||
69 | append('plugin.properties') | ||
70 | from(project.configurations.webapp) { | ||
71 | into 'webapp' | ||
72 | } | ||
73 | } | ||
74 | |||
75 | tasks.register('serveBackend', JavaExec) { | ||
76 | dependsOn project.configurations.webapp | ||
77 | dependsOn sourceSets.main.runtimeClasspath | ||
78 | classpath = sourceSets.main.runtimeClasspath | ||
79 | mainClass = mainClassName | ||
80 | // Enable JDK 19 preview features for virtual thread support. | ||
81 | jvmArgs += '--enable-preview' | ||
82 | standardInput = System.in | ||
83 | def baseResource = project.configurations.webapp.incoming.artifacts.artifactFiles.first() | ||
84 | environment BASE_RESOURCE: baseResource | ||
85 | group = 'run' | ||
86 | description = 'Start a Jetty web server serving the Xtex API and assets.' | ||
87 | } | ||
diff --git a/subprojects/language-web/build.gradle.kts b/subprojects/language-web/build.gradle.kts new file mode 100644 index 00000000..c68daa9a --- /dev/null +++ b/subprojects/language-web/build.gradle.kts | |||
@@ -0,0 +1,91 @@ | |||
1 | plugins { | ||
2 | id("refinery-java-application") | ||
3 | id("refinery-xtext-conventions") | ||
4 | } | ||
5 | |||
6 | val webapp: Configuration by configurations.creating { | ||
7 | isCanBeConsumed = false | ||
8 | isCanBeResolved = true | ||
9 | } | ||
10 | |||
11 | configurations.all { | ||
12 | // Use log4j-over-slf4j instead of log4j 1.x | ||
13 | exclude(group = "log4j", module = "log4j") | ||
14 | } | ||
15 | |||
16 | dependencies { | ||
17 | implementation(project(":refinery-language")) | ||
18 | implementation(project(":refinery-language-ide")) | ||
19 | implementation(libs.jetty.server) | ||
20 | implementation(libs.jetty.servlet) | ||
21 | implementation(libs.jetty.websocket.server) | ||
22 | implementation(libs.slf4j.api) | ||
23 | implementation(libs.slf4j.simple) | ||
24 | implementation(libs.slf4j.log4j) | ||
25 | implementation(libs.xtext.web) | ||
26 | webapp(project(path = ":refinery-frontend", configuration = "productionAssets")) | ||
27 | testImplementation(testFixtures(project(":refinery-language"))) | ||
28 | testImplementation(libs.jetty.websocket.client) | ||
29 | } | ||
30 | |||
31 | val generateXtextLanguage = project(":refinery-language").tasks.named("generateXtextLanguage") | ||
32 | |||
33 | for (taskName in listOf("compileJava", "processResources")) { | ||
34 | tasks.named(taskName) { | ||
35 | dependsOn(generateXtextLanguage) | ||
36 | } | ||
37 | } | ||
38 | |||
39 | application { | ||
40 | mainClass.set("tools.refinery.language.web.ServerLauncher") | ||
41 | // Enable JDK 19 preview features for virtual thread support. | ||
42 | applicationDefaultJvmArgs += "--enable-preview" | ||
43 | } | ||
44 | |||
45 | tasks.withType(JavaCompile::class) { | ||
46 | options.release.set(19) | ||
47 | // Enable JDK 19 preview features for virtual thread support. | ||
48 | options.compilerArgs.plusAssign("--enable-preview") | ||
49 | } | ||
50 | |||
51 | // Enable JDK 19 preview features for virtual thread support. | ||
52 | fun enablePreview(task: JavaForkOptions) { | ||
53 | task.jvmArgs("--enable-preview") | ||
54 | } | ||
55 | |||
56 | tasks.withType(Test::class) { | ||
57 | enablePreview(this) | ||
58 | } | ||
59 | |||
60 | tasks.jar { | ||
61 | dependsOn(webapp) | ||
62 | from(webapp) { | ||
63 | into("webapp") | ||
64 | } | ||
65 | } | ||
66 | |||
67 | tasks.shadowJar { | ||
68 | dependsOn(webapp) | ||
69 | from(project.sourceSets.main.map { it.output }) | ||
70 | exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA","schema/*", | ||
71 | ".options", ".api_description", "*.profile", "about.*", "about_*.html", "about_files/*", | ||
72 | "plugin.xml", "systembundle.properties", "profile.list", "META-INF/resources/xtext/**") | ||
73 | append("plugin.properties") | ||
74 | from(webapp) { | ||
75 | into("webapp") | ||
76 | } | ||
77 | } | ||
78 | |||
79 | tasks.register("serveBackend", JavaExec::class) { | ||
80 | dependsOn(webapp) | ||
81 | val mainRuntimeClasspath = sourceSets.main.map { it.runtimeClasspath } | ||
82 | dependsOn(mainRuntimeClasspath) | ||
83 | classpath(mainRuntimeClasspath) | ||
84 | mainClass.set(application.mainClass) | ||
85 | enablePreview(this) | ||
86 | standardInput = System.`in` | ||
87 | val baseResource = webapp.incoming.artifacts.artifactFiles.first() | ||
88 | environment("BASE_RESOURCE", baseResource) | ||
89 | group = "run" | ||
90 | description = "Start a Jetty web server serving the Xtex API and assets." | ||
91 | } | ||