-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild.gradle
108 lines (93 loc) · 3.41 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
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
project.ext.i2pVersion = '0.9.40'
String compat(String src) {
if (src.contains('.')) {
src.substring(src.lastIndexOf('.') + 1)
} else {
src
}
}
String javaExecutable(String targetJavaHome, String execName) {
def javaExecutablesPath = new File(targetJavaHome, "bin")
def executable = new File(javaExecutablesPath, execName)
if (!executable.exists()) {
throw new IllegalArgumentException("There is no ${execName} executable in ${javaExecutablesPath}")
}
return executable.toString()
}
configure([project(':core'), project(':webapp')]) {
project.version = '0.4.8'
project.afterEvaluate {
jar {
manifest {
attributes 'Implementation-Version': project.version
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
def i2pBootClasspath
// Set java7BootClasspath=/path/to/rt.jar:/path/to/jce.jar in ~/.gradle/gradle.properties if needed
if (java7BootClasspath) {
i2pBootClasspath = java7BootClasspath
} else {
def java7Home = System.getenv("JAVA7_HOME")
if (java7Home) {
i2pBootClasspath = "${java7Home}/jre/lib/jce.jar:${java7Home}/jre/lib/rt.jar"
}
}
if (i2pBootClasspath) {
project.tasks.withType(AbstractCompile, { AbstractCompile ac ->
ac.options.bootstrapClasspath = files(i2pBootClasspath)
})
} else {
if (JavaVersion.current().java8Compatible && !JavaVersion.current().java9Compatible) {
throw new GradleException("Set java7BootClasspath property or JAVA7_HOME environment variable to enable cross-compilation, or run Gradle with JDK 9+")
}
project.afterEvaluate {
tasks.withType(JavaCompile) {
def version = compat(sourceCompatibility)
logger.info("Configuring $name to use --release $version")
options.compilerArgs.addAll(['--release', version])
}
}
}
// Set up Java override if configured (used to test with Java 7).
def targetJavaHome = System.getenv("TARGET_JAVA_HOME")
if (targetJavaHome) {
if (JavaVersion.current().java9Compatible) {
throw new GradleException("Only set TARGET_JAVA_HOME with JDK 8")
}
project.afterEvaluate {
logger.info("Target Java home set to ${targetJavaHome}")
logger.info("Configuring Gradle to use forked compilation and testing")
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.javaHome = file(targetJavaHome)
}
tasks.withType(Javadoc) {
executable = javaExecutable(targetJavaHome, "javadoc")
}
tasks.withType(Test) {
executable = javaExecutable(targetJavaHome, "java")
}
tasks.withType(JavaExec) {
executable = javaExecutable(targetJavaHome, "java")
}
}
}
}
}