PsiChangeTracker tests
[fedora-idea.git] / build / scripts / dist.gant
blob5f28d29af106670bcb47d7a067d5db08f0968bdc
1 import org.jetbrains.jps.Jps
2 import static org.jetbrains.jps.idea.IdeaProjectLoader.*
4 includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
5 includeTool << Jps
7 requireProperty("out", "$home/out")
9 class Paths {
10   final sandbox
11   final distWin
12   final distAll
13   final distUnix
14   final distMac
15   final artifacts
17   def Paths(String out) {
18     sandbox = out
19     distWin = "$sandbox/dist.win.ce"
20     distAll = "$sandbox/dist.all.ce"
21     distUnix = "$sandbox/dist.unix.ce"
22     distMac = "$sandbox/dist.mac.ce"
24     artifacts = "$sandbox/artifacts"
25   }
28 setProperty("paths", new Paths(out))
30 def paths = new Paths(out)
32 def includeFile(String filepath) {
33   Script s = groovyShell.parse(new File(filepath))
34   s.setBinding(binding)
35   s
38 target(compile: "Compile project") {
39   loadProject()
41   project.stage("Cleaning up sandbox folder")
42   ant.delete(dir: paths.sandbox)
44   [paths.sandbox, paths.distWin, paths.distAll, paths.distUnix, paths.distMac, paths.artifacts].each {
45     ant.mkdir(dir: it)
46   }
48   ant.tstamp() {
49     format(property: "today.year", pattern: "yyyy")
50   }
52   project["javac"] = "$jdk/bin/javac"
53   project.targetFolder = "$out/classes"
54   project.clean()
55   project.makeProduction()
58 String appInfoFile() {
59   return "${this["community-resources"].output}/idea/IdeaApplicationInfo.xml"
62 def wire_build_date(String buildNumber) {
63   ant.replace(token: "__BUILD_NUMBER__", value: buildNumber, file: appInfoFile())
64   ant.replace(token: "__BUILD_DATE__", value: DSTAMP, file: appInfoFile())
67 target('default': 'The default target') {
68   depends(compile)
69   layoutAll(
70           buildNumber: "IC-SNAPSHOT",
71           version: "MaiaCE",
72           system_selector: "IntelliJIdeaCE90",
73           vmoptions: "-Xms32m -Xmx256m -XX:MaxPermSize=150m -ea",
74           home, out)
77 public def layoutAll(Map args, String home, String out) {
78   Paths paths = new Paths(out)
80   wire_build_date(args.buildNumber)
82   def layouts = includeFile("$home/build/scripts/layouts.gant")
83   layouts.layoutFull(home, paths.distAll)
85   ant.echo(message: args.buildNumber, file: "$paths.distAll/build.txt")
86   ant.copy(todir: "$paths.distAll/license", preservelastmodified: "true") {
87     fileset(dir: "$home/license")
88   }
90   layoutMac(args, home, paths)
91   layoutLinux(args, home, paths)
92   layoutWin(args, home, paths)
95 private def patchPropertiesFile(String where) {
96   ant.echo(file: "$where/bin/idea.properties", append: "true", message:
97            """
99 #-----------------------------------------------------------------------
100 # Change to 'disabled' if you need not to receive instant visual notifications about
101 # fatal errors that happen to IDEA or plugins installed.
102 #-----------------------------------------------------------------------
103 idea.fatal.error.notification=enabled
105   )
108 private def layoutWin(Map args, String home, Paths paths) {
109   layout("$paths.distWin") {
110     dir("bin") {
111       fileset(dir: "$home/bin") { include(name: "*.*") }
112       fileset(dir: "$home/bin/win") { include(name: "*.*") }
113     }
114   }
116   patchPropertiesFile(paths.distWin)
117   ant.echo(file: "$paths.distWin/bin/idea.exe.vmoptions", message: args.vmoptions.replace(' ', '\n'))
119   ant.zip(zipfile: "$paths.artifacts/idea${args.buildNumber}.win.zip") {
120     fileset(dir: paths.distAll)
121     fileset(dir: paths.distWin)
122   }
125 private def layoutMac(Map args, String home, Paths paths) {
126   project.stage("Cleaning up sandbox folder")
128   ant.copy(todir: "$paths.distMac/bin") {
129     fileset(dir: "$home/bin") { include(name: "*.*") }
130     fileset(dir: "$home/bin/nix")
131     fileset(dir: "$home/bin/mac")
132   }
134   patchPropertiesFile(paths.distMac)
136   ant.copy(todir: paths.distMac) {
137     fileset(dir: "$home/build/conf/mac")
138   }
140   ant.replace(file: "${paths.distMac}/Contents/Info.plist") {
141     replacefilter(token: "@@build@@", value: args.buildNumber)
144     replacefilter(token: "@@version@@", value: args.version)
145     replacefilter(token: "@@vmoptions@@", value: args.vmoptions)
146     replacefilter(token: "@@system_selector@@", value: args.system_selector)
147   }
149   def root = "$args.version-${args.buildNumber}.app"
150   ant.zip(zipfile: "$paths.artifacts/idea${args.buildNumber}.mac.zip") {
151     [paths.distAll, paths.distMac].each {
152       tarfileset(dir: it, prefix: root) {
153         exclude(name: "bin/*.sh")
154         exclude(name: "Contents/MacOS/idea")
155       }
156     }
158     tarfileset(dir: paths.distMac, filemode: "755", prefix: root) {
159       include(name: "bin/*.sh")
160       include(name: "Contents/MacOS/idea")
161     }
162   }
165 def layoutLinux(Map args, String home, Paths paths) {
166   project.stage("tar.gz")
167   layout(paths.distUnix) {
168     dir("bin") {
169       fileset(dir: "$home/bin") { include(name: "*.*") }
170       fileset(dir: "$home/bin/linux") { include(name: "*.*") }
171       fileset(dir: "$home/bin/nix") { include(name: "*.*") }
172     }
173   }
175   patchPropertiesFile(paths.distUnix)
177   ant.echo(file: "$paths.distUnix/bin/idea.vmoptions", message: args.vmoptions.replace(' ', '\n') )
178   ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "idea.vmoptions", eol: "unix")
179   ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "*.sh", eol: "unix")
182   def tarRoot = "idea-$args.buildNumber"
183   def tarPath = "$paths.artifacts/idea${args.buildNumber}.tar"
184   ant.tar(tarfile: tarPath) {
185     [paths.distAll, paths.distUnix].each {
186       tarfileset(dir: it, prefix: tarRoot) {
187         exclude(name: "bin/*.sh")
188       }
189     }
191     tarfileset(dir: paths.distUnix, filemode: "755", prefix: tarRoot) {
192       include(name: "bin/*.sh")
193     }
194   }
196   ant.gzip(src: tarPath, zipfile: "${tarPath}.gz")
197   ant.delete(file: tarPath)