-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
213 lines (185 loc) · 8.03 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
// Copyright (c) 2003-2018 Broad Institute, Inc., Massachusetts Institute of Technology, and Regents
// of the University of California. All rights reserved.
apply plugin: 'java'
import org.apache.tools.ant.filters.ReplaceTokens
// Define the main class for the application
ext.mainClassName = 'xapps.browser.gsea.MSigDB_XML_Browser'
// Set up the ProGuard optimizing task
buildscript {
repositories {
flatDir dirs: 'lib_build'
}
dependencies {
classpath ':proguard:'
}
}
sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/main/java8']
}
}
}
configurations {
jarsToShipUntouched
compile.extendsFrom jarsToShipUntouched
}
dependencies {
jarsToShipUntouched fileTree(dir: 'modules', include: ['log4j-core-2.11.0.jar'])
compile fileTree(dir: 'modules', include: '*.jar') + fileTree(dir: 'lib', include: '*.jar')
}
task wrapper(type: Wrapper) {
gradleVersion = '4.10.2'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
processResources {
// Set the current timestamp for release builds; pass in a blank property to enable (i.e. -Ptimestamp="" at CLI)
if (timestamp.equals("")) {
ext.date = new Date()
timestamp = date.format("EEE, d MMM yyyy HH:mm:ss Z")
// This is a more filesystem-friendly date format.
timestamp_fs = date.format("yyyy-MM-dd_HHmmss")
}
filesMatching('edu/mit/broad/msigdb_browser/genome/resources/build.properties') {
filter (ReplaceTokens,
tokens: [ VERSION: version, VERSION_MAJOR: versionMajor, VERSION_MINOR: versionMinor, VERSION_PATCH: versionPatch,
BUILD: buildNumber, TIMESTAMP: timestamp ])
}
}
jar {
archiveName = "msigdb-xml-browser-minimal-${version}.jar"
manifest {
attributes(
"Permissions": "all-permissions",
"Application-Name": "MSigDB_XML_Browser",
"Built-By": System.getProperty('user.name'),
"Main-Class": mainClassName,
"MSigDB_XML_Browser-Build-Date": timestamp,
"Codebase": "http://*.broadinstitute.org/gsea/software https://*.broadinstitute.org/gsea/software http://*.broadinstitute.org:8080/gsea/software https://*.broadinstitute.org:8080/gsea/software http://*.gsea-msigdb.org/gsea/software https://*.gsea-msigdb.org/gsea/software http://*.msigdb.org/gsea/software https://*.msigdb.org/gsea/software",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
task fullJar(type: Jar, dependsOn: jar) {
// Based on https://discuss.gradle.org/t/removing-dependencies-from-a-jar-file-during-jar-task/5521/3
archiveName = "msigdb-xml-browser-all_deps-${version}.jar"
from {
((configurations.compile - configurations.jarsToShipUntouched) + "${buildDir}/libs/msigdb-xml-browser-minimal-${version}.jar").collect {
zipTree(it)
}
} {
exclude "META-INF/**"
}
manifest {
attributes(
"Permissions": "all-permissions",
"Application-Name": "MSigDB_XML_Browser",
"Built-By": System.getProperty('user.name'),
"Main-Class": mainClassName,
"MSigDB_XML_Browser-Build-Date": timestamp,
"Codebase": "http://*.broadinstitute.org/gsea/software https://*.broadinstitute.org/gsea/software http://*.broadinstitute.org:8080/gsea/software https://*.broadinstitute.org:8080/gsea/software http://*.gsea-msigdb.org/gsea/software https://*.gsea-msigdb.org/gsea/software http://*.msigdb.org/gsea/software https://*.msigdb.org/gsea/software",
"Class-Path": configurations.jarsToShipUntouched.collect { it.getName() }.join(' ')
)
}
}
task optimizeJar(type: proguard.gradle.ProGuardTask, dependsOn: fullJar) {
doFirst { mkdir "proguard_log" }
verbose
injars "${buildDir}/libs/msigdb-xml-browser-all_deps-${version}.jar"
outjars "${buildDir}/libs/msigdb-xml-browser-${version}.jar"
libraryjars "${System.getProperty('java.home')}/lib",
jarfilter: 'rt.jar,charsets.jar,jce.jar,jfr.jar,jsse.jar,resources.jar,ext/jfxrt.jar'
libraryjars "modules", jarfilter: configurations.jarsToShipUntouched.collect { it.getName() }.join(',')
configuration "lib_build/proguard_opt.cfg"
printusage "proguard_log/proguard_opt_log_${timestamp_fs}.txt"
printseeds "proguard_log/proguard_opt_seeds_${timestamp_fs}.txt"
}
task createDist(type: Copy, dependsOn: optimizeJar) {
from ("scripts") {
include 'msigdb-xml-browser.bat'
include 'msigdb-xml-browser.command'
include 'msigdb-xml-browser.sh'
include 'readme.txt'
filter (ReplaceTokens, tokens: [ VERSION: version ])
}
with copySpec {
from ("${buildDir}/libs") {
// Use the fullJar for now, until PG is set
// include "msigdb-xml-browser-${version}.jar"
include "msigdb-xml-browser-all_deps-${version}.jar"
}
from (configurations.jarsToShipUntouched) { }
into "lib"
}
into "${buildDir}/MSigDB_XML_Browser-dist"
}
task signJars(dependsOn: createDist) {
doLast {
// Only sign if the keystoreFile exists
ext.keystoreFile = file("${keystore}")
if (keystoreFile.exists()) {
ant.jar( update: true, file: "build/MSigDB_XML_Browser-dist/lib/batik-codec-1.10.jar") {
delegate.manifest { attribute(name: 'Permissions', value: 'all-permissions') }
}
ant.jar( update: true, file: "build/MSigDB_XML_Browser-dist/lib/log4j-core-2.11.0.jar") {
delegate.manifest { attribute(name: 'Permissions', value: 'all-permissions') }
}
ant.signjar( jar: 'build/MSigDB_XML_Browser-dist/lib/*.jar', keystore:"${keystoreFile.absolutePath}",
alias: "${alias}", keypass: "${keyPassword}", storepass: "${storePassword}", tsaurl: "${tsaurl}"
)
}
}
}
task createDistZip(type: Zip, dependsOn: [createDist, signJars]) {
archiveName = "MSigDB_XML_Browser_${version}.zip"
destinationDir = file("${buildDir}/distZip")
baseName = "MSigDB_XML_Browser"
from "${buildDir}/MSigDB_XML_Browser-dist" exclude "msigdb-xml-browser.bat"
into createDistZip.baseName + "_${version}"
doLast {
project.exec { commandLine('chmod', '775', createDistZip.archivePath ) }
}
}
task createMacDist(type: Copy, dependsOn: [createDist, signJars]) {
with copySpec {
from ("scripts/mac.app") exclude "Contents/Info.plist.template"
into "MSigDB_XML_Browser_${version}.app"
}
with copySpec {
from ("scripts/mac.app/Contents/Info.plist.template")
filter (ReplaceTokens, tokens: [ VERSION: version ])
rename "Info.plist.template", "Info.plist"
into "MSigDB_XML_Browser_${version}.app/Contents"
}
with copySpec {
from ("${buildDir}/MSigDB_XML_Browser-dist/lib") include '*.jar'
into "MSigDB_XML_Browser_${version}.app/Contents/Java"
}
into "${buildDir}/MSigDB_XML_Browser-Mac-dist"
doLast {
project.exec { commandLine('chmod', '775', "${buildDir}/MSigDB_XML_Browser-Mac-dist/MSigDB_XML_Browser_${version}.app" ) }
}
}
task createMacDistZip(type: Zip, dependsOn: createMacDist) {
archiveName = "MSigDB_XML_Browser_${version}.app.zip"
destinationDir = file("${buildDir}/distZip")
from "${buildDir}/MSigDB_XML_Browser-Mac-dist"
doLast {
project.exec { commandLine('chmod', '775', createMacDistZip.archivePath ) }
}
}
task createWinDistZip(type: Zip, dependsOn: [createDist, signJars]) {
archiveName = "MSigDB_XML_Browser_Win_${version}.zip"
destinationDir = file("${buildDir}/distZip")
baseName = "MSigDB_XML_Browser_Win"
from("${buildDir}/MSigDB_XML_Browser-dist") {
exclude "msigdb-xml-browser.sh"
exclude "msigdb-xml-browser.command"
}
into createWinDistZip.baseName + "_${version}"
doLast {
project.exec { commandLine('chmod', '775', createWinDistZip.archivePath ) }
}
}
build.dependsOn createDistZip,createMacDistZip,createWinDistZip