-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
124 lines (107 loc) · 3.63 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
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
import org.apache.tools.ant.filters.ReplaceTokens
group = 'org.mellowd'
version = '3.0.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'antlr'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
wrapper {
gradleVersion = '4.10.2'
distributionType = Wrapper.DistributionType.ALL
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
// All required libs are on the maven central repo
repositories {
mavenCentral()
}
// Define a shade configuration. Dependencies in this configuration
// are available at compile time and are shaded into the jar.
configurations {
shade
shade.transitive = false
compile.extendsFrom(shade)
}
// The compiler needs junit and gson to run the tests, antlr to generate
// the parser.
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
// Only shade the runtime because we don't need the generator after things are compiled
antlr group: 'org.antlr', name: 'antlr4', version: '4.7.1'
shade group: 'org.antlr', name: 'antlr4-runtime', version: '4.7'
}
// Add a manifest attribute, the shaded dependencies and antlr to the built jar.
// The manifest attribute makes the jar executable.
jar {
manifest {
attributes 'Main-Class': 'org.mellowd.io.Compiler'
}
//Include all shaded dependencies in the jar
from configurations.shade
.collect { it.isDirectory() ? it : zipTree(it) }
}
processResources {
// Register the version as a property because the ot of date checks
// will see the metadata file as UP-TO-DATE since it only stores
// the @version@ token
inputs.property('version-meta', rootProject.version)
filter ReplaceTokens, tokens: [
"version": rootProject.version
]
}
def doccoMode = 'linear' /* linear, parallel, classic */
def pathToLanguages = 'languages.json'
def toRelFile(File file) {
String relPath = file.absolutePath.replace(projectDir.absolutePath, '');
if (relPath.startsWith('\\')) {
relPath = relPath.substring(1);
}
return relPath;
}
task docco {
doLast {
exec {
String outDir = toRelFile(file("${project.docsDir}\\docco"));
executable = 'docco.cmd'
args += ['-o', "$outDir"]
//Always compile md files as linear because they look out of place
//when squeezed on the side with a blank window beside it
args += ['-l', doccoMode]
if (pathToLanguages) args += ['-L', pathToLanguages]
args += ['-t', 'site\\docco.jst']
args += ['-c', 'site\\docco.css']
sourceSets.main.allSource.plus(sourceSets.test.allSource).plus(sourceSets.test.resources)
//Exclude generated source files as they are not documented
.grep { !(it.path ==~ /.*generated-src.*/) }
.each { srcFile ->
args += toRelFile(file(srcFile))
}
args += toRelFile(file('index.md'))
args += toRelFile(file('langRef.md'))
}
copy {
from 'site\\public'
into toRelFile(file("${project.docsDir}\\docco\\public"))
}
}
}
test {
reports.html.destination = file("$project.docsDir\\docco\\tests")
}
generateGrammarSource {
outputDirectory = file("$outputDirectory/org/mellowd/compiler")
arguments += ['-package', 'org.mellowd.compiler']
arguments += ['-visitor']
arguments += ['-no-listener']
inputs.files(source.files)
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}