forked from FineUploader/fine-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
175 lines (147 loc) · 5.36 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
171
172
173
174
175
def filename = "fineuploader"
def srcDir = 'client'
def jsSrcDir = "$srcDir/js"
def tempSrcDir = 'build/temp'
apply plugin: 'js'
def coreFiles(String dir) {["${dir}/header.js",
"${dir}/util.js",
"${dir}/version.js",
"${dir}/features.js",
"${dir}/promise.js",
"${dir}/button.js",
"${dir}/paste.js",
"${dir}/upload-data.js",
"${dir}/uploader.basic.js",
"${dir}/dnd.js",
"${dir}/uploader.js",
"${dir}/ajax.requester.js",
"${dir}/deletefile.ajax.requester.js",
"${dir}/window.receive.message.js",
"${dir}/handler.base.js",
"${dir}/handler.form.js",
"${dir}/handler.xhr.js"]
}
def tempVersionStampFile = "$tempSrcDir/version.js"
def tempHeaderFile = "$tempSrcDir/header.js"
def cssFiles = ["$srcDir/fineuploader.css"]
def imageFiles = ["$srcDir/loading.gif",
"$srcDir/processing.gif"]
def additionalFilesToInclude = ["${jsSrcDir}/iframe.xss.response.js"]
def jQueryPluginFiles(String dir) { ["${dir}/jquery-plugin.js",
"${dir}/jquery-dnd.js"] }
def synchronized orderTasks( String aTasks ) {
// Laurence Toenjes 2012
// preserve dependency task order for Gradle (put this near the top of your gradle build file)
// example: task( 'seq-alpha', dependsOn: orderTasks( 'alpha bravo charlie' ) ) << { /* your task code */ }
// To view task dependency do cmd: gradle tasks --all
if ( !(project.ext.properties.containsKey("orderTasksCtr")) )
project.ext.orderTasksCtr = new java.util.concurrent.atomic.AtomicInteger(1000);
def cl_createProxyTask = { aTaskName ->
def ctr = project.ext.orderTasksCtr.incrementAndGet();
def newTaskName = "_seq_${ctr}_${aTaskName}";
def newTask = project.task( newTaskName );
newTask.dependsOn << "${aTaskName}";
def result = newTask;
}
''' , ' " [ ] ( ) '''.trim().split().each {
if (it in aTasks)
aTasks = aTasks.replace( it, (32 as char).toString() )
}
return aTasks.split().collect { cl_createProxyTask(it) };
}
/////////////////////////////////////////////////////////////////////////////
def calcSubTasks( aTask ) {
// used by taskInfo
def st = ( aTask.dependsOn.collect {it} as List ).flatten();
def filter1 = ( st.findAll { !("$it" == 'file collection') } );
return filter1;
}
def taskInfo( aTask, aLevel = -1 ) {
// use this recursive routine to print out an indented task dependency.
// example call: taskInfo( 'someTaskName' );
// uses calcSubTasks( aTask )
aLevel++;
def SPACE = "${32 as char}"
def indent = (SPACE*2) * aLevel;
print indent;
def skip = "${aTask.name}".startsWith("_seq_");
if (!skip)
println "${aTask.name}";
calcSubTasks( aTask ).each {
def theTask = (it instanceof org.gradle.api.internal.AbstractTask) ? it : project.tasks[ "$it" ] ;
taskInfo( theTask, aLevel )
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.eriwen:gradle-js-plugin:1.3'
}
}
combineJs {
source = files(coreFiles(tempSrcDir))
dest = file("$buildDir/${filename}-${fineUploaderVersion}.js")
}
task combineJsJquery(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
source = files(coreFiles(tempSrcDir)) + files(jQueryPluginFiles(tempSrcDir))
dest = file("$buildDir/jquery.${filename}-${fineUploaderVersion}.js")
}
minifyJs {
source = combineJs
dest = file("$buildDir/${filename}-${fineUploaderVersion}.min.js")
}
task minifyJsJquery(type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
source = combineJsJquery
dest = file("$buildDir/jquery.${filename}-${fineUploaderVersion}.min.js")
}
task zipJquery(type: Zip) {
baseName "jquery.$filename-$fineUploaderVersion"
from files("$buildDir")
destinationDir file('release')
}
task zip(type: Zip) {
baseName "$filename-$fineUploaderVersion"
from files("$buildDir")
destinationDir file('release')
}
task copyResources(type:Copy) {
from cssFiles + imageFiles + additionalFilesToInclude
into 'build'
rename { String fileName ->
fileName.replace('.css', "-${fineUploaderVersion}.css")
}
rename { String fileName ->
fileName.replace('.js', "-${fineUploaderVersion}.js")
}
}
task clean << {
delete files("$buildDir")
delete file(tempSrcDir)
}
task deleteTemp << {
delete file(tempSrcDir)
}
task copyJsToTempDir(type:Copy) {
from coreFiles(jsSrcDir) + jQueryPluginFiles(jsSrcDir)
into tempSrcDir
}
task stampWithVersion << {
//header (comments)
File headerFile = file("$tempHeaderFile")
String newContents = headerFile.text.replaceFirst("$fineUploaderversionPlaceholderText", "$fineUploaderVersion")
headerFile.text = newContents
//version file (code)
File versionFile = file(tempVersionStampFile)
newContents = versionFile.text.replaceFirst("$fineUploaderversionPlaceholderText", "$fineUploaderVersion")
versionFile.text = newContents
}
task createJqueryRelease(dependsOn: orderTasks('commonReleasePrep minifyJsJquery commonPostCombine zipJquery')) {
}
task createRelease(dependsOn: orderTasks('commonReleasePrep minifyJs commonPostCombine zip')) {
}
task commonReleasePrep(dependsOn: orderTasks('clean copyJsToTempDir stampWithVersion')) {
}
task commonPostCombine(dependsOn: orderTasks('copyResources deleteTemp')) {
}