-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathbuild.gradle
More file actions
68 lines (61 loc) · 2.04 KB
/
build.gradle
File metadata and controls
68 lines (61 loc) · 2.04 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
plugins {
id "com.eriwen.gradle.css" version "2.14.0"
id "com.eriwen.gradle.js" version "2.14.1"
}
combineCss {
source = ['src/css/bootstrap.css', 'src/css/jd.css']
dest = 'build/css/jd.all.css'
}
minifyCss {
source = combineCss
dest = '../css/jd.min.css'
yuicompressor {
lineBreakPos = -1
}
}
combineJs {
encoding = 'UTF-8'
source = ['src/js/jquery.js', 'src/js/bootstrap.js', 'src/js/jd.js']
dest = 'build/js/jd.all.js'
}
minifyJs {
source = combineJs
dest = '../js/jd.min.js'
closure {
warningLevel = 'QUIET'
}
}
task copyImg(type: Copy) {
from 'src/img'
include 'glyphicons-halflings.png', 'glyphicons-halflings-white.png', 'jd-gui.png', 'jd-eclipse.png',
'paypal-donate.gif', 'Icon_java_64.png', 'bullet.gif', 'sub_bullet.gif', 'win.gif', 'linux.gif',
'osx.gif', 'java.png', 'github.png', 'link.gif', 'eclipse.png', 'intellij.png', 'new.png'
into '../img'
}
task prepareIndexHtml {
doLast {
def html = file('src/index.html').text
.replace('jd.css', 'jd.min.css')
.replace('jd.js', 'jd.min.js')
.replaceAll('<link.*href="((?!css\\/jd\\.min\\.css).)*".*rel="stylesheet"[^>]*>', '')
.replaceAll('<script.*src="((?!js\\/jd\\.min\\.js).)*">(<\\/script>)?', '')
.replaceAll('\\n\\s*', '')
file('build/html').mkdirs()
file('build/html/index.html').write(html)
}
}
task copyFiles {
dependsOn prepareIndexHtml
doLast {
['src/.htaccess', 'src/favicon.ico', 'src/google8db921c12949ed8c.html', 'src/sitemap.xml', 'src/robots.txt', 'build/html/index.html'].each { file -> ant.copy(file: file, todir: '..') }
}
}
task build {
dependsOn minifyCss, minifyJs, copyImg, copyFiles
}
task clean {
doLast {
['../.htaccess', '../favicon.ico', '../google8db921c12949ed8c.html', '../sitemap.xml', '../robots.txt', '../index.html'].each { file -> ant.delete(file: file) }
['../css', '../img', '../js', 'build'].each { dir -> ant.delete(dir: dir) }
}
}