blob: a27633dbf67431578b152c7221e59a36a3cee2ee (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
buildscript {
def env = System.getenv()
ext.iceMavenRepo = env['ICE_MAVEN_REPOSITORY']
if (ext.iceMavenRepo == null) {
ext.iceMavenRepo = "repo.zeroc.com"
}
repositories {
maven {
url "https://${iceMavenRepo}/nexus/content/repositories/releases"
}
}
dependencies {
classpath group: 'com.zeroc.gradle.ice-builder', name: 'slice', version: '1.2.1'
}
}
if (!project.plugins.findPlugin(com.zeroc.gradle.icebuilder.slice.SlicePlugin)) {
project.apply(plugin: com.zeroc.gradle.icebuilder.slice.SlicePlugin)
}
ext.generatedDir = "$project.buildDir/generated"
ext.useLocalOnly = false
def android = false
try {
compileJava {
options.debug = debug
}
} catch(MissingMethodException ex) {
// For Android builds: thrown if compileJava isn't available.
android = true
}
def env = System.getenv()
// Determine the name of the Slice-to-Java translator
def isWindows = false
def programFiles
def slice2java = "slice2java"
def platform
def configuration
if (System.properties['os.name'].toLowerCase().contains('windows')) {
if(ext.cppPlatform != null && ext.cppPlatform.length() > 0)
{
platform = ext.cppPlatform
}
if(ext.cppConfiguration != null && ext.cppConfiguration.length() > 0)
{
configuration = ext.cppConfiguration
}
if(platform == null)
{
platform = env['CPP_PLATFORM']
}
if(configuration == null)
{
configuration = env['CPP_CONFIGURATION']
}
isWindows = true
slice2java = "${platform}/${configuration}/slice2java.exe"
def arch1 = env['PROCESSOR_ARCHITECTURE']
def arch2 = env['PROCESSOR_ARCHITEW6432']
if (arch1 == "AMD64" || arch1 == "IA64" || arch2 == "AMD64" || arch2 == "IA64") {
programFiles = System.getenv('ProgramFiles(x86)')
} else {
programFiles = System.getenv('ProgramFiles')
}
}
if (prefix == null || prefix.length() == 0) {
// If the prefix isn't set use these default locations.
if (isWindows) {
prefix = "C:\\Ice-${project.version}"
} else {
prefix = "/opt/Ice-${project.version}"
}
}
// Installation location for jar/pom & executables.
//
// Note that we exclude /usr/src/packages because it's the RPM build directory on SLES.
//
if ((prefix.startsWith("/usr") || prefix.startsWith("/usr/local")) && !prefix.startsWith("/usr/src/packages")) {
ext.jarDir = prefix + "/share/java"
ext.binDir = prefix + "/bin"
} else {
ext.jarDir = prefix + "/lib"
ext.binDir = prefix + "/bin"
}
// First check if ICE_HOME is set and it points at a valid installation
def iceHome = env['ICE_HOME']
if (iceHome != null && iceHome.length() > 0) {
def translator = new File("$iceHome/bin/$slice2java")
if (!translator.exists()) {
//
// Make sure ICE_HOME is not just pointing to the source distribution
//
translator = new File("$iceHome/cpp/bin/$slice2java")
if (!translator.exists()) {
throw new GradleException("Unable to find $slice2java in $iceHome, please verify ICE_HOME is " +
"properly configured and Ice is correctly installed.")
}
iceHome = null
}
}
def iceBinDist = false
if(env['USE_BIN_DIST'] == "yes") {
iceBinDist = true
}
// Check if we are building against source distribution
def iceDir
def iceCppDir
def iceSrcDist = false
if (!iceBinDist) {
def f1 = new File("$rootProject.projectDir/../java/src/Ice/src/main/java/Ice/Util.java")
if (f1.exists()) {
iceDir = "$rootProject.projectDir/.."
iceSrcDist = true
if (iceHome != null && iceHome.length() > 0) {
iceCppDir = iceHome
def f2 = new File("$iceDir/cpp/bin/$slice2java")
if (f2.exists()) {
println "Found $slice2java in both $iceCppDir/bin and $iceDir/cpp/bin, $iceCppDir/bin/$slice2java will be used!"
}
} else {
iceCppDir = iceDir + "/cpp"
slice.srcDist = true
slice.cppPlatform = platform
slice.cppConfiguration = configuration
}
slice.iceHome = iceCppDir
}
}
// Then, check if we're building against a binary distribution.
if (!iceDir) {
if (iceHome != null && iceHome.length() > 0) {
iceDir = iceHome
}
if (iceDir == null) {
def f1 = new File("/usr/bin/$slice2java")
if (f1.exists()) {
iceDir = "/usr"
}
}
if (iceDir == null && isWindows) {
iceDir = "${programFiles}\\ZeroC\\Ice-${project.version}"
}
if (iceDir == null) {
def f1 = new File("/usr/local/bin/${slice2java}")
if (f1.exists()) {
iceDir = "/usr/local"
}
}
if (iceDir == null) {
def f1 = new File("/opt/Ice-${project.version}/bin/${slice2java}")
if (f1.exists())
{
iceDir = "/opt/Ice-${project.version}"
}
}
if (iceDir == null) {
throw new GradleException("Unable to find a valid Ice distribution, please verify ICE_HOME is properly " +
"configured and Ice is correctly installed.")
}
slice.iceHome = iceDir
slice.srcDist = false
}
// Set the slice and java jar directory
if (iceDir == "/usr") {
ext.sliceDir = "/usr/share/Ice-${project.version}/slice"
ext.distJarDir = "/usr/share/java"
} else if (iceDir == "/usr/local") {
ext.sliceDir = "/usr/local/share/slice"
ext.distJarDir = "/usr/local/share/java"
} else {
ext.sliceDir = "${iceDir}/slice"
ext.distJarDir = iceSrcDist ? null : "${iceDir}/lib"
}
// Check is DESTDIR is set (non-Windows)
if (isWindows) {
ext.DESTDIR = ""
}
ext.versionSuffix = "-${project.version}"
ext.libDir = "$rootProject.projectDir/lib"
ext.iceSourceCompatibility = 1.7
ext.iceTargetCompatibility = 1.7
ext.searchFile = { List<Closure> places, List<String> searchPaths ->
def dirs = []
places.each {
def dir = it()
if(dir != null) {
dirs << dir + "/"
}
}
def candidates = searchPaths.collect {
def path = it
dirs.collect {
it.concat(path)
}
}.flatten()
return candidates.find {
new File(it).exists()
}
}
def demoJar(name) {
def taskName = name + "Jar"
// Create a jar for the client & server which includes everything in the demo.
def jarTask = tasks.create(name: taskName, type: Jar) {
version = ""
baseName = name
from(sourceSets.main.output) {
include "**"
}
}
jarTask.manifest {
attributes("Main-Class": name.capitalize())
attributes("Class-Path": configurations.runtime.resolve().collect { it.toURI() }.join(' '))
}
artifacts {
archives jarTask
}
}
ext {
demoJar = this.&demoJar
}
def localDependency(artifactId) {
if (distJarDir != null) {
return "com.zeroc:${artifactId}:${project.version}"
} else {
return project(":${artifactId}")
}
}
ext {
localDependency = this.&localDependency
}
|