-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
150 lines (131 loc) · 4.51 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.autoscout24.gradle:gradle-todo-plugin:1.0'
classpath 'commons-io:commons-io:2.0.1'
}
}
plugins {
id "base"
id "com.eriwen.gradle.js" version "1.12.1"
}
apply plugin: 'com.autoscout24.gradle.todo'
todo {
sourceFolder = "."
fileExtensions = ["php", "js", "txt"]
}
configurations {
ftpAntTask
}
repositories {
mavenCentral()
}
dependencies {
rhino 'com.google.javascript:closure-compiler:v20150920'
ftpAntTask("org.apache.ant:ant-commons-net:1.9.4") {
module("commons-net:commons-net:1.4.1") {
dependencies "oro:oro:2.0.8:jar"
}
}
}
javascript.source { // source sets
dev {
js {
srcDir "/scripts"
include "*.js"
exclude "*all-min.js"
}
}
prod {
js {
srcDir "/scripts"
include "*.min.js"
}
}
}
check {
dependsOn 'viewJshintResults'
dependsOn 'minifyJs'
}
combineJs {
source = javascript.source.dev.js.files
dest = file("${buildDir}/all.js")
}
minifyJs {
source = javascript.source.dev.js.files
dest = file("./scripts/all-min.js")
sourceMap = file("${buildDir}/all.sourcemap.json")
closure {
warningLevel 'VERBOSE'
// jQuery-1.9.js externs downloaded from https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.9.js
externs = files("resources/jQueryExterns.js", "resources/externs.js")
}
}
jshint {
sleep(500) // gives time to create buildDir
tasks.jshint.source = javascript.source.dev.js.files
tasks.jshint.dest = file("${buildDir}/jshint.out.xml")
tasks.jshint.reporter = 'checkstyle'
jshint.options = [browser: "true", jquery: "true"] // environments
jshint.options << [expr: "true"] // don't suppress warning
jshint.options << [wsh: "true"] // for ActiveXObjects
jshint.options << [globals: {"kcom"}]
jshint.options << [devel: "true"] // console.log is off already
}
task viewJshintResults (dependsOn:tasks.jshint, type:Exec) {
description "Shows Jshint XML in a browser for legibility"
onlyIf {
tasks.jshint.dest.readLines().join('') =~ /error|pattern/
}
def firefoxPath = /C:\Program Files (x86)\Mozilla Firefox\firefox.exe/
executable firefoxPath
args tasks.jshint.dest
ignoreExitValue = true
}
task ftp (dependsOn: ':alertWhenServerUpdates') {
description "Uploads all files that have changed to the server"
dependsOn minifyJs
def identity = file("resources/ftpid.txt").readLines()
ext.remotedir = "/k/"
doLast {
ant {
taskdef(name: 'ftp',
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
classpath: configurations.ftpAntTask.asPath)
ftp(server: "ftp.mankatopedia.com", userid: "${identity[0]}", password: "${identity[1]}", remotedir: "${remotedir}", verbose: "yes", depends: "yes", passive: "yes", serverTimeZoneConfig: "America/Los_Angeles", newer: "yes") {
fileset(dir: ".") {
exclude(name: ".gradle/")
exclude(name: "build.gradle")
include(name: "**/*.php")
include(name: "**/*.css")
include(name: "scripts/**/*")
include(name: "api/**/*")
include(name: "gfx/**/*")
}
}
}
}
}
task alertWhenServerUpdates (type:Exec){
description "Launches an external script to poll the server until new file is live"
inputs.files(fileTree(dir: 'scripts', include: '*.js'))
outputs.file 'always up-to-date without this fake file.txt'
def serverDir = "http://kcom.kovaciny.com/k/scripts/"
def urls = inputs.getFiles().collect{ serverDir + it.getName() }
workingDir "resources/"
commandLine "cmd", "/k",
"start /d \"resources\" checkforupdatedjs-Shortcut " + urls.join(" ")
}
task release (dependsOn: ['build', 'ftp']) {
// changes behavior when present in task graph
description "Produces build version"
}
gradle.taskGraph.whenReady {
if (gradle.taskGraph.hasTask(release)) {
minifyJs.source = combineJs // compile passed, don't need files and line numbers
} else {
jshint.options << [debug: "true"]
}
}