-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
59 lines (55 loc) · 2.1 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
plugins {
id 'org.jbake.site' version '5.0.0'
id "org.ajoberstar.git-publish" version "1.0.1"
}
bakePreview {
port = '8080'
}
gitPublish {
repoUri = 'https://github.com/jmcgarr/jmcgarr.github.io.git'
branch = 'master'
commitMessage = 'Publishing an update to my website'
contents {
from (file('build/jbake')) {
into '.'
}
}
}
// Based on a nice blog post from LD: http://ldaley.com/post/164424162157/auto-reload-html-asciidoctor-gradle-plugin-output
task liveEdit {
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
doLast {
["osascript", "-e", """
try
tell application "Finder" to get application file id "com.google.Chrome"
set appExists to true
on error
set appExists to false
end try
if appExists then
tell application "Google Chrome"
set theUrl to "http://localhost:8080/"
set found to false
set theWindowIndex to 0
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL starts with theUrl then
set found to true
tell application "Google Chrome" to set active tab index of theWindow to theTabIndex
tell theTab to reload
end if
end repeat
end repeat
if not found then
set URL of (active tab of (make new window)) to theUrl
end if
end tell
end if
"""].execute()
}
}
}
bakePreview.dependsOn tasks.find{ it.name == 'bake' }
gitPublishCommit.dependsOn tasks.find{ it.name == 'bake' }