apply from: "${rootDir}/gradle/xtext-common.gradle" dependencies { compile project(':language') compile project(':language-ide') compile "org.eclipse.xtext:org.eclipse.xtext.xbase.web:${xtextVersion}" compile "org.eclipse.xtext:org.eclipse.xtext.web.servlet:${xtextVersion}" compile "org.eclipse.xtend:org.eclipse.xtend.lib:${xtextVersion}" compile "org.eclipse.jetty:jetty-server:${jettyVersion}" compile "org.eclipse.jetty:jetty-annotations:${jettyVersion}" compile "org.slf4j:slf4j-simple:${slf4JVersion}" } def webpackOutputDir = "${buildDir}/webpack" def productionResources = "${webpackOutputDir}/production" def mainClass = 'org.eclipse.viatra.solver.language.web.ServerLauncher' def devMode = System.getenv('NODE_ENV') != 'production' def currentNodeEnv = devMode ? 'development' : 'production' apply plugin: 'com.moowork.node' node { version = nodeVersion npmVersion = project.ext.npmVersion download = true } for (environment in ['production', 'development']) { def taskName = 'webpack' + environment.substring(0, 1).toUpperCase() + environment.substring(1); task(taskName, type: NpmTask) { dependsOn ':language:generateXtext' dependsOn npmInstall inputs.dir 'src/main/css' inputs.dir 'src/main/html' inputs.dir 'src/main/js' inputs.dir "${buildDir}/generated/sources/xtext/js" inputs.file 'webpack.config.js' outputs.dir "${webpackOutputDir}/${environment}" args = ['run', 'build'] setEnvironment NODE_ENV: environment } } apply plugin: 'application' mainClassName = mainClass distTar.enabled = false distZip.enabled = false jar { dependsOn webpackProduction from(productionResources) { into 'webapp' } } apply plugin: 'com.github.johnrengelman.shadow' shadowDistTar.enabled = false shadowDistZip.enabled = false shadowJar { dependsOn webpackProduction from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output) configurations = [project.configurations.runtime] exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*', '.options', '.api_description', '*.profile', 'about.*', 'about_*.html', 'about_files/*', 'plugin.xml', 'systembundle.properties', 'profile.list', 'META-INF/resources/xtext/**') append('plugin.properties') from(productionResources) { into 'webapp' } } task jettyRun(type: JavaExec) { if (devMode) { dependsOn webpackDevelopment } else { dependsOn webpackProduction } dependsOn sourceSets.main.runtimeClasspath classpath = sourceSets.main.runtimeClasspath.filter{it.exists()} main = mainClass standardInput = System.in environment BASE_RESOURCE: "${webpackOutputDir}/${currentNodeEnv}" group = 'run' description = 'Start a Jetty web server serving the Xtex API and assets' } task webpackServe(type: NpmTask) { dependsOn ':language:generateXtext' dependsOn npmInstall outputs.dir "${webpackOutputDir}/hmr" args = ['run', 'serve'] setEnvironment NODE_ENV: 'hmr' group = 'run' description = 'Start a Webpack dev server with hot module replacement' } eclipse { project.file.whenMerged { natures.remove('org.eclipse.wst.common.modulecore.ModuleCoreNature') } }