-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
210 lines (183 loc) · 6.17 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
allprojects {
apply plugin: 'groovy'
repositories {
mavenCentral()
}
configurations {
all*.exclude group:'bouncycastle'
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:1.6.4'
compile 'com.google.collections:google-collections:1.0-rc2'
compile 'com.google.inject:guice:2.0'
compile 'com.google.inject.extensions:guice-multibindings:2.0'
compile 'aopalliance:aopalliance:1.0'
compile 'org.slf4j:slf4j-api:1.7.5'
runtime 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'xerces:xerces:2.3.0' // brg 2/19/2014: needed on Windows, not on OSX for some reason?
testCompile 'junit:junit:3.8.2'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
}
version = '1.2.5'
// Java runtime dir, required for packaging
project.ext.javaRuntimeFile = 'jre8'
}
// Griffon 0.2 requires compilation with Java 6
final javaHome = '/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home'
def javaExecutablesPath = new File(javaHome, 'bin')
def javaExecutables = [:].withDefault { execName ->
def executable = new File(javaExecutablesPath, execName)
assert executable.exists(): "There is no ${execName} executable in ${javaExecutablesPath}"
executable
}
tasks.withType(AbstractCompile) {
options.with {
fork = true
forkOptions.javaHome = file(javaHome)
}
}
task packageCheckMac() {
doLast {
stagingDirCheck()
def javaRuntimeDir = file("${project.rootDir}/package/java_runtime/mac")
println "Checking for Mac Java runtime dir and JRE..."
if (!javaRuntimeDir.exists()) {
throw new Error("Error: javaRuntimeDir ${javaRuntimeDir.absolutePath} does not exist.")
}
if (javaRuntimeFile == null) {
throw new Error("Error: javaRuntimeFile var is null.\nTo resolve, update javaRuntimeFile var with your Java 8 runtime in build.gradle.")
}
if (javaRuntimeDir.listFiles().find { it.name.equals(javaRuntimeFile) } == null) {
throw new Error("Error: Missing Java runtime file '${javaRuntimeFile}' in ${javaRuntimeDir.absolutePath}")
}
}
}
task packageCheckWin() {
doLast {
stagingDirCheck()
def javaRuntimeDir = file("${project.rootDir}/package/java_runtime/win")
println "Checking for Windows Java runtime dir and JRE..."
if (!javaRuntimeDir.exists()) {
throw new Error("Error: javaRuntimeDir ${javaRuntimeDir.absolutePath} does not exist.")
}
if (javaRuntimeFile == null) {
throw new Error("Error: javaRuntimeFile var is null.\nTo resolve, update javaRuntimeFile var with your Java 8 runtime in build.gradle.")
}
if (javaRuntimeDir.listFiles().find { it.name.equals(javaRuntimeFile) } == null) {
throw new Error("Error: Missing Java runtime file '${javaRuntimeFile}' in ${javaRuntimeDir.absolutePath}")
}
}
}
// Ensure staging dir is present for PSICAT and SchemeEditor.
// The staging dir is created by griffon on the run-app command. It differs from the sibling lib
// dir in one very important way: in addition to dependencies' JARs, it contains the application's
// JAR (PSICAT.jar or SchemeEditor.jar).
//
// JARs are copied into binary packages from the staging dir. Additionally, the Mac binary's Info.plist
// classpath is built from the staging dir's contents. Without a staging dir at package-time,
// built .apps and .exes will not launch and you will be confused.
def stagingDirCheck() {
['PSICAT', 'SchemeEditor'].each {
def stagingDir = file("${project.rootDir}/tools/${it}/staging")
if (!stagingDir.exists()) {
throw new Error("Error: tools/$it/staging directory does not exist. Run $it (`griffon run-app` in tools/$it) to build this directory.")
}
}
}
// Package PSICAT, SchemeEditor app bundles and resource files into a bundle
// ready for Mac distribution.
task packagePSICATMac() {
dependsOn ':tools:PSICAT:packageMac'
dependsOn ':tools:SchemeEditor:packageMac'
doLast {
def app = file("dist/mac/PSICAT-Mac-${version}")
if (!app.exists()) {
println "${app.absolutePath} not found, creating."
}
// clear existing bundle to avoid failed copy of JRE contents
delete "dist/mac/PSICAT-Mac-${version}/PSICAT.app"
copy {
into app
from "tools/PSICAT/dist/mac" // PSICAT app bundle
}
// clear existing bundle to avoid failed copy of JRE contents
delete "dist/mac/PSICAT-${version}/SchemeEditor.app"
copy {
into app
from "tools/SchemeEditor/dist/mac" // SchemeEditor app bundle
}
copy { // legacy schemes
into new File(app, "legacy schemes")
from "schemes/legacy"
}
copy { // modern schemes
into new File(app, "resources")
from "schemes"
exclude "legacy"
}
// tar and zip up the entire package
exec {
workingDir "dist/mac"
commandLine "tar", "cfvz", "PSICAT-Mac-${version}.tar.gz", "PSICAT-Mac-${version}"
}
}
}
// Package PSICAT, SchemeEditor executables and resource files into a bundle
// ready for Windows distribution.
task packagePSICATWin() {
dependsOn ':tools:PSICAT:packageWin'
dependsOn ':tools:SchemeEditor:packageWin'
doLast {
def app = file("dist/win/PSICAT-${version}")
if (!app.exists()) {
println "${app.absolutePath} not found, creating."
}
copy {
into app
from "tools/PSICAT/dist/win/PSICAT" // PSICAT dir contents
}
copy {
into app
from "tools/SchemeEditor/dist/win" // entire SchemeEditor dir
}
copy { // legacy schemes
into new File(app, "legacy schemes")
from "schemes/legacy"
}
copy { // modern schemes
into new File(app, "resources")
from "schemes"
exclude "legacy"
}
exec { // zip up the package
workingDir "dist/win/PSICAT-${version}"
commandLine "zip", "-r", "PSICAT-Win-${version}.zip", "."
}
ant.move(
file:"dist/win/PSICAT-${version}/PSICAT-Win-${version}.zip",
toFile:"dist/win/PSICAT-Win-${version}.zip"
)
}
}
// old, likely obsolete
task 'assemble-jars'(dependsOn: build) {
doLast {
File distDir = new File(buildDir, 'libs')
distDir.mkdirs()
subprojects.findAll { it.name != 'examples' && it.name != 'scripting' }.each { project ->
project.configurations?.compile?.files { dep -> dep.group != 'unspecified' }.each { dep ->
ant.zip(destfile: new File(distDir, dep.name)) {
zipfileset(src:dep, excludes:"log4j*")
}
}
copy {
from new File(project.buildDir, 'libs')
into distDir
include '*.jar'
}
}
}
}