blob: 7a5798bdd4c4d1a68e4e6cb758d11e7ffdefecc8 [file] [log] [blame]
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -08001/*
2 * Copyright 2000-2013 JetBrains s.r.o.
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
17import org.jetbrains.jps.Jps
18import org.jetbrains.jps.Module
19import org.jetbrains.jps.idea.IdeaProjectLoader
20
21includeTool << Jps
22
23binding.setVariable("p", {String key ->
24 return getProperty(key) as String
25})
26
27binding.setVariable("guessJdk", {
28 String javaHome = p("java.home")
29
30 if (new File(javaHome).getName() == "jre") {
31 javaHome = new File(javaHome).getParent()
32 }
33
34 return javaHome
35})
36
37binding.setVariable("includeFile", {String filePath ->
38 Script s = groovyShell.parse(new File(filePath))
39 s.setBinding(binding)
40 s
41})
42
43binding.setVariable("isMac", {
44 return System.getProperty("os.name").toLowerCase().startsWith("mac")
45})
46
47binding.setVariable("isWin", {
48 return System.getProperty("os.name").toLowerCase().startsWith("windows")
49})
50
51binding.setVariable("isEap", {
52 return "true" == p("component.version.eap")
53})
54
Tor Norbye934b9432013-05-07 20:09:46 -070055binding.setVariable("mem32", "-server -Xms128m -Xmx512m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50")
56binding.setVariable("mem64", "-Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50")
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -070057binding.setVariable("common_vmoptions", "-ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true")
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -080058
59binding.setVariable("vmOptions", { "$common_vmoptions ${isEap() ? '-XX:+HeapDumpOnOutOfMemoryError' : ''}".trim() })
60binding.setVariable("vmOptions32", { "$mem32 ${vmOptions()}".trim() })
61binding.setVariable("vmOptions64", { "$mem64 ${vmOptions()}".trim() })
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -070062
63binding.setVariable("yjpOptions", { String systemSelector, String platformSuffix = "" ->
64 "-agentlib:yjpagent$platformSuffix=disablej2ee,disablealloc,disabletracing,onlylocal,builtinprobes=none,disableexceptiontelemetry,sessionname=$systemSelector".trim()
65})
66
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -080067binding.setVariable("vmOptions32yjp", { String systemSelector ->
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -070068 "${vmOptions32()} ${yjpOptions(systemSelector)}".trim()
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -080069})
70binding.setVariable("vmOptions64yjp", { String systemSelector ->
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -070071 "${vmOptions64()} ${yjpOptions(systemSelector, "64")}".trim()
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -080072})
73
74binding.setVariable("isDefined", {String key ->
75 try {
76 this[key]
77 return true
78 }
79 catch (MissingPropertyException ignored) {
80 return false
81 }
82})
83
84private String require(String key) {
85 try {
86 this[key]
87 }
88 catch (MissingPropertyException ignored) {
89 projectBuilder.error("Property $key is required")
90 }
91}
92
93private String require(String key, String defaultValue) {
94 try {
95 this[key]
96 }
97 catch (MissingPropertyException ignored) {
98 projectBuilder.info("$key is not defined. Defaulting to $defaultValue")
99 this[key] = defaultValue
100 }
101}
102
103binding.setVariable("requireProperty", {String key, String defaultValue = null ->
104 if (defaultValue == null) {
105 require(key)
106 }
107 else {
108 require(key, defaultValue)
109 }
110})
111
112binding.setVariable("guessHome", {
113 // Current file is supposed to be at build/scripts/release.gant path
114 new File(requireProperty("gant.file").substring("file:".length())).getParentFile().getParentFile().getParent()
115})
116
117binding.setVariable("loadProject", {
118 requireProperty("jdkHome", guessJdk())
119 def mac = isMac()
120 jdk("IDEA jdk", jdkHome) {
121 if (!mac) {
122 classpath "$jdkHome/lib/tools.jar"
123 }
124 }
125 IdeaProjectLoader.loadFromPath(project, "${home}")
126})
127
128boolean hasSourceRoots(Module module) {
129 return !module.sourceRoots.isEmpty()
130}
131
132binding.setVariable("findModule", {String name ->
133 project.modules[name]
134})
135
136binding.setVariable("allModules", {
137 return project.modules.values()
138})
139
140binding.setVariable("printUnusedModules", {Set<String> usedModules ->
141 allModules().each {Module m ->
142 if (!usedModules.contains(m.name) && hasSourceRoots(m)) {
143 projectBuilder.warning("Module $m.name is not used in project layout")
144 }
145 }
146})
147
148requireProperty("home", guessHome())
149
150String readSnapshotBuild() {
151 def file = new File("$home/community/build.txt")
152 if (!file.exists()) {
153 file = new File("$home/build.txt")
154 }
155
156 return file.readLines().get(0)
157}
158
159binding.setVariable("snapshot", readSnapshotBuild())
160
161projectBuilder.buildInfoPrinter = new org.jetbrains.jps.teamcity.TeamcityBuildInfoPrinter()
162projectBuilder.compressJars = false
163
164binding.setVariable("notifyArtifactBuilt", { String artifactPath ->
165 if (!artifactPath.startsWith(home)) {
166 projectBuilder.error("Artifact path $artifactPath should start with $home")
167 }
168 def relativePath = artifactPath.substring(home.length())
169 if (relativePath.startsWith("/")) {
170 relativePath = relativePath.substring(1)
171 }
172 def file = new File(artifactPath)
173 if (file.isDirectory()) {
174 relativePath += "=>" + file.name
175 }
176 projectBuilder.info("##teamcity[publishArtifacts '$relativePath']")
177})
178
179def suspendUntilDebuggerConnect = System.getProperty("debug.suspend") ?: "n"
180def debugPort = System.getProperty("debug.port") ?: 5555
181if (suspendUntilDebuggerConnect == 'y') {
182 println """\
183------------->----------- This process is suspended until remote debugger connects to the port $debugPort ----<----
Tor Norbye8fb00212013-05-01 12:55:43 -0700184-------------------------------------------^------^------^------^------^------^------^-----------------------
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800185"""
186}
187
188binding.setVariable("patchFiles", { List files, Map args, String marker = "__" ->
189 files.each { file ->
190 args.each { arg ->
191 ant.replace(file: file, token: "${marker}${arg.key}${marker}", value: arg.value)
192 }
193 }
194})
195
196binding.setVariable("copyAndPatchFile", { String file, String target, Map args, String marker = "__" ->
197 ant.copy(file: file, tofile: target, overwrite: "true") {
198 filterset(begintoken: marker, endtoken: marker) {
199 args.each {
200 filter(token: it.key, value: it.value)
201 }
202 }
203 }
204})
205
206binding.setVariable("copyAndPatchFiles", { Closure files, String target, Map args, String marker = "__" ->
207 ant.copy(todir: target, overwrite: "true") {
208 files()
209
210 filterset(begintoken: marker, endtoken: marker) {
211 args.each {
212 filter(token: it.key, value: it.value)
213 }
214 }
215 }
216})
217
218binding.setVariable("wireBuildDate", { String buildNumber, String appInfoFile ->
219 ant.tstamp()
220 patchFiles([appInfoFile], ["BUILD_NUMBER": buildNumber, "BUILD_DATE": DSTAMP])
221})
222
223binding.setVariable("commonJvmArgs", {
224 return [
225 "-ea",
226 "-Didea.home.path=$home",
227 "-Xbootclasspath/p:${projectBuilder.moduleOutput(findModule("boot"))}",
228 "-XX:+HeapDumpOnOutOfMemoryError",
229 "-Didea.system.path=${p("teamcity.build.tempDir")}/system",
230 "-Didea.config.path=${p("teamcity.build.tempDir")}/config",
231 "-Xdebug",
232 "-Xrunjdwp:transport=dt_socket,server=y,suspend=$suspendUntilDebuggerConnect,address=$debugPort"]
233})
234
235binding.setVariable("classPathLibs", [
236 "bootstrap.jar",
237 "extensions.jar",
238 "util.jar",
239 "jdom.jar",
240 "log4j.jar",
241 "trove4j.jar",
242 "jna.jar"
243])
244
245binding.setVariable("platformApiModules", [
Tor Norbyeec3fb1e2013-05-31 07:45:51 -0700246 "analysis-api",
247 "core-api",
248 "external-system-api",
249 "indexing-api",
250 "jps-model-api",
251 "lang-api",
252 "lvcs-api",
253 "projectModel-api",
254 "platform-api",
255 "usageView",
256 "vcs-api",
257 "xdebugger-api",
258 "xml-openapi",
259 "xml-psi-api",
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800260])
261
262
263binding.setVariable("platformImplementationModules", [
Tor Norbyeec3fb1e2013-05-31 07:45:51 -0700264 "analysis-impl",
265 "core-impl",
266 "dvcs",
267 "images",
268 "indexing-impl",
269 "jps-model-impl",
270 "jps-model-serialization",
271 "lang-impl",
272 "lvcs-impl",
273 "projectModel-impl",
274 "platform-impl",
275 "vcs-impl",
276 "testRunner",
277 "smRunner",
278 "relaxng",
279 "RegExpSupport",
280 "spellchecker",
281 "xdebugger-impl",
282 "xml",
283 "xml-psi-impl",
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800284])
285
286binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
287 ant.copy(todir: "$path/bin") {
288 fileset(dir: "$ch/bin/mac")
289 }
290
291 ant.copy(todir: path) {
292 fileset(dir: "$ch/build/conf/mac")
293 }
294
295 ant.tstamp() {
296 format(property: "todayYear", pattern: "yyyy")
297 }
298
299 String executable = args.executable != null ? args.executable : p("component.names.product").toLowerCase()
300 String helpId = args.help_id != null ? args.help_id : "IJ"
301 String icns = "idea.icns"
302 String helpIcns = "$path/Contents/Resources/${helpId}.help/Contents/Resources/Shared/product.icns"
303 if (args.icns != null) {
304 ant.delete(file: "$path/Contents/Resources/idea.icns")
305 ant.copy(file: args.icns, todir: "$path/Contents/Resources")
306 ant.copy(file: args.icns, tofile: helpIcns)
307 icns = new File((String)args.icns).getName();
308 } else {
309 ant.copy(file: "$path/Contents/Resources/idea.icns", tofile: helpIcns)
310 }
311
312 String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
313
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700314 String vmOptions = "-Dfile.encoding=UTF-8 ${vmOptions()} -Xverify:none"
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800315 if (isEap() && !args.mac_no_yjp) {
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700316 vmOptions += " ${yjpOptions(args.system_selector)}"
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800317 }
318
319 String minor = p("component.version.minor")
320 String version = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "EAP $args.buildNumber" : "${p("component.version.major")}.${minor}"
321
322 Map properties = readIdeaProperties(args)
323
324 def coreKeys = ["idea.platform.prefix", "idea.paths.selector"]
325
326 String coreProperties = submapToXml(properties, coreKeys);
327
328 StringBuilder effectiveProperties = new StringBuilder()
329 properties.each { k, v ->
330 if (!coreKeys.contains(k)) {
331 effectiveProperties.append("$k=$v\n");
332 }
333 }
334
335 new File("$path/bin/idea.properties").text = effectiveProperties.toString()
336 new File("$path/bin/idea.vmoptions").text = "$mem64 -XX:+UseCompressedOops".split(" ").join("\n")
337
338 String classPath = classPathLibs.collect {"\$APP_PACKAGE/lib/${it}" }.join(":")
339
Jean-Baptiste Queru1d526b12013-02-27 09:41:48 -0800340 String urlSchemes = ""
341 if (args.urlSchemes != null) {
342 urlSchemes += """
343 <key>CFBundleURLTypes</key>
344 <array>
345 <dict>
346 <key>CFBundleTypeRole</key>
347 <string>Editor</string>
348 <key>CFBundleURLName</key>
349 <string>Stacktrace</string>
350 <key>CFBundleURLSchemes</key>
351 <array>
352"""
353 args.urlSchemes.each { scheme ->
354 urlSchemes += " <string>${scheme}</string>"
355 }
356 urlSchemes += """
357 </array>
358 </dict>
359 </array>
360"""
361 }
362
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800363 ant.replace(file: "$path/Contents/Info.plist") {
364 replacefilter(token: "@@build@@", value: args.buildNumber)
365 replacefilter(token: "@@doc_types@@", value: ifNull(args.doc_types, ""))
366 replacefilter(token: "@@executable@@", value: executable)
367 replacefilter(token: "@@icns@@", value: icns)
368 replacefilter(token: "@@bundle_name@@", value: fullName)
369 replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier)
370 replacefilter(token: "@@year@@", value: "$todayYear")
371 replacefilter(token: "@@version@@", value: version)
372 replacefilter(token: "@@vmoptions@@", value: vmOptions)
373 replacefilter(token: "@@idea_properties@@", value: coreProperties)
374 replacefilter(token: "@@class_path@@", value: classPath)
375 replacefilter(token: "@@help_id@@", value: helpId)
Jean-Baptiste Queru1d526b12013-02-27 09:41:48 -0800376 replacefilter(token: "@@url_schemes@@", value: urlSchemes)
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800377 }
378
379 if (executable != "idea") {
380 ant.move(file: "$path/Contents/MacOS/idea", tofile: "$path/Contents/MacOS/$executable")
381 }
382
383 ant.replace(file: "$path/bin/inspect.sh") {
384 replacefilter(token: "@@product_full@@", value: fullName)
385 replacefilter(token: "@@script_name@@", value: executable)
386 }
387 if (args.inspect_script != null && args.inspect_script != "inspect") {
388 ant.move(file: "$path/bin/inspect.sh", tofile: "$path/bin/${args.inspect_script}.sh")
389 }
390})
391
392binding.setVariable("winScripts", { String target, String home, String name, Map args ->
393 String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
394 String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
395 String vm_options = args.vm_options != null ? args.vm_options : "${p("component.names.product").toLowerCase()}.exe"
396 if (vm_options.endsWith(".exe")) {
397 vm_options = vm_options.replace(".exe", "%BITS%.exe")
398 }
399 else {
400 vm_options = vm_options + "%BITS%"
401 }
402
403 String classPath = "SET CLASS_PATH=%IDE_HOME%\\lib\\${classPathLibs[0]}\n"
404 classPath += classPathLibs[1..-1].collect {"SET CLASS_PATH=%CLASS_PATH%;%IDE_HOME%\\lib\\${it}"}.join("\n")
405 if (args.tools_jar) classPath += "\nSET CLASS_PATH=%CLASS_PATH%;%JDK%\\lib\\tools.jar"
406
407 ant.copy(todir: "$target/bin") {
408 fileset(dir: "$home/bin/scripts/win")
409
410 filterset(begintoken: "@@", endtoken: "@@") {
411 filter(token: "product_full", value: fullName)
412 filter(token: "product_uc", value: product_uc)
413 filter(token: "vm_options", value: vm_options)
414 filter(token: "isEap", value: isEap())
415 filter(token: "system_selector", value: args.system_selector)
416 filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
417 filter(token: "class_path", value: classPath)
418 filter(token: "script_name", value: name)
419 }
420 }
421
422 if (name != "idea.bat") {
423 ant.move(file: "$target/bin/idea.bat", tofile: "$target/bin/$name")
424 }
425 if (args.inspect_script != null && args.inspect_script != "inspect") {
426 ant.move(file: "$target/bin/inspect.bat", tofile: "$target/bin/${args.inspect_script}.bat")
427 }
428
429 ant.fixcrlf(srcdir: "$target/bin", includes: "*.bat", eol: "dos")
430})
431
432private ifNull(v, defVal) { v != null ? v : defVal }
433
434binding.setVariable("unixScripts", { String target, String home, String name, Map args ->
435 String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
436 String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
437 String vm_options = args.vm_options != null ? args.vm_options : p("component.names.product").toLowerCase()
438
439 String classPath = "CLASSPATH=\"\$IDE_HOME/lib/${classPathLibs[0]}\"\n"
440 classPath += classPathLibs[1..-1].collect {"CLASSPATH=\"\$CLASSPATH:\$IDE_HOME/lib/${it}\""}.join("\n")
441 if (args.tools_jar) classPath += "\nCLASSPATH=\"\$CLASSPATH:\$JDK/lib/tools.jar\""
442
443 ant.copy(todir: "$target/bin") {
444 fileset(dir: "$home/bin/scripts/unix")
445
446 filterset(begintoken: "@@", endtoken: "@@") {
447 filter(token: "product_full", value: fullName)
448 filter(token: "product_uc", value: product_uc)
449 filter(token: "vm_options", value: vm_options)
450 filter(token: "isEap", value: isEap())
451 filter(token: "system_selector", value: args.system_selector)
452 filter(token: "ide_jvm_args", value: ifNull(args.ide_jvm_args, ""))
453 filter(token: "class_path", value: classPath)
454 filter(token: "script_name", value: name)
455 }
456 }
457
458 if (name != "idea.sh") {
459 ant.move(file: "$target/bin/idea.sh", tofile: "$target/bin/$name")
460 }
461 if (args.inspect_script != null && args.inspect_script != "inspect") {
462 ant.move(file: "$target/bin/inspect.sh", tofile: "$target/bin/${args.inspect_script}.sh")
463 }
464
465 ant.fixcrlf(srcdir: "$target/bin", includes: "*.sh", eol: "unix")
466})
467
468binding.setVariable("winVMOptions", { String target, String system_selector, String name, String name64 = null ->
469 def options = isEap() && system_selector != null ? vmOptions32yjp(system_selector) : vmOptions32()
470 ant.echo(file: "$target/bin/${name}.vmoptions", message: options.replace(' ', '\n'))
471
472 if (name64 != null) {
473 options = isEap() && system_selector != null ? vmOptions64yjp(system_selector) : vmOptions64()
474 ant.echo(file: "$target/bin/${name64}.vmoptions", message: options.replace(' ', '\n'))
475 }
476
477 ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "dos")
478})
479
480binding.setVariable("unixVMOptions", { String target, String name ->
481 ant.echo(file: "$target/bin/${name}.vmoptions", message: vmOptions32().replace(' ', '\n'))
482 ant.echo(file: "$target/bin/${name}64.vmoptions", message: vmOptions64().replace(' ', '\n'))
483 ant.fixcrlf(srcdir: "$target/bin", includes: "*.vmoptions", eol: "unix")
484})
485
486binding.setVariable("unixReadme", { String target, String home, Map args ->
487 String fullName = args.fullName != null ? args.fullName : p("component.names.fullname")
488 String settings_dir = args.system_selector.replaceFirst("\\d+", "")
489 copyAndPatchFile("$home/build/Install-Linux-tar.txt", "$target/Install-Linux-tar.txt",
490 ["product_full": fullName,
491 "product": p("component.names.product").toLowerCase(),
492 "system_selector": args.system_selector,
493 "settings_dir": settings_dir], "@@")
494 ant.fixcrlf(file: "$target/bin/Install-Linux-tar.txt", eol: "unix")
495})
496
497binding.setVariable("forceDelete", { String dirPath ->
498 // if wasn't deleted - retry several times
499 attempt = 1
500 while (attempt < 21 && (new File(dirPath).exists())) {
501 if (attempt > 1) {
502 ant.echo "Deleting $dirPath ... (attempt=$attempt)"
503
504 // let's wait a bit and try again - may be help
505 // in some cases on our windows 7 agents
506 sleep(2000)
507 }
508
509 ant.delete(failonerror: false, dir: dirPath)
510
511 attempt++
512 }
513
514 if (new File(dirPath).exists()) {
515 ant.project.log ("Cannot delete directory: $dirPath" )
516 System.exit (1)
517 }
518})
519
520binding.setVariable("patchPropertiesFile", { String target, Map args = [:] ->
521 String file = "$target/bin/idea.properties"
522
523 if (args.appendices != null) {
524 ant.concat(destfile: file, append: true) {
525 args.appendices.each {
526 fileset(file: it)
527 }
528 }
529 }
530
531 String product_uc = args.product_uc != null ? args.product_uc : p("component.names.product").toUpperCase()
532 String settings_dir = args.system_selector.replaceFirst("\\d+", "")
533 ant.replace(file: file) {
534 replacefilter(token: "@@product_uc@@", value: product_uc)
535 replacefilter(token: "@@settings_dir@@", value: settings_dir)
536 }
537
538 String message = (isEap() ? """
539#-----------------------------------------------------------------------
540# Change to 'disabled' if you don't want to receive instant visual notifications
541# about fatal errors that happen to an IDE or plugins installed.
542#-----------------------------------------------------------------------
543idea.fatal.error.notification=enabled
544"""
545 : """
546#-----------------------------------------------------------------------
547# Change to 'enabled' if you want to receive instant visual notifications
548# about fatal errors that happen to an IDE or plugins installed.
549#-----------------------------------------------------------------------
550idea.fatal.error.notification=disabled
551""")
552 ant.echo(file: file, append: true, message: message)
553})
554
555binding.setVariable("zipSources", { String home, String targetDir ->
556 String sources = "$targetDir/sources.zip"
557 projectBuilder.stage("zip sources to $sources")
558
559 ant.mkdir(dir: targetDir)
560 ant.delete(file: sources)
561 ant.zip(destfile: sources) {
562 fileset(dir: home) {
563 ["java", "groovy", "ipr", "iml", "form", "xml", "properties"].each {
564 include(name: "**/*.$it")
565 }
566 exclude(name: "**/testData/**")
567 }
568 }
569
570 notifyArtifactBuilt(sources)
571})
572
573/**
574 * E.g.
575 *
576 * Load all properties from file:
577 * readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties")
578 *
579 * Load all properties except "idea.cycle.buffer.size", change "idea.max.intellisense.filesize" to 3000
580 * and enable "idea.is.internal" mode:
581 * readIdeaProperties("idea.properties.path" : "$home/ruby/build/idea.properties",
582 * "idea.properties" : ["idea.max.intellisense.filesize" : 3000,
583 * "idea.cycle.buffer.size" : null,
584 * "idea.is.internal" : true ])
585 * @param args
586 * @return text xml properties description in xml
587 */
588private Map readIdeaProperties(Map args) {
589 String ideaPropertiesPath = args == null ? null : args.get("idea.properties.path")
590 if (ideaPropertiesPath == null) {
591 return [:]
592 }
593
594 // read idea.properties file
595 Properties ideaProperties = new Properties();
596 FileInputStream ideaPropertiesFile = new FileInputStream(ideaPropertiesPath);
597 ideaProperties.load(ideaPropertiesFile);
598 ideaPropertiesFile.close();
599
600 def defaultProperties = ["CVS_PASSFILE": "~/.cvspass",
601 "com.apple.mrj.application.live-resize": "false",
602 "idea.paths.selector": args.system_selector,
603 "java.endorsed.dirs": "",
604 "idea.smooth.progress": "false",
605 "apple.laf.useScreenMenuBar": "true",
606 "apple.awt.graphics.UseQuartz": "true",
607 "apple.awt.fullscreencapturealldisplays": "false"]
608 if (args.platform_prefix != null) {
609 defaultProperties.put("idea.platform.prefix", args.platform_prefix)
610 }
611
612 Map properties = defaultProperties
613 def customProperties = args.get("idea.properties")
614 if (customProperties != null) {
615 properties += customProperties
616 }
617
618 properties.each {k, v ->
619 if (v == null) {
620 // if overridden with null - ignore property
621 ideaProperties.remove(k)
622 } else {
623 // if property is overridden in args map - use new value
624 ideaProperties.put(k, v)
625 }
626 }
627
628 return ideaProperties;
629}
630
631private String submapToXml(Map properties, List keys) {
632// generate properties description for Info.plist
633 StringBuilder buff = new StringBuilder()
634
635 keys.each { key ->
636 String value = properties[key]
637 if (value != null) {
638 String string =
639 """
640 <key>$key</key>
641 <string>$value</string>
642"""
643 buff.append(string)
644 }
645 }
646 return buff.toString()
647}
648
649binding.setVariable("buildWinZip", { String zipPath, List paths ->
650 projectBuilder.stage(".win.zip")
651
652 fixIdeaPropertiesEol(paths, "dos")
653
654 ant.zip(zipfile: zipPath) {
655 paths.each {
656 fileset(dir: it)
657 }
658 }
659
660 notifyArtifactBuilt(zipPath)
661})
662
663binding.setVariable("buildMacZip", { String zipRoot, String zipPath, List paths, String macPath, List extraBins = [] ->
664 projectBuilder.stage(".mac.zip")
665
666 allPaths = paths + [macPath]
667 ant.zip(zipfile: zipPath) {
668 allPaths.each {
669 zipfileset(dir: it, prefix: zipRoot) {
670 exclude(name: "bin/*.sh")
671 exclude(name: "bin/fsnotifier")
Jean-Baptiste Queru9edc8f62013-02-08 15:14:04 -0800672 exclude(name: "bin/restarter")
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800673 exclude(name: "Contents/MacOS/*")
674 extraBins.each {
675 exclude(name: it)
676 }
677 exclude(name: "bin/idea.properties")
678 }
679 }
680
681 allPaths.each {
682 zipfileset(dir: it, filemode: "755", prefix: zipRoot) {
683 include(name: "bin/*.sh")
684 include(name: "bin/fsnotifier")
Jean-Baptiste Queru9edc8f62013-02-08 15:14:04 -0800685 include(name: "bin/restarter")
Jean-Baptiste Querub56ea2a2013-01-08 11:11:20 -0800686 include(name: "Contents/MacOS/*")
687 extraBins.each {
688 include(name: it)
689 }
690 }
691 }
692
693 zipfileset(file: "$macPath/bin/idea.properties", prefix: "$zipRoot/bin")
694 }
695})
696
697binding.setVariable("buildTarGz", { String tarRoot, String tarPath, List paths ->
698 projectBuilder.stage(".tar.gz")
699
700 fixIdeaPropertiesEol(paths, "unix")
701
702 ant.tar(tarfile: tarPath, longfile: "gnu") {
703 paths.each {
704 tarfileset(dir: it, prefix: tarRoot) {
705 exclude(name: "bin/*.sh")
706 exclude(name: "bin/fsnotifier*")
707 type(type: "file")
708 }
709 }
710
711 paths.each {
712 tarfileset(dir: it, filemode: "755", prefix: tarRoot) {
713 include(name: "bin/*.sh")
714 include(name: "bin/fsnotifier*")
715 type(type: "file")
716 }
717 }
718 }
719
720 String gzPath = "${tarPath}.gz"
721 ant.gzip(src: tarPath, zipfile: gzPath)
722 ant.delete(file: tarPath)
723 notifyArtifactBuilt(gzPath)
724})
725
726private void fixIdeaPropertiesEol(List paths, String eol) {
727 paths.each {
728 String file = "$it/bin/idea.properties"
729 if (new File(file).exists()) {
730 ant.fixcrlf(file: file, eol: eol)
731 }
732 }
733}
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700734
Tor Norbyed1a59a02013-04-03 16:27:26 -0700735binding.setVariable("buildWinLauncher", { String ch, String inputPath, String outputPath, String appInfo, String launcherProperties, String pathsSelector, List resourcePaths ->
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700736 projectBuilder.stage("winLauncher")
737
Tor Norbyed1a59a02013-04-03 16:27:26 -0700738 File launcherPropertiesTempFile = null;
739 if (pathsSelector != null) {
740 String propertiesContent = new File(launcherProperties).text
741 if (propertiesContent.contains("__PRODUCT_PATHS_SELECTOR__")) {
742 propertiesContent = propertiesContent.replace("__PRODUCT_PATHS_SELECTOR__", pathsSelector)
743 launcherPropertiesTempFile = File.createTempFile("launcher", ".properties")
744 launcherPropertiesTempFile.write(propertiesContent)
745 launcherProperties = launcherPropertiesTempFile.getAbsolutePath()
746 }
747 }
748
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700749 ant.java(classname: "com.pme.launcher.LauncherGeneratorMain", fork: "true") {
750 arg(value: inputPath)
751 arg(value: appInfo)
752 arg(value: "$ch/native/WinLauncher/WinLauncher/resource.h")
753 arg(value: launcherProperties)
754 arg(value: outputPath)
755 classpath {
756 pathelement(location: "$ch/build/lib/launcher-generator.jar")
757 fileset(dir: "$ch/lib") {
758 include(name: "guava*.jar")
759 include(name: "jdom.jar")
760 include(name: "sanselan*.jar")
761 }
762 resourcePaths.each {
763 pathelement(location: it)
764 }
765 }
766 }
Tor Norbyed1a59a02013-04-03 16:27:26 -0700767
768 if (launcherPropertiesTempFile != null) {
769 launcherPropertiesTempFile.delete()
770 }
Jean-Baptiste Queru2bd2b7c2013-04-01 14:41:51 -0700771})