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
|
// **********************************************************************
//
// Copyright (c) 2003-2017 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"
}
//
// If iceBuilderHome is set add its lib directory it to the local maven repositories
// so we can build using a local plugin version
//
if (iceBuilderHome) {
def builder = new File([iceBuilderHome, "build", "libs"].join(File.separator))
if(builder.exists()) {
repositories {
flatDir dirs: "file://${builder.getCanonicalPath()}"
}
}
}
if(new File("/usr/share/maven-repo").exists()){
repositories {
maven {
url "file:///usr/share/maven-repo"
}
}
}
repositories {
mavenCentral()
maven {
url "https://${iceMavenRepo}/nexus/content/repositories/releases"
}
}
dependencies {
classpath group: 'com.zeroc.gradle.ice-builder', name: 'slice', version: "${iceBuilderVersion}"
}
}
if (!project.plugins.findPlugin(com.zeroc.gradle.icebuilder.slice.SlicePlugin)) {
project.apply(plugin: com.zeroc.gradle.icebuilder.slice.SlicePlugin)
}
if(System.env.USE_BIN_DIST != "yes") {
slice {
iceHome = new File([project(':ice').projectDir, "..", "..", ".."].join(File.separator)).getCanonicalPath()
}
}
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 = System.properties['os.name'].toLowerCase().contains('windows')
if (!prefix) {
// 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"
}
// Check if we are building against source distribution
def iceCppDir = slice.srcDist ? [slice.iceHome, "cpp"].join(File.separator) : slice.iceHome
def iceSrcDist = false
// 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 localDependency(artifactId) {
if (project.slice.srcDist) {
return project(":${artifactId}")
} else {
return "com.zeroc:${artifactId}:${project.version}"
}
}
ext {
localDependency = this.&localDependency
}
def localappdata
def nuget
def dbVersion
def dbPackage
if (isWindows) {
nuget = "${System.env.LOCALAPPDATA}/ZeroC/nuget/nuget.exe"
dbVersion = "5.3.28.1"
dbPackage = "${iceCppDir}/third-party-packages/berkeley.db.java7"
task nugetDirectory() {
def nugetDir = new File("${localappdata}/ZeroC/nuget")
if(!nugetDir.exists()) {
nugetDir.mkdirs()
}
}
task nugetInstall(type:Exec, dependsOn:nugetDirectory) {
commandLine 'cmd', '/c', 'powershell', '-Command', "(New-Object Net.WebClient).DownloadFile('http://nuget.org/nuget.exe', '${nuget}')"
}
task nugetInstallBerkeleyDb(type:Exec) {
commandLine 'cmd', '/c', nuget, 'install', 'berkeley.db.java7', '-OutputDirectory', "${iceCppDir}/third-party-packages/", '-ExcludeVersion'
}
}
if (!android) {
//
// Find BerkeleyDB JAR
//
if(dbHome) {
ext.dbJar = "${dbHome}/db.jar"
} else if(env['DB_HOME']) {
def dbHomeDir = env['DB_HOME']
ext.dbJar = "${dbHomeDir}/lib/db.jar"
} else {
def subdirs
if (isWindows) {
if(slice.srcDist){
if(!new File(nuget).exists()) {
nugetInstall.execute()
}
if(!new File("${dbPackage}/berkeley.db.java7.nupkg").exists()) {
nugetInstallBerkeleyDb.execute()
}
subdirs = [ "${dbPackage}/build/native/lib/" ]
} else {
subdirs = [ "${slice.iceHome}/lib/" ]
}
} else {
subdirs = [
"/usr/local/opt/ice/libexec/lib/",
"/usr/local/opt/berkeley-db53/lib/",
"/usr/local/lib/",
"/usr/share/java/",
"/opt/Ice-${project.version}/lib/",
"/opt/db/lib/",
"/usr/lib/"
]
}
def candidates = ["db-5.3.28.jar", "db-5.3.21.jar", "db.jar"].collect {
def dbJarName = it
subdirs.collect {
it.concat(dbJarName)
}
}.flatten()
ext.dbJar = candidates.find {
new File(it).exists()
}
}
if(!ext.dbJar || !new File(ext.dbJar).exists()) {
throw new GradleException("Unable to locate the required third party BerkeleyDB jar file `db.jar'.")
}
}
|