aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/build.gradle
blob: ff0f9e9c7dca72a3d4097b3cf9c89eec56ee5505 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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:9.4.42.v20210604"
	compile "org.eclipse.jetty:jetty-annotations:9.4.42.v20210604"
	compile "org.slf4j:slf4j-simple:1.7.31"
}

def webpackOutputDir = "${buildDir}/webpack"
def productionResources = "${webpackOutputDir}/production"
def mainClass = 'org.eclipse.viatra.solver.language.web.ServerLauncher'

apply plugin: 'com.moowork.node'

for (environment in ['production', 'development']) {
	def taskName = 'webpack' + environment.substring(0, 1).toUpperCase() + environment.substring(1);
	task(taskName, type: NpmTask) {
		dependsOn ':language:generateXtext'
		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
distZip.enabled = false

jar {
	dependsOn webpackProduction
	from(productionResources) {
		into 'webapp'
	}
}

apply plugin: 'com.github.johnrengelman.shadow'
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) {
	dependsOn webpackDevelopment
	dependsOn sourceSets.main.runtimeClasspath
	classpath = sourceSets.main.runtimeClasspath.filter{it.exists()}
	main = mainClass
	standardInput = System.in
	group = 'run'
	description = 'Starts an example Jetty server with your language'
	environment(
		DEV_MODE: 'true',
		LISTEN_ADDRESS: 'localhost',
		LISTEN_PORT: '1313',
		BASE_RESOURCE: "${webpackOutputDir}/development"
	)
}

eclipse {
	project {
		file.whenMerged {
			natures.remove('org.eclipse.wst.common.modulecore.ModuleCoreNature')
		}
	}
}