-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
114 lines (99 loc) · 2.8 KB
/
build.gradle
File metadata and controls
114 lines (99 loc) · 2.8 KB
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
import groovy.io.FileType
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
}
}
plugins {
id 'java'
id 'antlr'
id 'eclipse'
id 'de.undercouch.download' version '3.2.0'
}
apply plugin: 'eu.appsatori.fatjar'
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
antlr 'org.antlr:antlr4:4.5'
testCompile 'junit:junit:4.11'
compile 'net.arnx:jsonic:1.3.9'
compile fileTree(dir: 'libs', include: '**/*.jar')
}
compileJava {
options.encoding = 'utf-8'
}
jar {
manifest {
attributes 'Main-Class': 'analyzer.CodeAnalyzer'
}
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
fatJar {
baseName = 'analyzer'
manifest {
attributes 'Main-Class': 'analyzer.CodeAnalyzer'
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
doFirst {
from (configurations.compile.collect { it.isDirectory() ? it : zipTree(it) })
}
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
task downloadFile {
doLast {
def grammarUrl = 'https://raw.githubusercontent.com/antlr/grammars-v4/master/cpp/'
def testFileUrl = 'https://raw.githubusercontent.com/antlr/grammars-v4/master/cpp/examples/helloworld.cpp'
def grammarName = 'CPP14.g4'
def testFileName = 'test.cpp'
download {
src grammarUrl + grammarName
dest 'src/main/antlr/' + grammarName
}
download {
src testFileUrl
dest 'src/test/resources/' + testFileName
}
}
}
task setGumtree {
doLast {
def zipUrl = 'https://bintray.com/jrfaller/GumTree/download_file?file_path=gumtree-20161230-2.1.0-SNAPSHOT.zip'
def zipName = 'gumtree.zip'
def path = 'libs/' + zipName
download {
src zipUrl
dest path
}
copy {
from zipTree(path).matching {
include '**/*.jar'
}
into 'libs'
}
}
}
task buildParser {
doLast {
def packageName = 'cpp'
def header = 'package ' + packageName + ';\n\n'
copy {
from 'build/generated-src/antlr/main'
into 'src/main/java/' + packageName
}
new File('src/main/java/' + packageName).eachFileMatch(FileType.FILES, ~/CPP14[a-zA-Z]+.java/) {
def text = header + it.text
it.write(text)
}
}
}
buildParser.dependsOn downloadFile, generateGrammarSource
task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}