-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbuild.gradle
170 lines (146 loc) · 7.75 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
apply plugin: 'java'
version '0.4.0'
group 'com.codebrig'
sourceCompatibility = 1.8
archivesBaseName = 'journey-browser'
ext {
projectUrl = 'https://github.com/CodeBrig/Journey'
jcefVersion = [
'67': '67.0.3396.62',
'69': '69.0.3497.100',
'73': '73.1.11.216',
'75': '75.0.13.220',
'78': '78.2.7.237'
]
jcefCommit = [
'67': '1fda5d8f948670d08ef86bc4e8637b8581995ce9',
'69': '235e3a844380b72761643324e1d9b7713cae3b63',
'73': '6b140efeef4e566b6a68025b1dcea9b2da6e6e57',
'75': '13ae2d6074bc00a31888fb752dd45f9cf254725d',
'78': '1e3a9146226d3df8a7f0c9c03989d220ac26ca49'
]
}
repositories {
mavenCentral()
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'com.github.bfergerson:joor:bef9254b2a'
compileOnly 'com.github.bfergerson:joor:bef9254b2a'
compile fileTree(dir: 'jcef/binary_distrib/linux64/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/binary_distrib/win32/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/binary_distrib/win64/bin/', include: '*.jar')
compile fileTree(dir: 'jcef/jcef_build/native/Release', include: '*.jar')
}
task createProperties(dependsOn: processResources) {
doLast {
def mode = "online"
if ((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))) {
mode = "offline"
}
new File("$buildDir/resources/main/journey_build.properties").withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p['build_date'] = new Date().toInstant().toString()
p['mode'] = mode
p['project_url'] = project.projectUrl.toString()
p.store w, null
}
}
}
classes {
dependsOn createProperties
}
jar {
dependsOn "initEnvironment"
from {
(configurations.compileOnly).collect { it.isDirectory() ? it : zipTree(it) }
}
}
task initEnvironment {
def chromiumMajorVersion = "78"
if (System.getenv("TRAVIS_OS_NAME") == "osx") {
chromiumMajorVersion = "73"
}
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
}
if (System.getenv('JITPACK') == "true" ||
(((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))))) {
println "Downloading JCEF distribution"
def f = new File("jcef/binary_distrib", "jcef-distrib-linux64.zip")
f.getParentFile().mkdirs()
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
.withInputStream { i -> f.withOutputStream { it << i } }
println "Successfully downloaded JCEF distribution"
println "Unzipping JCEF distribution"
ant.unzip(src: f.absolutePath, dest: f.getParentFile().absolutePath, overwrite: "true")
println "Successfully unzipped JCEF distribution"
if ((System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").contains("offline")) ||
(System.getenv("VERSION") != null && System.getenv("VERSION").contains("offline"))) {
def linuxBuild = new File('natives/jcef-distrib-linux64.zip')
linuxBuild.getParentFile().mkdirs()
def macintoshBuild = new File('natives/jcef-distrib-macintosh64.zip')
def windows32Build = new File('natives/jcef-distrib-windows32.zip')
def windows64Build = new File('natives/jcef-distrib-windows64.zip')
println "Downloading CEF natives files for offline distribution"
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-linux64.zip")
.withInputStream { i -> linuxBuild.withOutputStream { it << i } }
//https://github.com/CodeBrig/Journey/issues/23
new URL(project.projectUrl + "/releases/download/" + project.version + "-69-assets/jcef-distrib-macintosh64.zip")
.withInputStream { i -> macintoshBuild.withOutputStream { it << i } }
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows32.zip")
.withInputStream { i -> windows32Build.withOutputStream { it << i } }
new URL(project.projectUrl + "/releases/download/" + project.version + "-$chromiumMajorVersion-assets/jcef-distrib-windows64.zip")
.withInputStream { i -> windows64Build.withOutputStream { it << i } }
println "Successfully downloaded CEF natives files for offline distribution"
println "Unpacking CEF natives files for offline distribution"
ant.unzip(src: linuxBuild.absolutePath, dest: linuxBuild.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: macintoshBuild.absolutePath, dest: macintoshBuild.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: windows32Build.absolutePath, dest: windows32Build.getParentFile().absolutePath, overwrite: "true")
ant.unzip(src: windows64Build.absolutePath, dest: windows64Build.getParentFile().absolutePath, overwrite: "true")
println "Successfully unpacked CEF natives files for offline distribution"
def resourcesDir = file('src/main/resources')
new File(linuxBuild.getParentFile(), "linux64").renameTo(new File(resourcesDir, "linux64"))
new File(macintoshBuild.getParentFile(), "macosx64").renameTo(new File(resourcesDir, "macosx64"))
new File(windows32Build.getParentFile(), "win32").renameTo(new File(resourcesDir, "win32"))
new File(windows64Build.getParentFile(), "win64").renameTo(new File(resourcesDir, "win64"))
}
}
}
task patchJCEF {
doFirst {
//https://bitbucket.org/chromiumembedded/java-cef/issues/317
println "Patching java-cef#317"
def cefAppFile = file('jcef/java/org/cef/CefApp.java')
cefAppFile.text = cefAppFile.text.replace('System.loadLibrary("jawt");', file('patches/jcef-317.txt').text)
if (System.getenv("TRAVIS_OS_NAME") == "osx") {
//https://bitbucket.org/chromiumembedded/java-cef/issues/270
println "Patching java-cef#270"
def cefBrowserWindowMacFile = file('jcef/java/org/cef/browser/mac/CefBrowserWindowMac.java')
cefBrowserWindowMacFile.text = file('patches/jcef-270.txt').text
}
}
}
task checkoutJCEF {
doFirst {
def chromiumMajorVersion = "78"
if (System.getenv("TRAVIS_OS_NAME") == "osx") {
chromiumMajorVersion = "69"
}
if (System.getenv("TRAVIS_BRANCH") != null && System.getenv("TRAVIS_BRANCH").split("-").length == 3) {
chromiumMajorVersion = System.getenv("TRAVIS_BRANCH").split("-")[1]
} else if (System.getenv("VERSION") != null && System.getenv("VERSION").split("-").length == 3) {
chromiumMajorVersion = System.getenv("VERSION").split("-")[1]
}
def p = ("git checkout " + jcefCommit[chromiumMajorVersion]).execute(null, new File("jcef").absoluteFile)
p.waitFor()
}
}