-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
229 lines (197 loc) · 7.47 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
apply plugin: 'java'
apply plugin: 'application'
configurations {
srcFormatter
}
sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
ext.programName = 'Audiveris'
ext.programVersion = '4.4.0-SNAPSHOT'
ext.companyName = "$programName Ltd."
ext.companyId = "${programName}Ltd"
// this code is required in order to adapt values of os.name and os.arch to the
// conventions used by Javacpp's dependencies
ext.targetOSName = System.getProperty('os.name').toLowerCase()\
.startsWith('mac os x') ? 'macosx' :\
System.getProperty('os.name').split(' ')[0].toLowerCase()
ext.targetOSArch = ["i386":"x86", "i486":"x86", "i586":"x86", "i686":"x86",
"amd64":"x86_64", "x86-64":"x86_64", "x86_64":"x86_64"]\
[System.getProperty('os.arch').toLowerCase()]
ext.targetOS = "${project.ext.targetOSName}-${project.ext.targetOSArch}"
println "targetOS=${project.ext.targetOS}"
if (!hasProperty('mainClass')) {
ext.mainClass = ext.programName
}
mainClassName = ext.programName
// Useful for turning on deprecation warnings
// Just uncomment the appropriate option
allprojects {
tasks.withType(JavaCompile) {
//options.compilerArgs << "-Xlint:deprecation"
//options.compilerArgs << "-Xlint:unchecked"
}
}
run {
minHeapSize = '512m'
maxHeapSize = '1g'
}
repositories {
jcenter()
maven {
name = 'JBoss repository' // required to obtain non-free JAI
url = 'https://repository.jboss.org/nexus/content/repositories/thirdparty-releases'
}
mavenLocal()
//flatDir(dirs: 'dev/externals') // for libraries not in any other repository
}
sourceSets {
main {
java {
srcDir 'src/main'
}
resources {
srcDir 'src/main'
srcDir 'dev/icons'
}
}
test {
java {
srcDir 'src/test'
}
}
}
dependencies {
compile(
[group: 'org.jdesktop.bsaf', name: 'bsaf', version: '1.9.2'],
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.22'],
[group: 'net.jcip', name: 'jcip-annotations', version: '1.0'],
[group: 'org.bushe', name: 'eventbus', version: '1.4'],
[group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'],
[group: 'com.jgoodies', name: 'jgoodies-forms', version: '1.9.0'],
[group: 'com.jgoodies', name: 'jgoodies-looks', version: '2.7.0'],
[group: 'javax.media', name: 'jai-core', version: '1.1.3'],
[group: 'org.audiveris', name: 'proxymusic', version: '3.0.1'],
[group: 'org.jfree', name: 'jfreechart', version: '1.0.19'],
[group: 'com.itextpdf', name: 'itextpdf', version: '5.5.9'],
[group: 'gov.nist.math', name: 'jama', version: '1.0.3'],
[group: 'org.bytedeco', name: 'javacpp', version: '1.3'],
[group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.73-1.3'],
[group: 'org.bytedeco.javacpp-presets', name: 'tesseract', version: '3.04.01-1.3'],
[group: 'com.github.jai-imageio', name: 'jai-imageio-core', version: '1.3.1'],
)
runtime(
[group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.73-1.3', classifier: "${project.ext.targetOS}"],
[group: 'org.bytedeco.javacpp-presets', name: 'tesseract', version: '3.04.01-1.3', classifier: "${project.ext.targetOS}"]
)
testCompile(
[group: 'junit', name: 'junit', version: '4.10']
)
srcFormatter (
[group: 'jalopy', name: 'jalopy-ant', version: '0.1-1.5b5'],
[group: 'log4j', name: 'log4j', version: '1.2.17'],
[group: 'jalopy', name: 'jalopy', version: '1.5rc3']
)
}
jar {
// override default output archive name
archiveName = "audiveris.jar"
exclude ("**/doc-files/**")
destinationDir = file('build/jar')
// copy resources into the destination jar
from(file('res')) {
into 'res'
}
manifest {
attributes 'Built-By': project.ext.companyName
attributes 'Specification-Title': project.ext.programName
attributes 'Specification-Vendor': project.ext.companyName
attributes 'Specification-Version': project.ext.programVersion
attributes 'Implementation-Version': project.ext.programVersion
}
}
// Defining 'debug' task allows to set its arguments later
task(debug, dependsOn: 'classes', type: JavaExec) {
main = mainClassName
classpath = sourceSets.main.runtimeClasspath
debug true
}
// Populate application arguments for 'run' & 'debug' tasks?
if (hasProperty('args_file_name')) {
new File("$projectDir/$args_file_name").eachLine { line ->
run.args(line)
debug.args(line)
}
}
// retrieve the abbreviated hash for the latest commit from Git
task "git_build"(type:Exec) {
commandLine "git rev-parse --short HEAD".split(' ')
standardOutput = new ByteArrayOutputStream()
doLast {
project.ext."programBuild" = standardOutput.toString().replaceAll('\n', '')
}
}
task generateProgramId {
doLast {
project.ext.outputDir = file("$buildDir/generated-src/org/audiveris/omr")
def className = "ProgramId"
outputDir.exists() || outputDir.mkdirs()
def gSrc = new File(outputDir, "${className}.java")
gSrc.write("package org.audiveris.omr;\n\n")
gSrc.append("/**\n * Class {@code $className} provides full program identification.\n")
gSrc.append(" * This code has been automatically generated by Gradle.\n */\n")
gSrc.append("public class $className {")
["company_name", "company_id", "program_name", "program_version"].each { str ->
def strParts = str.split("_")
def propName = strParts[0] + strParts[1].capitalize()
gSrc.append("\n /** Precise ${strParts[0]} ${strParts[1]}: {@value} */")
gSrc.append("\n public static final String ${str.toUpperCase()} = \"${project.ext."$propName"}\";\n")
}
gSrc.append("}\n")
}
}
compileJava.dependsOn("generateProgramId")
sourceSets {
main {
java {
srcDir { "$buildDir/generated-src/org/audiveris/omr" }
}
}
}
// Avoid JDK8 too strict javadoc
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
javadoc {
doFirst {
copy {
from "src/main/org/audiveris/omr"
into "$buildDir/docs/javadoc/org/audiveris/omr"
include ("*/doc-files/**")
}
}
title = "${project.ext.programName}-${project.ext.programVersion} API"
options.overview('src/main/overview.html')
}
// format Java sources with the ancient Jalopy formatter (use it carefully!)
// usage: gradle formatSources
task formatSources(description: 'Format Java sources with Jalopy.') {
doLast {
ant.taskdef(name: 'formatSrcTask', classname: 'de.hunsicker.jalopy.plugin.ant.AntPlugin',
classpath: configurations.srcFormatter.asPath)
ant.formatSrcTask(convention: 'dev/jalopy/java-convention.xml', history: 'file',
historymethod: 'adler32', loglevel: 'info', threads: '1') {
fileset(dir: 'src') {
include(name: '**/*.java')
exclude(name: '**/package-info.java')
}
}
}
}
// Ability to include private tasks
fileTree("$projectDir/private").include('*.gradle').each { file ->
apply from: file
}