-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
78 lines (65 loc) · 2.01 KB
/
build.gradle
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
apply plugin: 'java'
// Allows generating an Eclipse project via 'gradle eclipse'
apply plugin: 'eclipse'
// TODO clean up these definitions
def xtendSrcDir = file('src/main/java')
// TODO not sure if the below is still an issue with Xtend 2.4.0
// Ideally would want this to be in build/ somewhere, but the Xtend Eclipse plugin
// seems to put it as a peer of the Java source root (i.e. even if I tell it to
// output to "/build/xtend-gen", it ends up outputing to "/src/main/build/xtend-gen")
def xtendGenTargetDir = file('src/main/xtend-gen')
repositories {
mavenCentral()
maven {
url "http://build.eclipse.org/common/xtend/maven/"
}
}
dependencies {
compile 'org.eclipse.xtend:org.eclipse.xtend.lib:2.4.0'
compile 'org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.4.0'
}
sourceSets {
main {
java {
srcDir xtendGenTargetDir
}
}
}
eclipse {
project {
natures 'org.eclipse.xtext.ui.shared.xtextNature'
buildCommand 'org.eclipse.xtext.ui.shared.xtextBuilder'
}
}
import org.apache.log4j.BasicConfigurator
import org.eclipse.xtend.core.XtendStandaloneSetup
import org.eclipse.xtend.core.compiler.batch.XtendBatchCompiler
task compileXtend {
inputs.dir xtendSrcDir
outputs.dir xtendGenTargetDir
doLast {
def srcPath = xtendSrcDir.absolutePath
def targetPath = xtendGenTargetDir.absolutePath
def classpath = configurations.compile.asPath
BasicConfigurator.configure()
XtendBatchCompiler compiler = new XtendStandaloneSetup().createInjectorAndDoEMFRegistration().getInstance(XtendBatchCompiler.class)
compiler.setOutputPath(targetPath)
compiler.setClassPath(classpath)
compiler.setSourcePath(srcPath)
if (!compiler.compile()) {
throw new GradleException("Xtend compilation failed.");
}
}
}
tasks.compileJava.dependsOn compileXtend
buildscript {
repositories {
mavenCentral()
maven {
url "http://build.eclipse.org/common/xtend/maven/"
}
}
dependencies {
classpath 'org.eclipse.xtend:org.eclipse.xtend.standalone:2.4.0'
}
}