Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 1 | /* |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 2 | * Copyright 2000-2014 JetBrains s.r.o. |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 17 | import org.jetbrains.jps.gant.JpsGantTool |
| 18 | import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter |
| 19 | import org.jetbrains.jps.model.java.JavaSourceRootType |
| 20 | import org.jetbrains.jps.model.module.JpsModule |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 21 | |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 22 | includeTool << JpsGantTool |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 23 | |
| 24 | binding.setVariable("p", {String key -> |
| 25 | return getProperty(key) as String |
| 26 | }) |
| 27 | |
| 28 | binding.setVariable("guessJdk", { |
| 29 | String javaHome = p("java.home") |
| 30 | |
| 31 | if (new File(javaHome).getName() == "jre") { |
| 32 | javaHome = new File(javaHome).getParent() |
| 33 | } |
| 34 | |
| 35 | return javaHome |
| 36 | }) |
| 37 | |
| 38 | binding.setVariable("includeFile", {String filePath -> |
| 39 | Script s = groovyShell.parse(new File(filePath)) |
| 40 | s.setBinding(binding) |
| 41 | s |
| 42 | }) |
| 43 | |
| 44 | binding.setVariable("isMac", { |
| 45 | return System.getProperty("os.name").toLowerCase().startsWith("mac") |
| 46 | }) |
| 47 | |
| 48 | binding.setVariable("isWin", { |
| 49 | return System.getProperty("os.name").toLowerCase().startsWith("windows") |
| 50 | }) |
| 51 | |
| 52 | binding.setVariable("isEap", { |
| 53 | return "true" == p("component.version.eap") |
| 54 | }) |
| 55 | |
Tor Norbye | 02cf98d6 | 2014-08-19 12:53:10 -0700 | [diff] [blame] | 56 | binding.setVariable("mem32", "-server -Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=150m") |
| 57 | binding.setVariable("mem64", "-Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=225m") |
Tor Norbye | c1ace1f | 2013-07-08 11:26:24 -0700 | [diff] [blame] | 58 | binding.setVariable("common_vmoptions", "-ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true " + |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 59 | "-Didea.project.structure.max.errors.to.show=0 " + |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 60 | "-Djsse.enableSNIExtension=false " + |
Tor Norbye | 02cf98d6 | 2014-08-19 12:53:10 -0700 | [diff] [blame] | 61 | "-XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 62 | |
| 63 | binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() }) |
| 64 | binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() }) |
| 65 | binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() }) |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 66 | |
| 67 | binding.setVariable("yjpOptions", { String systemSelector, String platformSuffix = "" -> |
Tor Norbye | c667c1f | 2014-05-28 17:06:51 -0700 | [diff] [blame] | 68 | "-agentlib:yjpagent$platformSuffix=probe_disable=*,disablealloc,disabletracing,onlylocal,disableexceptiontelemetry,delay=10000,sessionname=$systemSelector".trim() |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 69 | }) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 70 | binding.setVariable("vmOptions32yjp", { String systemSelector -> |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 71 | "${vmOptions32()} ${yjpOptions(systemSelector)}".trim() |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 72 | }) |
| 73 | binding.setVariable("vmOptions64yjp", { String systemSelector -> |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 74 | "${vmOptions64()} ${yjpOptions(systemSelector, "64")}".trim() |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 75 | }) |
| 76 | |
| 77 | binding.setVariable("isDefined", {String key -> |
| 78 | try { |
| 79 | this[key] |
| 80 | return true |
| 81 | } |
| 82 | catch (MissingPropertyException ignored) { |
| 83 | return false |
| 84 | } |
| 85 | }) |
| 86 | |
| 87 | private String require(String key) { |
| 88 | try { |
| 89 | this[key] |
| 90 | } |
| 91 | catch (MissingPropertyException ignored) { |
Tor Norbye | 2e5965e | 2014-07-25 12:24:15 -0700 | [diff] [blame] | 92 | projectBuilder.error("Property '$key' is required") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
| 96 | private String require(String key, String defaultValue) { |
| 97 | try { |
| 98 | this[key] |
| 99 | } |
| 100 | catch (MissingPropertyException ignored) { |
Tor Norbye | 2e5965e | 2014-07-25 12:24:15 -0700 | [diff] [blame] | 101 | projectBuilder.info("'$key' is not defined. Defaulting to '$defaultValue'") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 102 | this[key] = defaultValue |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | binding.setVariable("requireProperty", {String key, String defaultValue = null -> |
| 107 | if (defaultValue == null) { |
| 108 | require(key) |
| 109 | } |
| 110 | else { |
| 111 | require(key, defaultValue) |
| 112 | } |
| 113 | }) |
| 114 | |
| 115 | binding.setVariable("guessHome", { |
Tor Norbye | 2e5965e | 2014-07-25 12:24:15 -0700 | [diff] [blame] | 116 | // current file is supposed to be at build/scripts/*.gant path |
| 117 | String uri = requireProperty("gant.file") |
| 118 | new File(new URI(uri).getSchemeSpecificPart()).getParentFile().getParentFile().getParent() |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 119 | }) |
| 120 | |
| 121 | binding.setVariable("loadProject", { |
| 122 | requireProperty("jdkHome", guessJdk()) |
| 123 | def mac = isMac() |
| 124 | jdk("IDEA jdk", jdkHome) { |
| 125 | if (!mac) { |
| 126 | classpath "$jdkHome/lib/tools.jar" |
| 127 | } |
| 128 | } |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 129 | projectBuilder.dataStorageRoot = new File("$home/.jps-build-data") |
| 130 | loadProjectFromPath(home) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 131 | }) |
| 132 | |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 133 | boolean hasSourceRoots(JpsModule module) { |
| 134 | return module.getSourceRoots(JavaSourceRootType.SOURCE).iterator().hasNext() |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | binding.setVariable("findModule", {String name -> |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 138 | project.modules.find { it.name == name } |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 139 | }) |
| 140 | |
| 141 | binding.setVariable("allModules", { |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 142 | return project.modules |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 143 | }) |
| 144 | |
| 145 | binding.setVariable("printUnusedModules", {Set<String> usedModules -> |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 146 | allModules().each {JpsModule m -> |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 147 | if (!usedModules.contains(m.name) && hasSourceRoots(m)) { |
| 148 | projectBuilder.warning("Module $m.name is not used in project layout") |
| 149 | } |
| 150 | } |
| 151 | }) |
| 152 | |
| 153 | requireProperty("home", guessHome()) |
| 154 | |
| 155 | String readSnapshotBuild() { |
| 156 | def file = new File("$home/community/build.txt") |
| 157 | if (!file.exists()) { |
| 158 | file = new File("$home/build.txt") |
| 159 | } |
| 160 | |
| 161 | return file.readLines().get(0) |
| 162 | } |
| 163 | |
| 164 | binding.setVariable("snapshot", readSnapshotBuild()) |
| 165 | |
Tor Norbye | 6739a8f | 2013-08-07 11:11:08 -0700 | [diff] [blame] | 166 | projectBuilder.buildInfoPrinter = new TeamCityBuildInfoPrinter() |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 167 | projectBuilder.compressJars = false |
| 168 | |
| 169 | binding.setVariable("notifyArtifactBuilt", { String artifactPath -> |
| 170 | if (!artifactPath.startsWith(home)) { |
Siva Velusamy | 3ff7bb6 | 2013-09-06 15:47:55 -0700 | [diff] [blame] | 171 | // AndroidStudio: make this to be just an info as the out folder is typically |
| 172 | // not in the home folder |
| 173 | projectBuilder.info("Artifact path $artifactPath should start with $home") |
| 174 | return |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 175 | } |
| 176 | def relativePath = artifactPath.substring(home.length()) |
| 177 | if (relativePath.startsWith("/")) { |
| 178 | relativePath = relativePath.substring(1) |
| 179 | } |
| 180 | def file = new File(artifactPath) |
| 181 | if (file.isDirectory()) { |
| 182 | relativePath += "=>" + file.name |
| 183 | } |
| 184 | projectBuilder.info("##teamcity[publishArtifacts '$relativePath']") |
| 185 | }) |
| 186 | |
| 187 | def suspendUntilDebuggerConnect = System.getProperty("debug.suspend") ?: "n" |
| 188 | def debugPort = System.getProperty("debug.port") ?: 5555 |
| 189 | if (suspendUntilDebuggerConnect == 'y') { |
| 190 | println """\ |
| 191 | ------------->----------- This process is suspended until remote debugger connects to the port $debugPort ----<---- |
Tor Norbye | 8fb00210 | 2013-05-01 12:55:43 -0700 | [diff] [blame] | 192 | -------------------------------------------^------^------^------^------^------^------^----------------------- |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 193 | """ |
| 194 | } |
| 195 | |
| 196 | binding.setVariable("patchFiles", { List files, Map args, String marker = "__" -> |
| 197 | files.each { file -> |
| 198 | args.each { arg -> |
| 199 | ant.replace(file: file, token: "${marker}${arg.key}${marker}", value: arg.value) |
| 200 | } |
| 201 | } |
| 202 | }) |
| 203 | |
| 204 | binding.setVariable("copyAndPatchFile", { String file, String target, Map args, String marker = "__" -> |
| 205 | ant.copy(file: file, tofile: target, overwrite: "true") { |
| 206 | filterset(begintoken: marker, endtoken: marker) { |
| 207 | args.each { |
| 208 | filter(token: it.key, value: it.value) |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | }) |
| 213 | |
| 214 | binding.setVariable("copyAndPatchFiles", { Closure files, String target, Map args, String marker = "__" -> |
| 215 | ant.copy(todir: target, overwrite: "true") { |
| 216 | files() |
| 217 | |
| 218 | filterset(begintoken: marker, endtoken: marker) { |
| 219 | args.each { |
| 220 | filter(token: it.key, value: it.value) |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | }) |
| 225 | |
| 226 | binding.setVariable("wireBuildDate", { String buildNumber, String appInfoFile -> |
| 227 | ant.tstamp() |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 228 | patchFiles([appInfoFile], ["BUILD_NUMBER": buildNumber, "BUILD_DATE": DSTAMP, |
| 229 | "PACKAGE_CODE": buildNumber.substring(0, buildNumber.indexOf('-'))]) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 230 | }) |
| 231 | |
| 232 | binding.setVariable("commonJvmArgs", { |
| 233 | return [ |
| 234 | "-ea", |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 235 | "-server", |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 236 | "-Didea.home.path=$home", |
| 237 | "-Xbootclasspath/p:${projectBuilder.moduleOutput(findModule("boot"))}", |
| 238 | "-XX:+HeapDumpOnOutOfMemoryError", |
| 239 | "-Didea.system.path=${p("teamcity.build.tempDir")}/system", |
Siva Velusamy | a3091f6 | 2014-04-30 07:15:29 -0700 | [diff] [blame] | 240 | "-Didea.config.path=${p("teamcity.build.tempDir")}/config"] |
| 241 | // We don't want this on the Jenkins build server |
| 242 | // "-Xdebug", |
| 243 | // "-Xrunjdwp:transport=dt_socket,server=y,suspend=$suspendUntilDebuggerConnect,address=$debugPort"] |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 244 | }) |
| 245 | |
| 246 | binding.setVariable("classPathLibs", [ |
| 247 | "bootstrap.jar", |
| 248 | "extensions.jar", |
| 249 | "util.jar", |
| 250 | "jdom.jar", |
| 251 | "log4j.jar", |
| 252 | "trove4j.jar", |
| 253 | "jna.jar" |
| 254 | ]) |
| 255 | |
| 256 | binding.setVariable("platformApiModules", [ |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 257 | "analysis-api", |
| 258 | "core-api", |
Tor Norbye | 1aa2e09 | 2014-08-20 17:01:23 -0700 | [diff] [blame] | 259 | "dvcs-api", |
Tor Norbye | c7f983b | 2013-09-05 16:07:26 -0700 | [diff] [blame] | 260 | "editor-ui-api", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 261 | "external-system-api", |
| 262 | "indexing-api", |
| 263 | "jps-model-api", |
| 264 | "lang-api", |
| 265 | "lvcs-api", |
| 266 | "projectModel-api", |
| 267 | "platform-api", |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 268 | "structure-view-api", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 269 | "usageView", |
| 270 | "vcs-api", |
Tor Norbye | 1aa2e09 | 2014-08-20 17:01:23 -0700 | [diff] [blame] | 271 | "vcs-api-core", |
Tor Norbye | 32218cc | 2013-10-08 09:48:09 -0700 | [diff] [blame] | 272 | "vcs-log-api", |
Tor Norbye | c667c1f | 2014-05-28 17:06:51 -0700 | [diff] [blame] | 273 | "vcs-log-graph-api", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 274 | "xdebugger-api", |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 275 | "remote-servers-api", |
| 276 | "remote-servers-agent-rt", |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 277 | "xml-analysis-api", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 278 | "xml-openapi", |
| 279 | "xml-psi-api", |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 280 | "xml-structure-view-api", |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 281 | ]) |
| 282 | |
| 283 | |
| 284 | binding.setVariable("platformImplementationModules", [ |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 285 | "analysis-impl", |
| 286 | "core-impl", |
Tor Norbye | 1aa2e09 | 2014-08-20 17:01:23 -0700 | [diff] [blame] | 287 | "dvcs-impl", |
Tor Norbye | a28de54 | 2013-09-11 15:53:32 -0700 | [diff] [blame] | 288 | "editor-ui-ex", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 289 | "images", |
| 290 | "indexing-impl", |
| 291 | "jps-model-impl", |
| 292 | "jps-model-serialization", |
| 293 | "lang-impl", |
| 294 | "lvcs-impl", |
| 295 | "projectModel-impl", |
| 296 | "platform-impl", |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 297 | "structure-view-impl", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 298 | "vcs-impl", |
Tor Norbye | 32218cc | 2013-10-08 09:48:09 -0700 | [diff] [blame] | 299 | "vcs-log-graph", |
| 300 | "vcs-log-impl", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 301 | "testRunner", |
| 302 | "smRunner", |
| 303 | "relaxng", |
| 304 | "RegExpSupport", |
| 305 | "spellchecker", |
| 306 | "xdebugger-impl", |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 307 | "remote-servers-impl", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 308 | "xml", |
Tor Norbye | 3a2425a5 | 2013-11-04 10:16:08 -0800 | [diff] [blame] | 309 | "xml-analysis-impl", |
Tor Norbye | ec3fb1e | 2013-05-31 07:45:51 -0700 | [diff] [blame] | 310 | "xml-psi-impl", |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 311 | "xml-structure-view-impl", |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 312 | "protocol-reader-runtime", |
| 313 | "script-debugger-backend", |
| 314 | "script-debugger-ui" |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 315 | ]) |
| 316 | |
| 317 | binding.setVariable("layoutMacApp", { String path, String ch, Map args -> |
| 318 | ant.copy(todir: "$path/bin") { |
| 319 | fileset(dir: "$ch/bin/mac") |
| 320 | } |
| 321 | |
| 322 | ant.copy(todir: path) { |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 323 | fileset(dir: "$ch/build/conf/mac/Contents") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | ant.tstamp() { |
| 327 | format(property: "todayYear", pattern: "yyyy") |
| 328 | } |
| 329 | |
| 330 | String executable = args.executable != null ? args.executable : p("component.names.product").toLowerCase() |
| 331 | String helpId = args.help_id != null ? args.help_id : "IJ" |
| 332 | String icns = "idea.icns" |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 333 | String helpIcns = "$path/Resources/${helpId}.help/Contents/Resources/Shared/product.icns" |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 334 | if (args.icns != null) { |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 335 | ant.delete(file: "$path/Resources/idea.icns") |
| 336 | ant.copy(file: args.icns, todir: "$path/Resources") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 337 | ant.copy(file: args.icns, tofile: helpIcns) |
| 338 | icns = new File((String)args.icns).getName(); |
| 339 | } else { |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 340 | ant.copy(file: "$path/Resources/idea.icns", tofile: helpIcns) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | String fullName = args.fullName != null ? args.fullName : p("component.names.fullname") |
| 344 | |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 345 | String vmOptions = "-Dfile.encoding=UTF-8 ${vmOptions()} -Xverify:none" |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 346 | |
| 347 | String minor = p("component.version.minor") |
| 348 | String version = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "EAP $args.buildNumber" : "${p("component.version.major")}.${minor}" |
| 349 | |
| 350 | Map properties = readIdeaProperties(args) |
| 351 | |
| 352 | def coreKeys = ["idea.platform.prefix", "idea.paths.selector"] |
| 353 | |
| 354 | String coreProperties = submapToXml(properties, coreKeys); |
| 355 | |
| 356 | StringBuilder effectiveProperties = new StringBuilder() |
| 357 | properties.each { k, v -> |
| 358 | if (!coreKeys.contains(k)) { |
| 359 | effectiveProperties.append("$k=$v\n"); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | new File("$path/bin/idea.properties").text = effectiveProperties.toString() |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 364 | String ideaVmOptions = "$mem64 -XX:+UseCompressedOops".split(" ").join("\n") |
| 365 | if (isEap() && !args.mac_no_yjp) { |
| 366 | ideaVmOptions += " ${yjpOptions(args.system_selector)}" |
| 367 | } |
| 368 | new File("$path/bin/idea.vmoptions").text = ideaVmOptions |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 369 | |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 370 | String classPath = classPathLibs.collect {"\$APP_PACKAGE/Contents/lib/${it}" }.join(":") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 371 | |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 372 | String archs = """ |
| 373 | <key>LSArchitecturePriority</key> |
| 374 | <array>""" |
Vladimir Orlov | 0344e5a | 2014-02-28 11:46:37 +0400 | [diff] [blame] | 375 | (args.archs != null ? args.archs : ["x86_64", "i386"]).each { |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 376 | archs += "<string>${it}</string>" |
| 377 | } |
| 378 | archs +="</array>\n" |
| 379 | |
Jean-Baptiste Queru | 1d526b1 | 2013-02-27 09:41:48 -0800 | [diff] [blame] | 380 | String urlSchemes = "" |
| 381 | if (args.urlSchemes != null) { |
| 382 | urlSchemes += """ |
| 383 | <key>CFBundleURLTypes</key> |
| 384 | <array> |
| 385 | <dict> |
| 386 | <key>CFBundleTypeRole</key> |
| 387 | <string>Editor</string> |
| 388 | <key>CFBundleURLName</key> |
| 389 | <string>Stacktrace</string> |
| 390 | <key>CFBundleURLSchemes</key> |
| 391 | <array> |
| 392 | """ |
| 393 | args.urlSchemes.each { scheme -> |
| 394 | urlSchemes += " <string>${scheme}</string>" |
| 395 | } |
| 396 | urlSchemes += """ |
| 397 | </array> |
| 398 | </dict> |
| 399 | </array> |
| 400 | """ |
| 401 | } |
| 402 | |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 403 | ant.replace(file: "$path/Info.plist") { |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 404 | replacefilter(token: "@@build@@", value: args.buildNumber) |
| 405 | replacefilter(token: "@@doc_types@@", value: ifNull(args.doc_types, "")) |
| 406 | replacefilter(token: "@@executable@@", value: executable) |
| 407 | replacefilter(token: "@@icns@@", value: icns) |
| 408 | replacefilter(token: "@@bundle_name@@", value: fullName) |
| 409 | replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier) |
| 410 | replacefilter(token: "@@year@@", value: "$todayYear") |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 411 | replacefilter(token: "@@company_name@@", value: args.companyName) |
| 412 | replacefilter(token: "@@min_year@@", value: "2013") |
| 413 | replacefilter(token: "@@max_year@@", value: "$todayYear") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 414 | replacefilter(token: "@@version@@", value: version) |
| 415 | replacefilter(token: "@@vmoptions@@", value: vmOptions) |
| 416 | replacefilter(token: "@@idea_properties@@", value: coreProperties) |
| 417 | replacefilter(token: "@@class_path@@", value: classPath) |
| 418 | replacefilter(token: "@@help_id@@", value: helpId) |
Jean-Baptiste Queru | 1d526b1 | 2013-02-27 09:41:48 -0800 | [diff] [blame] | 419 | replacefilter(token: "@@url_schemes@@", value: urlSchemes) |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 420 | replacefilter(token: "@@archs@@", value: archs) |
Tor Norbye | 0f831a7 | 2014-04-25 07:38:52 -0700 | [diff] [blame] | 421 | replacefilter(token: "@@min_osx@@", value: ifNull(args.min_osx, "10.6")) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | if (executable != "idea") { |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 425 | ant.move(file: "$path/MacOS/idea", tofile: "$path/MacOS/$executable") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | ant.replace(file: "$path/bin/inspect.sh") { |
| 429 | replacefilter(token: "@@product_full@@", value: fullName) |
| 430 | replacefilter(token: "@@script_name@@", value: executable) |
| 431 | } |
| 432 | if (args.inspect_script != null && args.inspect_script != "inspect") { |
| 433 | ant.move(file: "$path/bin/inspect.sh", tofile: "$path/bin/${args.inspect_script}.sh") |
| 434 | } |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 435 | |
| 436 | ant.fixcrlf(srcdir: "$path/bin", includes: "*.sh", eol: "unix") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 437 | }) |
| 438 | |
| 439 | binding.setVariable("winScripts", { String target, String home, String name, Map args -> |
| 440 | String fullName = args.fullName != null ? args.fullName : p("component.names.fullname") |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 441 | String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase().replace(" ", "_") |
| 442 | String vm_options = args.vm_options != null ? args.vm_options : "${p("component.names.product").toLowerCase().replace(" ", "-")}.exe" |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 443 | if (vm_options.endsWith(".exe")) { |
| 444 | vm_options = vm_options.replace(".exe", "%BITS%.exe") |
| 445 | } |
| 446 | else { |
| 447 | vm_options = vm_options + "%BITS%" |
| 448 | } |
| 449 | |
| 450 | String classPath = "SET CLASS_PATH=%IDE_HOME%\\lib\\${classPathLibs[0]}\n" |
| 451 | classPath += classPathLibs[1..-1].collect {"SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\\lib\\${it}"}.join("\n") |
| 452 | if (args.tools_jar) classPath += "\nSET CLASS_PATH=%CLASS_PATH%;%JDK%\\lib\\tools.jar" |
| 453 | |
| 454 | ant.copy(todir: "$target/bin") { |
| 455 | fileset(dir: "$home/bin/scripts/win") |
| 456 | |
| 457 | filterset(begintoken: "@@", endtoken: "@@") { |
| 458 | filter(token: "product_full", value: fullName) |
| 459 | filter(token: "product_uc", value: product_uc) |
| 460 | filter(token: "vm_options", value: vm_options) |
| 461 | filter(token: "isEap", value: isEap()) |
| 462 | filter(token: "system_selector", value: args.system_selector) |
| 463 | filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, "")) |
| 464 | filter(token: "class_path", value: classPath) |
| 465 | filter(token: "script_name", value: name) |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | if (name != "idea.bat") { |
| 470 | ant.move(file: "$target/bin/idea.bat", tofile: "$target/bin/$name") |
| 471 | } |
| 472 | if (args.inspect_script != null && args.inspect_script != "inspect") { |
| 473 | ant.move(file: "$target/bin/inspect.bat", tofile: "$target/bin/${args.inspect_script}.bat") |
| 474 | } |
| 475 | |
| 476 | ant.fixcrlf(srcdir: "$target/bin", includes: "*.bat", eol: "dos") |
| 477 | }) |
| 478 | |
| 479 | private ifNull(v, defVal) { v != null ? v : defVal } |
| 480 | |
| 481 | binding.setVariable("unixScripts", { String target, String home, String name, Map args -> |
| 482 | String fullName = args.fullName != null ? args.fullName : p("component.names.fullname") |
| 483 | String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase() |
| 484 | String vm_options = args.vm_options != null ? args.vm_options : p("component.names.product").toLowerCase() |
| 485 | |
| 486 | String classPath = "CLASSPATH=\"\$IDE_HOME/lib/${classPathLibs[0]}\"\n" |
| 487 | classPath += classPathLibs[1..-1].collect {"CLASSPATH=\"\$CLASSPATH:\$IDE_HOME/lib/${it}\""}.join("\n") |
| 488 | if (args.tools_jar) classPath += "\nCLASSPATH=\"\$CLASSPATH:\$JDK/lib/tools.jar\"" |
| 489 | |
| 490 | ant.copy(todir: "$target/bin") { |
| 491 | fileset(dir: "$home/bin/scripts/unix") |
| 492 | |
| 493 | filterset(begintoken: "@@", endtoken: "@@") { |
| 494 | filter(token: "product_full", value: fullName) |
| 495 | filter(token: "product_uc", value: product_uc) |
| 496 | filter(token: "vm_options", value: vm_options) |
| 497 | filter(token: "isEap", value: isEap()) |
| 498 | filter(token: "system_selector", value: args.system_selector) |
| 499 | filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, "")) |
| 500 | filter(token: "class_path", value: classPath) |
| 501 | filter(token: "script_name", value: name) |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | if (name != "idea.sh") { |
| 506 | ant.move(file: "$target/bin/idea.sh", tofile: "$target/bin/$name") |
| 507 | } |
| 508 | if (args.inspect_script != null && args.inspect_script != "inspect") { |
| 509 | ant.move(file: "$target/bin/inspect.sh", tofile: "$target/bin/${args.inspect_script}.sh") |
| 510 | } |
| 511 | |
| 512 | ant.fixcrlf(srcdir: "$target/bin", includes: "*.sh", eol: "unix") |
| 513 | }) |
| 514 | |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 515 | binding.setVariable("winVMOptions", { String target, Map args, String name, String name64 = null -> |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 516 | if (name != null) { |
| 517 | def options = vmOptions32() |
| 518 | options = options.replace(" -XX:+UseCodeCacheFlushing", "") |
| 519 | options += " -Didea.platform.prefix=" + args.platform_prefix |
| 520 | options += " -Didea.paths.selector=" + args.system_selector |
| 521 | ant.echo(file: "$target/bin/${name}.vmoptions", message: options.replace(' ', '\n')) |
| 522 | } |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 523 | |
| 524 | if (name64 != null) { |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 525 | def options = vmOptions64() |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 526 | options += " -Didea.platform.prefix=" + args.platform_prefix |
| 527 | options += " -Didea.paths.selector=" + args.system_selector |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 528 | ant.echo(file: "$target/bin/${name64}.vmoptions", message: options.replace(' ', '\n')) |
| 529 | } |
| 530 | |
| 531 | ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "dos") |
| 532 | }) |
| 533 | |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 534 | binding.setVariable("unixVMOptions", { String target, String name, String name64 = (name + "64") -> |
| 535 | if (name != null) { |
| 536 | ant.echo(file: "$target/bin/${name}.vmoptions", message: "${vmOptions32()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n')) |
| 537 | } |
| 538 | if (name64 != null) { |
| 539 | ant.echo(file: "$target/bin/${name64}.vmoptions", message: "${vmOptions64()} -Dawt.useSystemAAFontSettings=lcd".trim().replace(' ', '\n')) |
| 540 | } |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 541 | ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "unix") |
| 542 | }) |
| 543 | |
| 544 | binding.setVariable("unixReadme", { String target, String home, Map args -> |
| 545 | String fullName = args.fullName != null ? args.fullName : p("component.names.fullname") |
| 546 | String settings_dir = args.system_selector.replaceFirst("\\d+", "") |
| 547 | copyAndPatchFile("$home/build/Install-Linux-tar.txt", "$target/Install-Linux-tar.txt", |
| 548 | ["product_full": fullName, |
| 549 | "product": p("component.names.product").toLowerCase(), |
| 550 | "system_selector": args.system_selector, |
Siva Velusamy | a9491e2 | 2013-09-30 16:25:05 -0700 | [diff] [blame] | 551 | "script_name" : args.script_name, |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 552 | "settings_dir": settings_dir], "@@") |
| 553 | ant.fixcrlf(file: "$target/bin/Install-Linux-tar.txt", eol: "unix") |
| 554 | }) |
| 555 | |
| 556 | binding.setVariable("forceDelete", { String dirPath -> |
| 557 | // if wasn't deleted - retry several times |
| 558 | attempt = 1 |
| 559 | while (attempt < 21 && (new File(dirPath).exists())) { |
| 560 | if (attempt > 1) { |
| 561 | ant.echo "Deleting $dirPath ... (attempt=$attempt)" |
| 562 | |
| 563 | // let's wait a bit and try again - may be help |
| 564 | // in some cases on our windows 7 agents |
| 565 | sleep(2000) |
| 566 | } |
| 567 | |
| 568 | ant.delete(failonerror: false, dir: dirPath) |
| 569 | |
| 570 | attempt++ |
| 571 | } |
| 572 | |
| 573 | if (new File(dirPath).exists()) { |
| 574 | ant.project.log ("Cannot delete directory: $dirPath" ) |
| 575 | System.exit (1) |
| 576 | } |
| 577 | }) |
| 578 | |
| 579 | binding.setVariable("patchPropertiesFile", { String target, Map args = [:] -> |
| 580 | String file = "$target/bin/idea.properties" |
| 581 | |
| 582 | if (args.appendices != null) { |
| 583 | ant.concat(destfile: file, append: true) { |
| 584 | args.appendices.each { |
| 585 | fileset(file: it) |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase() |
| 591 | String settings_dir = args.system_selector.replaceFirst("\\d+", "") |
| 592 | ant.replace(file: file) { |
| 593 | replacefilter(token: "@@product_uc@@", value: product_uc) |
| 594 | replacefilter(token: "@@settings_dir@@", value: settings_dir) |
| 595 | } |
| 596 | |
| 597 | String message = (isEap() ? """ |
| 598 | #----------------------------------------------------------------------- |
| 599 | # Change to 'disabled' if you don't want to receive instant visual notifications |
| 600 | # about fatal errors that happen to an IDE or plugins installed. |
| 601 | #----------------------------------------------------------------------- |
| 602 | idea.fatal.error.notification=enabled |
| 603 | """ |
| 604 | : """ |
| 605 | #----------------------------------------------------------------------- |
| 606 | # Change to 'enabled' if you want to receive instant visual notifications |
| 607 | # about fatal errors that happen to an IDE or plugins installed. |
| 608 | #----------------------------------------------------------------------- |
| 609 | idea.fatal.error.notification=disabled |
| 610 | """) |
| 611 | ant.echo(file: file, append: true, message: message) |
| 612 | }) |
| 613 | |
| 614 | binding.setVariable("zipSources", { String home, String targetDir -> |
| 615 | String sources = "$targetDir/sources.zip" |
| 616 | projectBuilder.stage("zip sources to $sources") |
| 617 | |
| 618 | ant.mkdir(dir: targetDir) |
| 619 | ant.delete(file: sources) |
| 620 | ant.zip(destfile: sources) { |
| 621 | fileset(dir: home) { |
| 622 | ["java", "groovy", "ipr", "iml", "form", "xml", "properties"].each { |
| 623 | include(name: "**/*.$it") |
| 624 | } |
| 625 | exclude(name: "**/testData/**") |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | notifyArtifactBuilt(sources) |
| 630 | }) |
| 631 | |
| 632 | /** |
| 633 | * E.g. |
| 634 | * |
| 635 | * Load all properties from file: |
| 636 | * readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties") |
| 637 | * |
| 638 | * Load all properties except "idea.cycle.buffer.size", change "idea.max.intellisense.filesize" to 3000 |
| 639 | * and enable "idea.is.internal" mode: |
| 640 | * readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties", |
| 641 | * "idea.properties" : ["idea.max.intellisense.filesize" : 3000, |
| 642 | * "idea.cycle.buffer.size" : null, |
| 643 | * "idea.is.internal" : true ]) |
| 644 | * @param args |
| 645 | * @return text xml properties description in xml |
| 646 | */ |
| 647 | private Map readIdeaProperties(Map args) { |
| 648 | String ideaPropertiesPath = args == null ? null : args.get("idea.properties.path") |
| 649 | if (ideaPropertiesPath == null) { |
| 650 | return [:] |
| 651 | } |
| 652 | |
| 653 | // read idea.properties file |
| 654 | Properties ideaProperties = new Properties(); |
| 655 | FileInputStream ideaPropertiesFile = new FileInputStream(ideaPropertiesPath); |
| 656 | ideaProperties.load(ideaPropertiesFile); |
| 657 | ideaPropertiesFile.close(); |
| 658 | |
| 659 | def defaultProperties = ["CVS_PASSFILE": "~/.cvspass", |
| 660 | "com.apple.mrj.application.live-resize": "false", |
| 661 | "idea.paths.selector": args.system_selector, |
| 662 | "java.endorsed.dirs": "", |
| 663 | "idea.smooth.progress": "false", |
| 664 | "apple.laf.useScreenMenuBar": "true", |
| 665 | "apple.awt.graphics.UseQuartz": "true", |
| 666 | "apple.awt.fullscreencapturealldisplays": "false"] |
| 667 | if (args.platform_prefix != null) { |
| 668 | defaultProperties.put("idea.platform.prefix", args.platform_prefix) |
| 669 | } |
| 670 | |
| 671 | Map properties = defaultProperties |
| 672 | def customProperties = args.get("idea.properties") |
| 673 | if (customProperties != null) { |
| 674 | properties += customProperties |
| 675 | } |
| 676 | |
| 677 | properties.each {k, v -> |
| 678 | if (v == null) { |
| 679 | // if overridden with null - ignore property |
| 680 | ideaProperties.remove(k) |
| 681 | } else { |
| 682 | // if property is overridden in args map - use new value |
| 683 | ideaProperties.put(k, v) |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | return ideaProperties; |
| 688 | } |
| 689 | |
| 690 | private String submapToXml(Map properties, List keys) { |
| 691 | // generate properties description for Info.plist |
| 692 | StringBuilder buff = new StringBuilder() |
| 693 | |
| 694 | keys.each { key -> |
| 695 | String value = properties[key] |
| 696 | if (value != null) { |
| 697 | String string = |
| 698 | """ |
| 699 | <key>$key</key> |
| 700 | <string>$value</string> |
| 701 | """ |
| 702 | buff.append(string) |
| 703 | } |
| 704 | } |
| 705 | return buff.toString() |
| 706 | } |
| 707 | |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 708 | binding.setVariable("buildWinZip", { String zipRoot, String zipPath, List paths -> |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 709 | projectBuilder.stage(".win.zip") |
| 710 | |
| 711 | fixIdeaPropertiesEol(paths, "dos") |
| 712 | |
| 713 | ant.zip(zipfile: zipPath) { |
| 714 | paths.each { |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 715 | zipfileset(dir: it, prefix: zipRoot) |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 716 | } |
| 717 | } |
| 718 | |
| 719 | notifyArtifactBuilt(zipPath) |
| 720 | }) |
| 721 | |
| 722 | binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, String macPath, List extraBins = [] -> |
| 723 | projectBuilder.stage(".mac.zip") |
| 724 | |
| 725 | allPaths = paths + [macPath] |
| 726 | ant.zip(zipfile: zipPath) { |
| 727 | allPaths.each { |
| 728 | zipfileset(dir: it, prefix: zipRoot) { |
| 729 | exclude(name: "bin/*.sh") |
Tor Norbye | 32218cc | 2013-10-08 09:48:09 -0700 | [diff] [blame] | 730 | exclude(name: "bin/*.py") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 731 | exclude(name: "bin/fsnotifier") |
Jean-Baptiste Queru | 9edc8f6 | 2013-02-08 15:14:04 -0800 | [diff] [blame] | 732 | exclude(name: "bin/restarter") |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 733 | exclude(name: "MacOS/*") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 734 | extraBins.each { |
| 735 | exclude(name: it) |
| 736 | } |
| 737 | exclude(name: "bin/idea.properties") |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | allPaths.each { |
| 742 | zipfileset(dir: it, filemode: "755", prefix: zipRoot) { |
| 743 | include(name: "bin/*.sh") |
Tor Norbye | 32218cc | 2013-10-08 09:48:09 -0700 | [diff] [blame] | 744 | include(name: "bin/*.py") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 745 | include(name: "bin/fsnotifier") |
Jean-Baptiste Queru | 9edc8f6 | 2013-02-08 15:14:04 -0800 | [diff] [blame] | 746 | include(name: "bin/restarter") |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 747 | include(name: "MacOS/*") |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 748 | extraBins.each { |
| 749 | include(name: it) |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | zipfileset(file: "$macPath/bin/idea.properties", prefix: "$zipRoot/bin") |
| 755 | } |
| 756 | }) |
| 757 | |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 758 | binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths, List extraBins = [] -> |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 759 | projectBuilder.stage(".tar.gz") |
| 760 | |
| 761 | fixIdeaPropertiesEol(paths, "unix") |
| 762 | |
| 763 | ant.tar(tarfile: tarPath, longfile: "gnu") { |
| 764 | paths.each { |
| 765 | tarfileset(dir: it, prefix: tarRoot) { |
| 766 | exclude(name: "bin/*.sh") |
| 767 | exclude(name: "bin/fsnotifier*") |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 768 | extraBins.each { |
| 769 | exclude(name: it) |
| 770 | } |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 771 | type(type: "file") |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | paths.each { |
| 776 | tarfileset(dir: it, filemode: "755", prefix: tarRoot) { |
| 777 | include(name: "bin/*.sh") |
| 778 | include(name: "bin/fsnotifier*") |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 779 | extraBins.each { |
| 780 | include(name: it) |
| 781 | } |
Jean-Baptiste Queru | b56ea2a | 2013-01-08 11:11:20 -0800 | [diff] [blame] | 782 | type(type: "file") |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | String gzPath = "${tarPath}.gz" |
| 788 | ant.gzip(src: tarPath, zipfile: gzPath) |
| 789 | ant.delete(file: tarPath) |
| 790 | notifyArtifactBuilt(gzPath) |
| 791 | }) |
| 792 | |
| 793 | private void fixIdeaPropertiesEol(List paths, String eol) { |
| 794 | paths.each { |
| 795 | String file = "$it/bin/idea.properties" |
| 796 | if (new File(file).exists()) { |
| 797 | ant.fixcrlf(file: file, eol: eol) |
| 798 | } |
| 799 | } |
| 800 | } |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 801 | |
Tor Norbye | c1ace1f | 2013-07-08 11:26:24 -0700 | [diff] [blame] | 802 | binding.setVariable("buildWinLauncher", { String ch, String inputPath, String outputPath, String appInfo, |
| 803 | String launcherProperties, String pathsSelector, List resourcePaths -> |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 804 | projectBuilder.stage("winLauncher") |
| 805 | |
Tor Norbye | d1a59a0 | 2013-04-03 16:27:26 -0700 | [diff] [blame] | 806 | if (pathsSelector != null) { |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 807 | def paths = getProperty("paths") |
| 808 | def launcherPropertiesTemp = "${paths.sandbox}/launcher.properties" |
| 809 | copyAndPatchFile(launcherProperties, launcherPropertiesTemp, ["PRODUCT_PATHS_SELECTOR": pathsSelector]) |
| 810 | launcherProperties = launcherPropertiesTemp |
Tor Norbye | d1a59a0 | 2013-04-03 16:27:26 -0700 | [diff] [blame] | 811 | } |
| 812 | |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 813 | ant.java(classname: "com.pme.launcher.LauncherGeneratorMain", fork: "true") { |
Tor Norbye | 814f829 | 2014-03-06 17:27:18 -0800 | [diff] [blame] | 814 | sysproperty(key: "java.awt.headless", value: "true") |
Jean-Baptiste Queru | 2bd2b7c | 2013-04-01 14:41:51 -0700 | [diff] [blame] | 815 | arg(value: inputPath) |
| 816 | arg(value: appInfo) |
| 817 | arg(value: "$ch/native/WinLauncher/WinLauncher/resource.h") |
| 818 | arg(value: launcherProperties) |
| 819 | arg(value: outputPath) |
| 820 | classpath { |
| 821 | pathelement(location: "$ch/build/lib/launcher-generator.jar") |
| 822 | fileset(dir: "$ch/lib") { |
| 823 | include(name: "guava*.jar") |
| 824 | include(name: "jdom.jar") |
| 825 | include(name: "sanselan*.jar") |
| 826 | } |
| 827 | resourcePaths.each { |
| 828 | pathelement(location: it) |
| 829 | } |
| 830 | } |
| 831 | } |
| 832 | }) |
Siva Velusamy | 7be1af1 | 2013-09-06 16:46:31 -0700 | [diff] [blame] | 833 | |
| 834 | binding.setVariable("layoutUpdater", { String target, String jarName = "updater.jar" -> |
| 835 | layout(target) { |
| 836 | jar(jarName) { |
| 837 | module("updater") |
| 838 | } |
| 839 | } |
| 840 | }) |
| 841 | |
Tor Norbye | f7998d0 | 2013-09-27 10:19:19 -0700 | [diff] [blame] | 842 | binding.setVariable("collectUsedJars", { List modules, List approvedJars, List forbiddenJars, List modulesToBuild -> |
Tor Norbye | beca983 | 2013-09-19 12:39:22 -0700 | [diff] [blame] | 843 | def usedJars = new HashSet(); |
| 844 | |
Tor Norbye | beca983 | 2013-09-19 12:39:22 -0700 | [diff] [blame] | 845 | modules.each { |
| 846 | def module = findModule(it) |
| 847 | if (module != null) { |
| 848 | projectBuilder.moduleRuntimeClasspath(module, false).each { |
| 849 | File file = new File(it) |
| 850 | if (file.exists()) { |
| 851 | String path = file.canonicalPath.replace('\\', '/') |
| 852 | if (path.endsWith(".jar") && approvedJars.any { path.startsWith(it) } && !forbiddenJars.any { path.contains(it) }) { |
| 853 | if (usedJars.add(path)) { |
| 854 | projectBuilder.info("\tADDED: $path for ${module.getName()}") |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
Tor Norbye | f7998d0 | 2013-09-27 10:19:19 -0700 | [diff] [blame] | 859 | if (modulesToBuild != null) { |
| 860 | modulesToBuild << module |
| 861 | } |
Tor Norbye | beca983 | 2013-09-19 12:39:22 -0700 | [diff] [blame] | 862 | } |
| 863 | else { |
| 864 | projectBuilder.warning("$it is not a module") |
| 865 | } |
| 866 | } |
Tor Norbye | f7998d0 | 2013-09-27 10:19:19 -0700 | [diff] [blame] | 867 | |
| 868 | return usedJars |
| 869 | }) |
| 870 | |
| 871 | binding.setVariable("buildModulesAndCollectUsedJars", { List modules, List approvedJars, List forbiddenJars -> |
| 872 | def modulesToBuild = [] |
| 873 | def usedJars = collectUsedJars(modules, approvedJars, forbiddenJars, modulesToBuild) |
| 874 | projectBuilder.cleanOutput() |
Tor Norbye | beca983 | 2013-09-19 12:39:22 -0700 | [diff] [blame] | 875 | projectBuilder.buildModules(modulesToBuild) |
| 876 | |
| 877 | return usedJars |
| 878 | }) |
| 879 | |
| 880 | binding.setVariable("buildSearchableOptions", { String target, List licenses, Closure cp, String jvmArgs = null, |
| 881 | def paths = getProperty("paths") -> |
| 882 | projectBuilder.stage("Building searchable options") |
| 883 | |
| 884 | String targetFile = "${target}/searchableOptions.xml" |
| 885 | ant.delete(file: targetFile) |
| 886 | |
| 887 | licenses.each { |
| 888 | ant.copy(file: it, todir: paths.ideaSystem) |
| 889 | } |
| 890 | |
| 891 | ant.path(id: "searchable.options.classpath") { cp() } |
| 892 | String classpathFile = "${paths.sandbox}/classpath.txt" |
| 893 | ant.echo(file: classpathFile, append: false, message: "\${toString:searchable.options.classpath}") |
| 894 | ant.replace(file: classpathFile, token: File.pathSeparator, value: "\n") |
| 895 | |
| 896 | ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) { |
| 897 | jvmarg(line: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))} -ea -Xmx500m -XX:MaxPermSize=200m") |
| 898 | jvmarg(line: "-Didea.home.path=$home -Didea.system.path=${paths.ideaSystem} -Didea.config.path=${paths.ideaConfig}") |
| 899 | if (jvmArgs != null) { |
| 900 | jvmarg(line: jvmArgs) |
| 901 | } |
| 902 | |
| 903 | arg(line: "${classpathFile} com.intellij.idea.Main traverseUI ${target}/searchableOptions.xml") |
| 904 | |
| 905 | classpath() { |
| 906 | pathelement(location: "${projectBuilder.moduleOutput(findModule("java-runtime"))}") |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | ant.available(file: targetFile, property: "searchable.options.exists"); |
| 911 | ant.fail(unless: "searchable.options.exists", message: "Searchable options were not built.") |
| 912 | }) |
Tor Norbye | 9258464 | 2014-04-17 08:39:25 -0700 | [diff] [blame] | 913 | |
| 914 | binding.setVariable("reassignAltClickToMultipleCarets", {String communityHome -> |
| 915 | String defaultKeymapContent = new File("$communityHome/platform/platform-resources/src/idea/Keymap_Default.xml").text |
| 916 | defaultKeymapContent = defaultKeymapContent.replace("<mouse-shortcut keystroke=\"alt button1\"/>", "") |
| 917 | defaultKeymapContent = defaultKeymapContent.replace("<mouse-shortcut keystroke=\"alt shift button1\"/>", |
| 918 | "<mouse-shortcut keystroke=\"alt button1\"/>") |
| 919 | patchedKeymapFile = new File("${paths.sandbox}/classes/production/platform-resources/idea/Keymap_Default.xml") |
| 920 | patchedKeymapFile.write(defaultKeymapContent) |
Siva Velusamy | a3091f6 | 2014-04-30 07:15:29 -0700 | [diff] [blame] | 921 | }) |
Tor Norbye | 65f60eb | 2014-07-16 18:07:37 -0700 | [diff] [blame] | 922 | |
| 923 | // modules used in Upsource and in Kotlin as an API to IDEA |
| 924 | binding.setVariable("analysisApiModules", [ |
| 925 | "analysis-api", |
| 926 | "boot", |
| 927 | "core-api", |
| 928 | "duplicates-analysis", |
| 929 | "editor-ui-api", |
| 930 | "editor-ui-ex", |
| 931 | "extensions", |
| 932 | "indexing-api", |
| 933 | "java-analysis-api", |
| 934 | "java-indexing-api", |
| 935 | "java-psi-api", |
| 936 | "java-structure-view", |
| 937 | "jps-model-api", |
| 938 | "jps-model-serialization", |
| 939 | "projectModel-api", |
| 940 | "structure-view-api", |
| 941 | "util", |
| 942 | "util-rt", |
| 943 | "xml-analysis-api", |
| 944 | "xml-psi-api", |
| 945 | "xml-structure-view-api", |
| 946 | ]) |
Tor Norbye | 02cf98d6 | 2014-08-19 12:53:10 -0700 | [diff] [blame] | 947 | binding.setVariable("analysisImplModules", [ |
| 948 | "analysis-impl", |
| 949 | "core-impl", |
| 950 | "indexing-impl", |
| 951 | "java-analysis-impl", |
| 952 | "java-indexing-impl", |
| 953 | "java-psi-impl", |
| 954 | "projectModel-impl", |
| 955 | "structure-view-impl", |
| 956 | "xml-analysis-impl", |
| 957 | "xml-psi-impl", |
| 958 | "xml-structure-view-impl", |
| 959 | ]) |