-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
165 lines (138 loc) · 4.42 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
plugins {
id 'java-library'
id 'antlr'
id 'application'
id 'maven-publish'
id "de.undercouch.download" version "4.0.4"
}
group 'net.signbit.samx'
version '0.4.8'
sourceCompatibility = 1.8
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'org.relaxng', name: 'jing', version: '20181222'
implementation group: 'xerces', name: 'xercesImpl', version: '2.12.0'
implementation 'commons-cli:commons-cli:1.4'
implementation 'commons-io:commons-io:2.6'
implementation 'org.apache.commons:commons-text:1.8'
implementation 'org.apache.commons:commons-lang3:3.10'
implementation 'com.github.jtidy:jtidy:1.0.2'
runtimeOnly group: 'net.sourceforge.plantuml', name: 'plantuml', version: '1.2020.8'
antlr 'org.antlr:antlr4:4.8'
}
generateGrammarSource {
maxHeapSize = "64m"
arguments += ["-visitor", "-long-messages"]
doLast {
copy {
from 'build/generated-src/antlr/main/'
include '*.*'
into 'build/generated-src/antlr/main/net/signbit/samx/parser'
}
project.delete fileTree('build/generated-src/antlr/main').include('*.*')
}
}
application {
mainClassName = 'net.signbit.samx.PrettyPrint'
executableDir = 'bin'
}
task createAllStartScripts() {
// just a placeholder
}
def scripts = ['tokenize' : 'net.signbit.samx.Tokenize',
'raw_tokens' : 'net.signbit.samx.RawTokens',
'to_xml' : 'net.signbit.samx.ConvertToXml',
'to_html' : 'net.signbit.samx.ConvertToHtml',
'pretty_print' : 'net.signbit.samx.PrettyPrint',
'extract_code' : 'net.signbit.samx.ExtractCode',
'generate_header': 'net.signbit.samx.literate.GenerateHeader',
]
scripts.each() { scriptName, className ->
def t = tasks.create(name: scriptName + 'StartScript', type: CreateStartScripts) {
mainClassName = className
applicationName = scriptName
outputDir = new File(project.buildDir, 'scripts')
classpath = jar.outputs.files + project.configurations.runtimeClasspath
}
applicationDistribution.into("bin") {
from(t)
fileMode = 0755
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
createAllStartScripts.dependsOn(t)
}
publishing {
publications {
maven(MavenPublication) {
groupId = group
artifactId = 'samxj'
version = version
from components.java
}
}
}
task downloadRelaxSchema(type: Download) {
src 'https://docbook.org/xml/5.1/rng/docbook.rng'
dest buildDir
overwrite false
}
task createDocs {
def docs = file("$buildDir/docs")
outputs.dir docs
doLast {
docs.mkdirs()
}
}
task generateBook(type: JavaExec) {
description = 'Generates the documentation in DocBook format'
group = 'verification'
classpath = sourceSets.main.runtimeClasspath
main = 'net.signbit.samx.ConvertToXml'
args = ['-i', 'doc/samx_language.samx', '-o', 'build/docs/samx_language.dbk', '-b', '-s', 'src/dist/schemas/docbook.rng.gz']
mustRunAfter test
}
task extractBookDiagrams(type: JavaExec) {
description = 'Extracts diagrams from the manual'
group = 'verification'
classpath = sourceSets.main.runtimeClasspath
main = 'net.signbit.samx.ExtractCode'
args = ['-i', 'doc/samx_language.samx', '-o', 'build/docs']
mustRunAfter test
}
task convertBookDiagrams(type: JavaExec) {
description = 'Converts diagrams to PNG'
group = 'verification'
classpath = sourceSets.main.runtimeClasspath
main = 'net.sourceforge.plantuml.Run'
args = ['build/docs/ditaa-example.plantuml'] // TODO: read diagrams from directory
mustRunAfter test
}
tasks.generateBook.dependsOn createDocs
tasks.extractBookDiagrams.dependsOn createDocs
tasks.convertBookDiagrams.dependsOn extractBookDiagrams
check.dependsOn generateBook
check.dependsOn convertBookDiagrams
distributions {
main {
contents {
exclude("**/*.plantuml") // TODO: remove hack
from 'README.md'
from("src/test/resources/") {
into "examples"
}
from(createDocs) {
into 'docs'
}
from(generateBook) {
into 'docs'
}
from(convertBookDiagrams) {
into 'docs'
}
}
}
}