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