-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.gradle
More file actions
134 lines (111 loc) · 3.94 KB
/
build.gradle
File metadata and controls
134 lines (111 loc) · 3.94 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Android litters the top-level with a "build/" folder.
* Applying the Base plugin provides a "clean" task.
*
* That litter may have been intentional?
* https://code.google.com/p/android/issues/detail?id=194472
*/
apply plugin: "base"
allprojects {
group = "com.github.vhati.openuhs"
version = "0.7.0"
// Define a custom attribute to let subprojects copy the license.
project.ext.licenseFile = project(":").file("LICENSE")
// Declare where to find dependencies.
repositories {
mavenCentral()
}
}
project(":core") {
apply plugin: "org.gradle.java"
dependencies {
// A downstream project will need to use the SAME version for its logger binding jar, if any.
// Presumably, if they declare both api and binding, their build tool will version-pin.
compile "org.slf4j:slf4j-api:1.7.21"
}
}
project(":desktop-reader") {
apply plugin: "org.gradle.java"
dependencies {
compile project(":core")
compile "org.slf4j:slf4j-api:1.7.21"
compile "ch.qos.logback:logback-core:1.1.7"
compile "ch.qos.logback:logback-classic:1.1.7"
compile "org.jdom:jdom2:2.0.6"
compile "net.sf.jopt-simple:jopt-simple:4.9" // 5.x requires Java 1.7.
}
}
task wrapper(type: Wrapper) {
gradleVersion = "2.14.1"
}
/*
* Retro-compiling for compatibility with older VMs can be done with modern classes.
*
* However, it's recommended to point the compiler's bootClasspath to authentic JDK jars.
*
* http://stackoverflow.com/questions/22681544/how-to-set-gradle-options-bootclasspath-in-an-os-independent-manner
*
* Or even more authentic: edit tasks to point at the old JDK's commands.
*
* https://docs.gradle.org/3.0/userguide/groovy_plugin.html
*/
def retroEnvs = [(JavaVersion.VERSION_1_6):"JDK6_HOME"]
def retroJDKs = [:]
retroEnvs.each { retroVer, retroEnv ->
if (System.env[retroEnv] != null && !System.env[retroEnv].isEmpty()) {
def binDir = new File(System.env[retroEnv], "bin")
// Resolve command names to full paths.
// This map starts empty, guesses from requested keys, and caches results.
def exeMap = [:].withDefault { nameKey ->
// Pick out the first file that matches the closure condition, or null.
def exeFile = binDir.listFiles().find {
(it.name ==~ '(?i)' + java.util.regex.Pattern.quote(nameKey) + '([.]exe)?')
}
assert(exeFile != null) : "Could not find ${nameKey} in ${binDir}"
exeFile
}
retroJDKs[retroVer] = exeMap
}
}
gradle.projectsEvaluated {
allprojects { p ->
// Restrict this hack to pure Java projects.
if (p.plugins.hasPlugin("org.gradle.java")) {
def blacklisted = false
/*
* To be cautious, and probably redundant, exclude retroJDKs for android explicitly.
*
* Android sets bootClasspath to the Android SDK's platform "android.jar".
* Without it, you get "package android.[etc] does not exist" errors.
*/
if (p.plugins.hasPlugin("com.android.application")) { blacklisted = true }
if (!blacklisted && retroJDKs.containsKey(p.targetCompatibility)) {
println("Using JDK ${p.targetCompatibility} for \"${p.name}\" tasks.")
p.tasks.withType(AbstractCompile) { t ->
t.options.fork = true
t.options.forkOptions.executable = retroJDKs[p.targetCompatibility]["javac"]
}
p.tasks.withType(Javadoc) { t ->
t.executable = retroJDKs[p.targetCompatibility]["javadoc"]
if (p.targetCompatibility.isJava8Compatible()) {
t.options.addStringOption("Xdoclint:-missing", "-quiet")
}
}
p.tasks.withType(Test) { t ->
t.executable = retroJDKs[p.targetCompatibility]["java"]
}
p.tasks.withType(JavaExec) { t ->
t.executable = retroJDKs[p.targetCompatibility]["java"]
}
}
else if (JavaVersion.current().isJava8Compatible()) {
p.tasks.withType(Javadoc) { t ->
// Java 8 introduced JavaDoc nags. Suppress them.
// Gradle's addStringOption() expects a key/value pair.
// This arg has no value, so tack on a harmless "-quiet" instead.
t.options.addStringOption("Xdoclint:-missing", "-quiet")
}
}
}
}
}