diff options
Diffstat (limited to 'language-web/build.gradle')
-rw-r--r-- | language-web/build.gradle | 144 |
1 files changed, 81 insertions, 63 deletions
diff --git a/language-web/build.gradle b/language-web/build.gradle index cee7b946..9e67f4e0 100644 --- a/language-web/build.gradle +++ b/language-web/build.gradle | |||
@@ -1,64 +1,98 @@ | |||
1 | apply plugin: 'java' | ||
1 | apply from: "${rootDir}/gradle/xtext-common.gradle" | 2 | apply from: "${rootDir}/gradle/xtext-common.gradle" |
2 | 3 | ||
3 | dependencies { | 4 | dependencies { |
4 | compile project(':language') | 5 | implementation project(':refinery-language') |
5 | compile project(':language-ide') | 6 | implementation project(':refinery-language-ide') |
6 | compile "org.eclipse.xtext:org.eclipse.xtext.xbase.web:${xtextVersion}" | 7 | implementation "org.eclipse.xtext:org.eclipse.xtext.xbase.web:${xtextVersion}" |
7 | compile "org.eclipse.xtext:org.eclipse.xtext.web.servlet:${xtextVersion}" | 8 | implementation "org.eclipse.xtext:org.eclipse.xtext.web.servlet:${xtextVersion}" |
8 | compile "org.eclipse.xtend:org.eclipse.xtend.lib:${xtextVersion}" | 9 | implementation "org.eclipse.xtend:org.eclipse.xtend.lib:${xtextVersion}" |
9 | compile "org.eclipse.jetty:jetty-server:${jettyVersion}" | 10 | implementation "org.eclipse.jetty:jetty-server:${jettyVersion}" |
10 | compile "org.eclipse.jetty:jetty-servlet:${jettyVersion}" | 11 | implementation "org.eclipse.jetty:jetty-servlet:${jettyVersion}" |
11 | compile "org.slf4j:slf4j-simple:${slf4JVersion}" | 12 | implementation "org.slf4j:slf4j-simple:${slf4JVersion}" |
13 | } | ||
14 | |||
15 | def generateXtext = project(':refinery-language').tasks.named('generateXtext') | ||
16 | |||
17 | tasks.named('compileJava') { | ||
18 | dependsOn generateXtext | ||
19 | } | ||
20 | |||
21 | tasks.named('processResources') { | ||
22 | dependsOn generateXtext | ||
12 | } | 23 | } |
13 | 24 | ||
14 | def webpackOutputDir = "${buildDir}/webpack" | 25 | def webpackOutputDir = "${buildDir}/webpack" |
15 | def productionResources = "${webpackOutputDir}/production" | 26 | def productionResources = "${webpackOutputDir}/production" |
16 | def mainClass = 'org.eclipse.viatra.solver.language.web.ServerLauncher' | 27 | def mainClass = 'org.eclipse.viatra.solver.language.web.ServerLauncher' |
17 | 28 | ||
18 | apply plugin: 'com.moowork.node' | 29 | apply plugin: 'org.siouan.frontend-jdk11' |
19 | 30 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpmYarn | |
20 | node { | 31 | |
21 | version = nodeVersion | 32 | frontend { |
22 | npmVersion = project.ext.npmVersion | 33 | nodeVersion = project.ext.nodeVersion |
23 | download = true | 34 | nodeInstallDirectory = file("${rootDir}/.gradle/node") |
24 | } | 35 | yarnEnabled = true |
25 | 36 | yarnVersion = project.ext.yarnVersion | |
26 | for (environment in ['production', 'development']) { | 37 | yarnInstallDirectory = file("${rootDir}/.gradle/yarn") |
27 | def taskName = 'webpack' + environment.substring(0, 1).toUpperCase() + environment.substring(1); | 38 | assembleScript = 'run assemble' |
28 | task(taskName, type: NpmTask) { | ||
29 | dependsOn ':language:generateXtext' | ||
30 | dependsOn npmInstall | ||
31 | inputs.dir 'src/main/css' | ||
32 | inputs.dir 'src/main/html' | ||
33 | inputs.dir 'src/main/js' | ||
34 | inputs.dir "${buildDir}/generated/sources/xtext/js" | ||
35 | inputs.file 'webpack.config.js' | ||
36 | outputs.dir "${webpackOutputDir}/${environment}" | ||
37 | args = ['run', 'build'] | ||
38 | setEnvironment NODE_ENV: environment | ||
39 | } | ||
40 | } | 39 | } |
41 | 40 | ||
42 | apply plugin: 'application' | 41 | tasks.named('installFrontend') { |
43 | mainClassName = mainClass | 42 | inputs.files('package.json', 'yarn.lock') |
44 | distTar.enabled = false | 43 | } |
45 | distZip.enabled = false | 44 | |
45 | def assembleFrontend = tasks.named('assembleFrontend') | ||
46 | assembleFrontend.configure { | ||
47 | dependsOn generateXtext | ||
48 | inputs.dir 'src/main/css' | ||
49 | inputs.dir 'src/main/html' | ||
50 | inputs.dir 'src/main/js' | ||
51 | inputs.dir "${buildDir}/generated/sources/xtext/js" | ||
52 | inputs.files('package.json', 'yarn.lock', 'webpack.config.js') | ||
53 | outputs.dir productionResources | ||
54 | } | ||
55 | |||
56 | def eslint = tasks.register('eslint', RunNpmYarn) { | ||
57 | inputs.dir 'src/main/js' | ||
58 | inputs.files('.eslintrc.js', 'tsconfig.json') | ||
59 | script = 'run check:eslint' | ||
60 | group = 'verification' | ||
61 | description = 'Check for TypeScript errors.' | ||
62 | } | ||
63 | |||
64 | def stylelint = tasks.register('stylelint', RunNpmYarn) { | ||
65 | inputs.dir 'src/main/css' | ||
66 | inputs.file '.stylelintrc.js' | ||
67 | script = 'run check:stylelint' | ||
68 | group = 'verification' | ||
69 | description = 'Check for Sass errors.' | ||
70 | } | ||
46 | 71 | ||
47 | jar { | 72 | tasks.named('check') { |
48 | dependsOn webpackProduction | 73 | dependsOn(eslint, stylelint) |
74 | } | ||
75 | |||
76 | tasks.named('jar') { | ||
77 | dependsOn assembleFrontend | ||
49 | from(productionResources) { | 78 | from(productionResources) { |
50 | into 'webapp' | 79 | into 'webapp' |
51 | } | 80 | } |
52 | } | 81 | } |
53 | 82 | ||
83 | apply plugin: 'application' | ||
84 | mainClassName = mainClass | ||
85 | distTar.enabled = false | ||
86 | distZip.enabled = false | ||
87 | |||
54 | apply plugin: 'com.github.johnrengelman.shadow' | 88 | apply plugin: 'com.github.johnrengelman.shadow' |
55 | shadowDistTar.enabled = false | 89 | shadowDistTar.enabled = false |
56 | shadowDistZip.enabled = false | 90 | shadowDistZip.enabled = false |
57 | 91 | ||
58 | shadowJar { | 92 | tasks.named('shadowJar') { |
59 | dependsOn webpackProduction | 93 | dependsOn assembleFrontend |
60 | from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output) | 94 | from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output) |
61 | configurations = [project.configurations.runtime] | 95 | configurations = [project.configurations.runtimeClasspath] |
62 | exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*', | 96 | exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*', |
63 | '.options', '.api_description', '*.profile', 'about.*', 'about_*.html', 'about_files/*', | 97 | '.options', '.api_description', '*.profile', 'about.*', 'about_*.html', 'about_files/*', |
64 | 'plugin.xml', 'systembundle.properties', 'profile.list', 'META-INF/resources/xtext/**') | 98 | 'plugin.xml', 'systembundle.properties', 'profile.list', 'META-INF/resources/xtext/**') |
@@ -68,8 +102,8 @@ shadowJar { | |||
68 | } | 102 | } |
69 | } | 103 | } |
70 | 104 | ||
71 | task jettyRun(type: JavaExec) { | 105 | def jettyRun = tasks.register('jettyRun', JavaExec) { |
72 | shouldRunAfter webpackProduction | 106 | shouldRunAfter assembleFrontend |
73 | dependsOn sourceSets.main.runtimeClasspath | 107 | dependsOn sourceSets.main.runtimeClasspath |
74 | classpath = sourceSets.main.runtimeClasspath.filter{it.exists()} | 108 | classpath = sourceSets.main.runtimeClasspath.filter{it.exists()} |
75 | main = mainClass | 109 | main = mainClass |
@@ -79,46 +113,30 @@ task jettyRun(type: JavaExec) { | |||
79 | description = 'Start a Jetty web server serving the Xtex API and assets (without rebuilding assets).' | 113 | description = 'Start a Jetty web server serving the Xtex API and assets (without rebuilding assets).' |
80 | } | 114 | } |
81 | 115 | ||
82 | task jettyRunAssets { | 116 | tasks.register('jettyRunAssets') { |
83 | dependsOn webpackProduction | 117 | dependsOn assembleFrontend |
84 | dependsOn jettyRun | 118 | dependsOn jettyRun |
85 | group = 'run' | 119 | group = 'run' |
86 | description = 'Rebuild assets and start a Jetty web server serving the Xtex API and assets.' | 120 | description = 'Rebuild assets and start a Jetty web server serving the Xtex API and assets.' |
87 | } | 121 | } |
88 | 122 | ||
89 | task webpackServe(type: NpmTask) { | 123 | tasks.register('webpackServe', RunNpmYarn) { |
90 | dependsOn ':language:generateXtext' | 124 | dependsOn generateXtext |
91 | dependsOn npmInstall | 125 | outputs.dir "${webpackOutputDir}/development" |
92 | outputs.dir "${webpackOutputDir}/hmr" | 126 | script = 'run serve' |
93 | args = ['run', 'serve'] | ||
94 | setEnvironment NODE_ENV: 'hmr' | ||
95 | group = 'run' | 127 | group = 'run' |
96 | description = 'Start a Webpack dev server with hot module replacement.' | 128 | description = 'Start a Webpack dev server with hot module replacement.' |
97 | } | 129 | } |
98 | 130 | ||
99 | task eslint(type: NpmTask) { | ||
100 | dependsOn npmInstall | ||
101 | args = ['run', 'eslint'] | ||
102 | inputs.dir 'src/main/js' | ||
103 | inputs.file 'tsconfig.json' | ||
104 | inputs.file '.eslintrc.js' | ||
105 | group = 'verification' | ||
106 | description = 'Checks for TypeScript errors.' | ||
107 | } | ||
108 | |||
109 | check.dependsOn += [eslint] | ||
110 | |||
111 | sonarqube.properties { | 131 | sonarqube.properties { |
112 | properties['sonar.sources'] += [ | 132 | properties['sonar.sources'] += [ |
113 | 'src/main/css', | 133 | 'src/main/css', |
114 | 'src/main/html', | 134 | 'src/main/html', |
115 | 'src/main/js', | 135 | 'src/main/js', |
116 | "${buildDir}/generated/sources/xtext/js", | ||
117 | ] | 136 | ] |
118 | properties['sonar.exclusions'] += [ | 137 | properties['sonar.exclusions'] += [ |
119 | 'src/main/css/xtext/**', | 138 | 'src/main/css/xtext/**', |
120 | 'src/main/js/xtext/**', | 139 | 'src/main/js/xtext/**', |
121 | "${buildDir}/generated/sources/xtext/js/**" | ||
122 | ] | 140 | ] |
123 | } | 141 | } |
124 | 142 | ||