-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
289 lines (236 loc) · 7.3 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
apply plugin: 'java'
apply plugin: 'eclipse'
group = 'rit'
version = 0.4
jar.baseName = 'flick'
// def uploadSite = 'ftp.bioinformatics.rit.edu'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.edu.sc.seis.gradle:launch4j:1.1.3"
// Needed for upload task
classpath 'commons-net:commons-net:3.3'
}
}
apply plugin: "edu.sc.seis.launch4j"
copyL4jLib {
include "$libsDir/${name.toLowerCase()}-${version}.jar"
}
launch4j {
jar = "$libsDir/${name.toLowerCase()}-${version}.jar"
headerType = 'console'
outputDir = "resources"
chdir = ''
icon = "$projectDir/resources/logo.ico"
bundledJrePath = "%JAVA_HOME%/bin/java.exe"
bundledJre64Bit = true
bundledJreAsFallback = true
downloadUrl = 'http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html'
// companyName = 'Aiezza Inc'
supportUrl = 'https://github.com/aaiezza/flick'
outfile = "${name.toLowerCase()}.exe"
}
task flickExe( dependsOn: generateXmlConfig, type: Exec ) {
commandLine "${->launch4j.launch4jCmd}", "${->project.buildDir}/${->launch4j.outputDir}/${->launch4j.xmlFileName}"
workingDir "${->project.buildDir}/${->launch4j.outputDir}"
}
flickExe.doFirst {
launch4j {
mainClassName = 'edu.rit.flick.util.Flick'
}
generateXmlConfig.writeXmlConfig()
}
task unflickExe( dependsOn: generateXmlConfig, type: Exec ) {
commandLine "${->launch4j.launch4jCmd}", "${->project.buildDir}/${->launch4j.outputDir}/${->launch4j.xmlFileName}"
workingDir "${->project.buildDir}/${->launch4j.outputDir}"
}
unflickExe.doFirst {
launch4j {
outfile = 'un' + outfile
mainClassName = 'edu.rit.flick.util.Unflick'
}
generateXmlConfig.writeXmlConfig()
}
// Explicitly create the main configuration
configurations {
main
}
dependencies {
compile 'com.google.guava:guava:18.0'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'it.unimi.dsi:dsiutils:2.2.4'
compile 'org.springframework:spring-context:4.2.5.RELEASE'
testCompile 'junit:junit:4.+'
testCompile 'junit-addons:junit-addons:1.+'
main configurations.compile
}
// Redefine the sourcesets
sourceSets {
main {
java.srcDir 'src'
resources {
srcDir 'resources'
include '*Usage.txt'
exclude 'launch4j_configs'
}
}
test {
java.srcDir 'test'
resources.srcDirs 'test_resources', main.resources
}
}
// Create bare jars. (This will come in handy later when we can upload to maven central)
sourceSets.all { set ->
def jarTask = task("${set.name}Jar", type: Jar) {
baseName = jar.baseName + "-$set.name"
from set.output
}
artifacts {
archives jarTask
}
}
// Extract dependencies into a temp folder so they can be exported to the main jar
task extractJars( type: Copy ) {
dependsOn configurations.main
def depJarFolder = file("${project.buildDir}/dep-jars/")
outputs.upToDateWhen { depJarFolder.exists() }
if ( !depJarFolder.exists() )
{
from {
configurations.main.asFileTree.each {
from( zipTree( it ) )
}
// Don't include the actual archives themselves
null
}
into depJarFolder
}
}
tasks.jar {
dependsOn extractJars
baseName = 'flick'
from sourceSets.main.output
from file("${project.buildDir}/dep-jars/")
}
// Insert version number into usage statement
processResources {
eachFile { copyDetails ->
if ( copyDetails.path.endsWith( 'Usage.txt' ) ) {
filter { line ->
line.replace('{{version}}', "$version")
}
}
}
outputs.upToDateWhen { false }
}
// Task for bundling the releases
task bundleReleases( group: 'Distribution' ) {
description = 'Builds distributions of flick for Unix & Windows systems.'
dependsOn 'bundleUnixRelease', 'bundleWindowsRelease'
}
task bundleUnixRelease ( group: 'Distribution', type: Tar ) {
dependsOn jar
baseName = jar.baseName
compression = Compression.GZIP
extension = 'tar.gz'
archiveName = "$baseName.$extension"
destinationDir file( "$distsDir" )
from( sourceSets.main.resources.getSrcDirs() ) {
include 'flick', 'unflick'
eachFile {
fileMode = 0755
}
}
from ( "$libsDir" ) {
include "${baseName}-${version}.jar"
rename "${baseName}-${version}.jar", "${baseName}.jar"
}
into "${baseName}-${version}"
outputs.upToDateWhen { false }
}
task bundleWindowsRelease ( group: 'Distribution', type: Zip ) {
dependsOn flickExe, unflickExe
baseName = jar.baseName
archiveName = "win-$baseName.$extension"
destinationDir file( "$distsDir" )
from "$buildDir/resources"
include 'flick.exe', 'unflick.exe'
into "${baseName}-${version}"
outputs.upToDateWhen { false }
}
build << { bundleReleases }
def lock = 0
// File uploaders
def getUploader = { fileLocation, uploadPath ->
lock ++
printf 'Uploading %s%n', fileLocation
[
run: {
def ftp = new org.apache.commons.net.ftp.FTPClient()
def config = new org.apache.commons.net.ftp.FTPClientConfig()
ftp.configure config
def error = false
try {
def reply
ftp.connect uploadSite
// printf( "Connected to %s successfully.%n", uploadSite )
// println ftp.replyString
// After connection attempt, you should check the reply code to verify
// success.
reply = ftp.replyCode
if( !org.apache.commons.net.ftp.FTPReply.isPositiveCompletion( reply ) ) {
ftp.disconnect()
println( "FTP server refused connection." )
}
// login
ftp.login 'FTPUser', 'FTPPassword'
// transfer files
ftp.changeWorkingDirectory uploadPath
def transferFile = file fileLocation
def fis = new java.io.FileInputStream( transferFile )
ftp.storeFile transferFile.name, fis
fis.close()
printf '%s uploaded.%n', transferFile.name
ftp.logout()
} catch( IOException e ) {
error = true
e.printStackTrace()
} finally {
if( ftp.isConnected() ) {
try {
ftp.disconnect()
} catch( IOException ioe ) {
// do nothing
}
}
}
lock --
}
] as java.lang.Thread
}
// Upload distribution artifacts to an FTP
task uploadDistribution( group: 'Distribution' , dependsOn: bundleReleases ) << {
def t1 = getUploader "$libsDir/${jar.baseName}-${version}.jar", '/flick/builds'
def t2 = getUploader "$libsDir/${jar.baseName}-main-${version}.jar", '/flick/builds'
def t3 = getUploader "$distsDir/win-${jar.baseName}.zip", '/flick/Windows'
def t4 = getUploader "$distsDir/${jar.baseName}.tar.gz", '/flick/Unix'
t1.start()
t2.start()
t3.start()
t4.start()
while ( lock > 0 ) {}
}
task p << {
println sourceSets.getNames()
this.properties.sort().each { k, v ->
println "$k : $v"
}
}