aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/build.gradle
blob: c5e27dc68a14f587b8c85344a646cf3ef93a911b (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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-servlet:${jettyVersion}"
	compile "org.slf4j:slf4j-simple:${slf4JVersion}"
}

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

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) {
	shouldRunAfter webpackProduction
	dependsOn sourceSets.main.runtimeClasspath
	classpath = sourceSets.main.runtimeClasspath.filter{it.exists()}
	main = mainClass
	standardInput = System.in
	environment BASE_RESOURCE: productionResources
	group = 'run'
	description = 'Start a Jetty web server serving the Xtex API and assets (without rebuilding assets).'
}

task jettyRunAssets {
	dependsOn webpackProduction
	dependsOn jettyRun
	group = 'run'
	description = 'Rebuild assets and 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.'
}

task eslint(type: NpmTask) {
	dependsOn npmInstall
	args = ['run', 'eslint']
	inputs.dir 'src/main/js'
	inputs.file 'tsconfig.json'
	inputs.file '.eslintrc.js'
	group = 'verification'
	description = 'Checks for TypeScript errors.' 
}

check.dependsOn += [eslint]

sonarqube.properties {
	properties['sonar.sources'] += [
		'src/main/css',
		'src/main/html',
		'src/main/js',
		"${buildDir}/genrated/sources/xtext/js",
	]
	properties['sonar.exclusions'] += [
		'src/main/css/xtext/**',
		'src/main/js/xtext/**',
		"${buildDir}/genrated/sources/xtext/js/**"
	]
}

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