absolute path in .gitignore
[fedora-idea.git] / build / scripts / dist.gant
bloba289242cf72f6459d33a17fb641e7d5e751a2f8f
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("buildNumber", requireProperty("build.number", "SNAPSHOT"))
8 requireProperty("out", "$home/out")
10 setProperty("version", "MaiaCE")
11 setProperty("vmoptions", "-Xms32m -Xmx256m -XX:MaxPermSize=150m -ea")
12 setProperty("system_selector", "IntelliJIdeaCE90")
14 class Paths {
15   final sandbox
16   final distWin
17   final distAll
18   final distUnix
19   final distMac
20   final artifacts
22   def Paths(String home, String out) {
23     sandbox = out
24     distWin = "$sandbox/dist.win"
25     distAll = "$sandbox/dist.all"
26     distUnix = "$sandbox/dist.unix"
27     distMac = "$sandbox/dist.mac"
29     artifacts = "$sandbox/artifacts"
30   }
33 setProperty("paths", new Paths(home, out))
35 def paths = new Paths(home, out)
37 def includeFile(String filename) {
38   Script s = groovyShell.parse(new File("$home/build/scripts/$filename"))
39   s.setBinding(binding)
40   s
43 target(compile: "Compile project") {
44   loadProject()
46   project.stage("Cleaning up sandbox folder")
47   ant.delete(dir: paths.sandbox)
49   [paths.sandbox, paths.distWin, paths.distAll, paths.distUnix, paths.distMac, paths.artifacts].each {
50     ant.mkdir(dir: it)
51   }
53   ant.tstamp() {
54     format(property: "today.year", pattern: "yyyy")
55   }
57   project["javac"] = "$jdk/bin/javac"
58   project.targetFolder = "$out/classes"
59   project.clean()
60   project.makeProduction()
63 String appInfoFile() {
64   return "${this["community-resources"].output}/idea/IdeaApplicationInfo.xml"
67 def wire_build_date() {
68   ant.replace(token: "__BUILD_NUMBER__", value: buildNumber, file: appInfoFile())
69   ant.replace(token: "__BUILD_DATE__", value: DSTAMP, file: appInfoFile())
72 target('default': 'The default target') {
73   depends(compile)
74   wire_build_date()
76   def layouts = includeFile("layouts.gant")
77   layouts.layoutFull(paths.distAll)
79   ant.echo(message: buildNumber, file: "$paths.distAll/build.txt")
80   ant.copy(todir: "$paths.distAll/license", preservelastmodified: "true") {
81     fileset(dir: "$home/license")
82   }
84   layoutMac()
85   layoutLinux()
86   layoutWin()
89 private def patchPropertiesFile(String where) {
90   ant.echo(file: "$where/bin/idea.properties", append: "true", message:
91            """
93 #-----------------------------------------------------------------------
94 # Change to 'disabled' if you need not to receive instant visual notifications about
95 # fatal errors that happen to IDEA or plugins installed.
96 #-----------------------------------------------------------------------
97 idea.fatal.error.notification=enabled
98 """
99   )
102 private def layoutWin() {
103   layout("$paths.distWin") {
104     dir("bin") {
105       fileset(dir: "$home/bin") { include(name: "*.*") }
106       fileset(dir: "$home/bin/win") { include(name: "*.*") }
107     }
108   }
110   patchPropertiesFile(paths.distWin)
111   ant.echo(file: "$paths.distWin/bin/idea.exe.vmoptions", message: vmoptions.replace(' ', '\n'))
113   ant.zip(zipfile: "$paths.artifacts/idea${buildNumber}.win.zip") {
114     fileset(dir: paths.distAll)
115     fileset(dir: paths.distWin)
116   }
119 private def layoutMac() {
120   project.stage("Cleaning up sandbox folder")
122   ant.copy(todir: "$paths.distMac/bin") {
123     fileset(dir: "$home/bin") { include(name: "*.*") }
124     fileset(dir: "$home/bin/nix")
125     fileset(dir: "$home/bin/mac")
126   }
128   patchPropertiesFile(paths.distMac)
130   ant.copy(todir: paths.distMac) {
131     fileset(dir: "$home/build/conf/mac")
132   }
134   ant.replace(file: "${paths.distMac}/Contents/Info.plist") {
135     replacefilter(token: "@@build@@", value: buildNumber)
138     replacefilter(token: "@@version@@", value: version)
139     replacefilter(token: "@@vmoptions@@", value: vmoptions)
140     replacefilter(token: "@@system_selector@@", value: system_selector)
141   }
143   def root = "$version-${buildNumber}.app"
144   ant.zip(zipfile: "$paths.artifacts/idea${buildNumber}.mac.zip") {
145     [paths.distAll, paths.distMac].each {
146       tarfileset(dir: it, prefix: root) {
147         exclude(name: "bin/*.sh")
148         exclude(name: "Contents/MacOS/idea")
149       }
150     }
152     tarfileset(dir: paths.distMac, filemode: "755", prefix: root) {
153       include(name: "bin/*.sh")
154       include(name: "Contents/MacOS/idea")
155     }
156   }
159 def layoutLinux() {
160   project.stage("tar.gz")
161   layout(paths.distUnix) {
162     dir("bin") {
163       fileset(dir: "$home/bin") { include(name: "*.*") }
164       fileset(dir: "$home/bin/linux") { include(name: "*.*") }
165       fileset(dir: "$home/bin/nix") { include(name: "*.*") }
166     }
167   }
169   patchPropertiesFile(paths.distUnix)
171   ant.echo(file: "$paths.distUnix/bin/idea.vmoptions", message: vmoptions.replace(' ', '\n') )
172   ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "idea.vmoptions", eol: "unix")
173   ant.fixcrlf(srcdir: "$paths.distUnix/bin", includes: "*.sh", eol: "unix")
176   def tarRoot = "idea-$buildNumber"
177   def tarPath = "$paths.artifacts/idea${buildNumber}.tar"
178   ant.tar(tarfile: tarPath) {
179     [paths.distAll, paths.distUnix].each {
180       tarfileset(dir: it, prefix: tarRoot) {
181         exclude(name: "bin/*.sh")
182       }
183     }
185     tarfileset(dir: paths.distUnix, filemode: "755", prefix: tarRoot) {
186       include(name: "bin/*.sh")
187     }
188   }
190   ant.gzip(src: tarPath, zipfile: "${tarPath}.gz")
191   ant.delete(file: tarPath)