excluded python helpers from frames view
[idea/community.git] / python / edu / build / pycharm_edu_build.gant
1 /*
2  * Copyright 2000-2014 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
17 import org.jetbrains.jps.LayoutInfo
18
19 setProperty("home", getHome())
20 includeTargets << new File("$home/community/build/scripts/utils.gant")
21 includeTargets << new File("$home/community/build/scripts/libLicenses.gant")
22 includeTargets << new File("$home/build/scripts/ultimate_utils.gant")
23
24 requireProperty("buildNumber", requireProperty("build.number", snapshot))
25 setProperty("buildName", "EDU-$buildNumber")
26 setProperty("ch", "$home/community")
27 setProperty("pythonCommunityHome", "$ch/python")
28 setProperty("pythonEduHome", "$ch/python/edu")
29
30 // load ApplicationInfo.xml properties
31 ant.xmlproperty(file: "$pythonEduHome/resources/idea/PyCharmEduApplicationInfo.xml", collapseAttributes: "true")
32 setProperty("system_selector", "PyCharmEdu${p("component.version.major")}0")
33 setProperty("dryRun", false)
34 setProperty("jdk16", guessJdk())
35
36 //modules to compile
37 setProperty("pluginFilter", new File("$pythonEduHome/build/plugin-list.txt").readLines())
38
39 private String getHome(){
40   // current file is supposed to be at build/scripts/*.gant path
41   String uri = this["gant.file"]
42   return new File(new URI(uri).getSchemeSpecificPart()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile()
43 }
44
45 private List<String> pycharmPlatformApiModules() {
46   return [platformApiModules, "dom-openapi"].flatten()
47 }
48
49
50 private List pycharmImplementationModules() {   //modules to put into pycharm.jar
51   return [platformImplementationModules, "dom-impl", "python-community", "python-ide-community", "python-educational", "python-openapi", "python-psi-api",
52     "platform-main"].flatten()
53 }
54
55 private List modules() {
56   return [
57     "python-pydev", "colorSchemes", pycharmPlatformApiModules(), pycharmImplementationModules(), pluginFilter
58   ].flatten()
59 }
60
61 private List approvedJars() {
62   def normalizedHome = ch.replace('\\', '/')
63   def normalizedPythonHome = pythonCommunityHome.replace('\\', '/')
64   return ["$normalizedHome/lib/", "$normalizedPythonHome/lib/", "$normalizedHome/xml/relaxng/lib/"]
65 }
66
67 class Paths {
68   final sandbox
69   final distAll
70   final distWin
71   final distMac
72   final distUnix
73   final artifacts
74   final ideaSystem
75   final ideaConfig
76
77   def Paths(String home) {
78     sandbox = "$home/out/pycharmEDU"
79
80     distAll = "$sandbox/layout"
81     distWin = "$sandbox/win"
82     distMac = "$sandbox/mac"
83     distUnix = "$sandbox/unix"
84     artifacts = "$sandbox/artifacts"
85
86     ideaSystem = "$sandbox/system"
87     ideaConfig = "$sandbox/config"
88   }
89 }
90
91 setProperty("paths", new Paths(home))
92
93 target('default': "Build artifacts") {
94
95   loadProject()
96
97   List resourcePaths = ["$ch/community-resources/src",
98                         "$ch/platform/icons/src",
99                         "$pythonEduHome/resources"]
100
101   projectBuilder.stage("Cleaning up sandbox folder")
102
103   projectBuilder.targetFolder = "${paths.sandbox}/classes"
104   projectBuilder.dryRun = dryRun
105
106   if (!dryRun) {
107     forceDelete(paths.sandbox)
108     ant.mkdir(dir: paths.sandbox)
109     //Use EDU versions of IdeTipsAndTricks.xml and icon-robots.txt.
110     ant.delete(file: "${pythonCommunityHome}/src/META-INF/IdeTipsAndTricks.xml")
111     ant.delete(file: "${pythonCommunityHome}/resources/icon-robots.txt")
112   }
113
114   ant.tstamp() {
115     format(property: "todayYear", pattern: "yyyy")
116   }
117
118   bundledJDKs()
119   ant.patternset(id: "resources.included") {
120     include(name: "**/*.properties")
121     include(name: "fileTemplates/**/*")
122     include(name: "inspectionDescriptions/**/*")
123     include(name: "intentionDescriptions/**/*")
124     include(name: "tips/**/*")
125     include(name: "search/**/*")
126   }
127
128   ant.patternset(id: "resources.excluded") {
129     exclude(name: "**/*.properties")
130     exclude(name: "fileTemplates/**/*")
131     exclude(name: "fileTemplates")
132     exclude(name: "inspectionDescriptions/**/*")
133     exclude(name: "inspectionDescriptions")
134     exclude(name: "intentionDescriptions/**/*")
135     exclude(name: "intentionDescriptions")
136     exclude(name: "tips/**/*")
137     exclude(name: "tips")
138     exclude(name: "courses")
139     exclude(name: "courses/*")
140   }
141
142   zipSources(home, paths.artifacts)
143
144   def usedJars = buildModulesAndCollectUsedJars(modules(), approvedJars(), ["/ant/"])
145
146   layoutEducational("${paths.sandbox}/classes/production", usedJars)
147
148   def extraArgs = ["build.code": "pycharm${buildName}", "build.number": "PE-$buildNumber", "artifacts.path": "${paths.artifacts}"]
149   signMacZip("pycharm", extraArgs)
150   notifyArtifactBuilt("${paths.artifacts}/pycharm${buildName}.sit")
151   buildDmg("pycharm", "${pythonEduHome}/build/DMG_background.png", extraArgs)
152
153   if (p("jdk.bundled.mac") != "false" && new File(macJDK).exists()) {
154     signMacZip("pycharm", extraArgs + ["sitFileName": "pycharm${buildName}-jdk-bundled", "jdk_archive_name": macJDK])
155     buildDmg("pycharm", "${pythonEduHome}/build/DMG_background.png", extraArgs + ["sitFileName": "pycharm${buildName}-jdk-bundled"])
156   }
157 }
158
159 public layoutEducational(String classesPath, Set usedJars) {
160   setProperty("pluginFilter", new File("$pythonEduHome/build/plugin-list.txt").readLines())
161
162   if (usedJars == null) {
163     usedJars = collectUsedJars(modules(), approvedJars(), ["/ant/"], null)
164   }
165
166   def paths = new Paths(home)
167   buildSearchableOptions("${projectBuilder.moduleOutput(findModule("platform-resources"))}/search", [], {
168     projectBuilder.moduleRuntimeClasspath(findModule("main_pycharm_edu"), false).each {
169       ant.pathelement(location: it)
170     }
171   }, "-Didea.platform.prefix=PyCharmEdu -Didea.no.jre.check=true")
172
173   def appInfo = appInfoFile()
174   if (!dryRun) {
175     wireBuildDate("PE-${buildNumber}", appInfo)
176   }
177
178   Map args = [
179     buildNumber: "PE-${buildNumber}",
180     system_selector: system_selector,
181     ide_jvm_args: "-Didea.platform.prefix=PyCharmEdu -Didea.no.jre.check=true"]
182
183   LayoutInfo layoutInfo = layoutFull(args, paths.distAll, usedJars)
184   generateLicensesTable("$paths.artifacts/third-party-libraries.txt", layoutInfo.usedModules);
185
186   layoutWin(args, paths.distWin)
187   layoutUnix(args, paths.distUnix)
188   layoutMac(args, paths.distMac)
189
190   ant.echo(message: "PE-${buildNumber}", file: "${paths.distAll}/build.txt")
191
192   def launcher = "${paths.distWin}/bin/pycharm.exe"
193   List resourcePaths = ["$ch/community-resources/src",
194     "$ch/platform/icons/src",
195     "$pythonCommunityHome/resources",
196     "$pythonEduHome/resources"]
197   buildWinLauncher(ch, "$ch/bin/WinLauncher/WinLauncher.exe", launcher,
198                    appInfo, "$pythonEduHome/build/pycharm_edu_launcher.properties", system_selector, resourcePaths)
199   executeExternalAnt(["dirName": "${paths.distWin}/bin", "fileName": "pycharm.exe"], "$home/build/signBuild.xml")
200
201   buildWinZip("${paths.artifacts}/pycharm${buildName}.zip", [paths.distAll, paths.distWin, "${paths.sandbox}/bundled.win.jdk"])
202
203   buildNSIS([paths.distAll, paths.distWin],
204             "$pythonEduHome/build/strings.nsi", "$pythonEduHome/build/paths.nsi",
205             "pycharmEDU-", false, true, system_selector)
206
207   String tarRoot = isEap() ? "pycharm-edu-$buildNumber" : "pycharm-edu-${p("component.version.major")}.${p("component.version.minor")}"
208   buildTarGz(tarRoot, "$paths.artifacts/pycharm${buildName}.tar", [paths.distAll, paths.distUnix])
209   if (p("jdk.bundled.linux") != "false") {
210     buildTarGz(tarRoot, "$paths.artifacts/pycharm${buildName}-jdk-bundled.tar", [paths.distAll, paths.distUnix, "${paths.sandbox}/bundled.linux.jdk"], ["jre/jre/bin/*"])
211   }
212
213
214   String macAppRoot = isEap() ? "PyCharm Educational ${p("component.version.major")}.${p("component.version.minor")} EAP.app/Contents" : "PyCharm Educational.app/Contents"
215   buildMacZip(macAppRoot, "${paths.artifacts}/pycharm${buildName}.sit", [paths.distAll], paths.distMac)
216   ant.copy(file: "${paths.artifacts}/pycharm${buildName}.sit", tofile: "${paths.artifacts}/pycharm${buildName}-jdk-bundled.sit")
217   //ant.delete(file: "${paths.artifacts}/pycharm${buildName}.sit")
218 }
219
220 private layoutPlugins(layouts) {
221   dir("plugins") {
222     layouts.layoutPlugin("interactive-learning")
223     layouts.layoutPlugin("interactive-learning-python") {
224       dir("courses") {
225         fileset(dir: "$pythonEduHome/interactive-learning-python/resources/courses")
226       }
227     }
228     layouts.layoutPlugin("course-creator")
229     layouts.layoutPlugin("course-creator-python")
230   }
231
232   layouts.layoutCommunityPlugins(ch)
233 }
234
235 private String appInfoFile() {
236   return "$home/out/pycharmEDU/classes/production/python-educational/idea/PyCharmEduApplicationInfo.xml"
237 }
238
239 private layoutFull(Map args, String target, Set usedJars) {
240   def openapiModules = pycharmPlatformApiModules()
241   def superLayouts = includeFile("$ch/build/scripts/layouts.gant")
242
243   reassignAltClickToMultipleCarets("$ch")
244   
245   def result = layout(target) {
246     dir("lib") {
247       jar("util.jar") {
248         module("util")
249         module("util-rt")
250       }
251
252       jar("openapi.jar") {
253         openapiModules.each { module it }
254       }
255
256       jar("annotations.jar") {
257         module("annotations-common")
258         module("annotations")
259       }
260       jar("extensions.jar") { module("extensions") }
261
262       jar("pycharm.jar") {
263         pycharmImplementationModules().each {
264           module(it) {
265             exclude(name: "**/tips/**")
266           }
267         }
268       }
269
270       jar("educational.jar") {
271         module("educational")
272       }
273
274       jar("pycharm-pydev.jar") {
275         module("python-pydev")
276       }
277
278       jar("bootstrap.jar") { module("bootstrap") }
279       jar("resources.jar") {
280         module("platform-resources")
281         module("colorSchemes")
282       }
283
284       jar("forms_rt.jar") {
285         module("forms_rt")
286       }
287
288       //noinspection GroovyAssignabilityCheck
289       jar([name: "resources_en.jar", duplicate: "preserve"]) {
290         // custom resources should go first
291         fileset(dir: "$pythonCommunityHome/resources") {
292           include(name: "**/tips/**")
293         }
294         module("platform-resources-en") {
295           ant.patternset {
296             exclude(name: "tips/images/switcher.png")
297             exclude(name: "tips/images/navigateToFilePath.gif")
298           }
299         }
300       }
301
302       jar("icons.jar") { module("icons") }
303       jar("boot.jar") { module("boot") }
304
305       usedJars.each {
306         fileset(file: it)
307       }
308
309       fileset(dir: "$ch/build/kotlinc/lib") {
310         include(name: "kotlin-runtime.jar")
311         include(name: "kotlin-reflect.jar")
312       }
313
314       dir("libpty") {
315         fileset(dir: "$ch/lib/libpty") {
316           exclude(name: "*.txt")
317         }
318       }
319
320       dir("ext") {
321         fileset(dir: "$ch/lib") {
322           include(name: "cglib*.jar")
323         }
324       }
325
326       dir("src") {
327         fileset(dir: "$ch/lib/src") {
328           include(name: "trove4j_changes.txt")
329           include(name: "trove4j_src.jar")
330         }
331
332         jar("pycharm-pydev-src.zip") {
333           fileset(dir: "$pythonCommunityHome/pydevSrc")
334         }
335         jar("pycharm-openapi-src.zip") {
336           fileset(dir: "$pythonCommunityHome/openapi/src")
337           fileset(dir: "$pythonCommunityHome/psi-api/src")
338         }
339       }
340     }
341
342     dir("help") {
343       fileset(dir: "$home/python/help") {
344         include(name: "*.pdf")
345       }
346     }
347
348     dir("helpers") {
349       fileset(dir: "$pythonCommunityHome/helpers")
350     }
351
352     dir("license") {
353       fileset(dir: "$ch/license")
354       fileset(dir: "$ch") {
355         include(name: "LICENSE.txt")
356         include(name: "NOTICE.txt")
357       }
358     }
359
360     layoutPlugins(superLayouts)
361
362     dir("bin") {
363       fileset(dir: "$ch/bin") {
364         exclude(name: "appletviewer.policy")
365         include(name: "*.*")
366       }
367     }
368   }
369   patchPropertiesFile(target, args + [appendices: ["$home/build/conf/ideaJNC.properties"]])
370   return result
371 }
372
373 private layoutWin(Map args, String target) {
374   layout(target) {
375     dir("bin") {
376       fileset(dir: "$ch/bin/win") {
377         exclude(name: "breakgen*")
378       }
379     }
380
381     dir("skeletons") {
382       fileset(dir: "$pythonCommunityHome/skeletons") {
383         include(name: "skeletons-win*.zip")
384       }
385     }
386   }
387
388   winScripts(target, ch, "pycharm.bat", args)
389   winVMOptions(target, null, "pycharm.exe")
390
391   ant.copy(file: "$home/python/help/pycharm-eduhelp.jar", todir: "$target/help", failonerror: false)
392 }
393
394 private layoutUnix(Map args, String target) {
395   layout(target) {
396     dir("bin") {
397       fileset(dir: "$ch/bin/linux") {
398         exclude(name: "libbreakgen*")
399       }
400     }
401   }
402
403   ant.copy(file: "$pythonCommunityHome/resources/PyCharmCore128.png", tofile: "$target/bin/pycharm.png")
404
405   unixScripts(target, ch, "pycharm.sh", args)
406   unixVMOptions(target, "pycharm")
407
408   ant.copy(file: "$home/python/help/pycharm-eduhelp.jar", todir: "$target/help", failonerror: false)
409 }
410
411 private layoutMac(Map _args, String target) {
412   layout(target) {
413     dir("bin") {
414       fileset(dir: "$home/bin") {
415         include(name: "*.jnilib")
416       }
417     }
418
419     dir("skeletons") {
420       fileset(dir: "$pythonCommunityHome/skeletons") {
421         include(name: "skeletons-mac*.zip")
422       }
423     }
424   }
425
426   Map args = new HashMap(_args)
427   args.icns = "$pythonCommunityHome/resources/PyCharmCore.icns"
428   args.bundleIdentifier = "com.jetbrains.pycharm"
429   args.platform_prefix = "PyCharmEdu"
430   args.help_id = "PE"
431   args."idea.properties.path" = "${paths.distAll}/bin/idea.properties"
432   args."idea.properties" = ["idea.no.jre.check": true, "ide.mac.useNativeClipboard": "false"];
433   args.executable = "pycharm"
434   layoutMacApp(target, ch, args)
435 }