1 import org.jetbrains.jps.LayoutInfo
3 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
5 setProperty("home", guessHome(this as Script))
7 includeTargets << new File("${guessHome(this as Script)}/build/scripts/utils.gant")
8 includeTargets << new File("${guessHome(this)}/build/scripts/libLicenses.gant")
10 requireProperty("buildNumber", requireProperty("build.number", snapshot))
12 setProperty("ch", home)
13 setProperty("pythonCommunityHome", "$home/python")
15 // load ApplicationInfo.xml properties
16 ant.xmlproperty(file: "$pythonCommunityHome/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml", collapseAttributes: "true")
18 setProperty("system_selector", "PyCharmCE${p("component.version.major")}0")
19 setProperty("dryRun", false)
20 setProperty("jdk16", guessJdk())
23 setProperty("pluginFilter", new File("$pythonCommunityHome/build/plugin-list.txt").readLines())
25 private List<String> pycharmPlatformApiModules() {
26 return [platformApiModules, "dom-openapi"].flatten()
30 private List pycharmImplementationModules() { //modules to put into pycharm.jar
31 return [platformImplementationModules, "dom-impl", "python-community", "python-community-ide-resources",
32 "python-ide-community", "python-configure", "python-openapi", "python-psi-api", "platform-main"].flatten()
35 private List modules() {
37 "python-pydev", "colorSchemes", pycharmPlatformApiModules(), pycharmImplementationModules(), pluginFilter
41 private List approvedJars() {
42 def normalizedHome = ch.replace('\\', '/')
43 def normalizedPythonHome = pythonCommunityHome.replace('\\', '/')
44 return ["$normalizedHome/lib/", "$normalizedPythonHome/lib/", "$normalizedHome/xml/relaxng/lib/"]
57 def Paths(String home) {
58 sandbox = "$home/out/pycharmCE"
60 distAll = "$sandbox/layout"
61 distWin = "$sandbox/win"
62 distMac = "$sandbox/mac"
63 distUnix = "$sandbox/unix"
64 artifacts = "$sandbox/artifacts"
66 ideaSystem = "$sandbox/system"
67 ideaConfig = "$sandbox/config"
71 setProperty("paths", new Paths(home))
72 setProperty("buildName", "PC-$buildNumber")
74 target('default': "Build artifacts") {
78 projectBuilder.stage("Cleaning up sandbox folder")
80 projectBuilder.targetFolder = "${paths.sandbox}/classes"
81 projectBuilder.dryRun = dryRun
84 forceDelete(paths.sandbox)
85 ant.mkdir(dir: paths.sandbox)
89 format(property: "todayYear", pattern: "yyyy")
92 ant.patternset(id: "resources.included") {
93 include(name: "**/*.properties")
94 include(name: "fileTemplates/**/*")
95 include(name: "inspectionDescriptions/**/*")
96 include(name: "intentionDescriptions/**/*")
97 include(name: "tips/**/*")
98 include(name: "search/**/*")
101 ant.patternset(id: "resources.excluded") {
102 exclude(name: "**/*.properties")
103 exclude(name: "fileTemplates/**/*")
104 exclude(name: "fileTemplates")
105 exclude(name: "inspectionDescriptions/**/*")
106 exclude(name: "inspectionDescriptions")
107 exclude(name: "intentionDescriptions/**/*")
108 exclude(name: "intentionDescriptions")
109 exclude(name: "tips/**/*")
110 exclude(name: "tips")
113 zipSources(home, paths.artifacts)
115 def usedJars = buildModulesAndCollectUsedJars(modules(), approvedJars(), ["/ant/"])
117 layoutCommunity("${paths.sandbox}/classes/production", usedJars)
120 buildNSIS([paths.distAll, paths.distWin],
121 "$home/python/build/strings.nsi", "$home/python/build/paths.nsi",
122 "pycharm", false, true, system_selector)
126 signMacZip("pycharm")
127 buildDmg("pycharm", "${home}/python/build/DMG_background.png")
131 public layoutCommunity(String classesPath, Set usedJars) {
132 setProperty("pluginFilter", new File("$pythonCommunityHome/build/plugin-list.txt").readLines())
134 if (usedJars == null) {
135 usedJars = collectUsedJars(modules(), approvedJars(), ["/ant/"], null)
138 def appInfo = appInfoFile(classesPath)
139 def paths = new Paths(home)
140 buildSearchableOptions("${projectBuilder.moduleOutput(findModule("platform-resources"))}/search", [], {
141 projectBuilder.moduleRuntimeClasspath(findModule("main_pycharm_ce"), false).each {
142 ant.pathelement(location: it)
144 }, "-Didea.platform.prefix=PyCharmCore -Didea.no.jre.check=true")
147 wireBuildDate("PC-${buildNumber}", appInfo)
151 buildNumber: "PC-${buildNumber}",
152 system_selector: system_selector,
153 ide_jvm_args: "-Didea.platform.prefix=PyCharmCore -Didea.no.jre.check=true"]
155 LayoutInfo layoutInfo = layoutFull(args, paths.distAll, usedJars)
156 generateLicensesTable("$paths.artifacts/third-party-libraries.txt", layoutInfo.usedModules);
158 layoutWin(args, paths.distWin)
159 layoutUnix(args, paths.distUnix)
160 layoutMac(args, paths.distMac)
162 ant.echo(message: "PC-${buildNumber}", file: "${paths.distAll}/build.txt")
164 def launcher = "${paths.distWin}/bin/pycharm.exe"
165 def launcher64 = "${paths.distWin}/bin/pycharm64.exe"
166 List resourcePaths = ["$ch/community-resources/src",
167 "$ch/platform/icons/src",
168 "$pythonCommunityHome/python-community-ide-resources/resources",
169 "$pythonCommunityHome/resources"]
170 buildWinLauncher("$ch", "$ch/bin/WinLauncher/WinLauncher.exe", launcher,
171 appInfo, "$pythonCommunityHome/build/pycharm_community_launcher.properties", system_selector, resourcePaths)
172 buildWinLauncher("$ch", "$ch/bin/WinLauncher/WinLauncher64.exe", launcher64,
173 appInfo, "$pythonCommunityHome/build/pycharm64_community_launcher.properties", system_selector, resourcePaths)
175 List pathsDist = new File("${home}/out/pycharm/jdk.win/jre").exists() ? [paths.distAll, paths.distWin, "${home}/out/pycharm/jdk.win"] : [paths.distAll, paths.distWin]
176 buildWinZip("${paths.artifacts}/pycharmPC-${buildNumber}.zip", pathsDist)
178 String tarRoot = isEap() ? "pycharm-community-$buildNumber" : "pycharm-community-${p("component.version.major")}.${p("component.version.minor")}"
179 buildTarGz(tarRoot, "$paths.artifacts/pycharmPC-${buildNumber}-no-jdk.tar", [paths.distAll, paths.distUnix])
180 if (p("jdk.linux") != "false") {
181 buildTarGz(tarRoot, "$paths.artifacts/pycharmPC-${buildName}.tar", [paths.distAll, paths.distUnix, "${home}/out/pycharm/jdk.linux"], ["jre/jre/bin/*"])
184 String macAppRoot = isEap() ? "PyCharm CE ${p("component.version.major")}.${p("component.version.minor")} EAP.app/Contents" : "PyCharm CE.app/Contents"
185 buildMacZip(macAppRoot, "${paths.artifacts}/pycharmPC-${buildNumber}.mac.zip", [paths.distAll], paths.distMac)
188 private layoutPlugins(layouts) {
190 layouts.layoutPlugin("rest")
191 layouts.layoutPlugin("python-rest")
192 layouts.layoutPlugin("ipnb") {
193 fileset(dir: "$pythonCommunityHome/ipnb/lib")
197 layouts.layoutCommunityPlugins(ch)
200 private String appInfoFile(String classesPath) {
201 return "$classesPath/python-community/idea/PyCharmCoreApplicationInfo.xml"
204 private layoutFull(Map args, String target, Set usedJars) {
205 def openapiModules = pycharmPlatformApiModules()
206 def superLayouts = includeFile("$ch/build/scripts/layouts.gant")
208 reassignAltClickToMultipleCarets("$ch")
210 def result = layout(target) {
218 openapiModules.each { module it }
221 jar("annotations.jar") {
222 module("annotations-common")
223 module("annotations")
225 jar("extensions.jar") { module("extensions") }
227 jar(([name: "pycharm.jar", duplicate: "preserve"])) {
228 pycharmImplementationModules().each {
230 exclude(name: "**/tips/**")
235 jar("pycharm-pydev.jar") {
236 module("python-pydev")
239 jar("bootstrap.jar") { module("bootstrap") }
240 jar("resources.jar") {
241 module("platform-resources")
242 module("colorSchemes")
245 jar("forms_rt.jar") {
249 //noinspection GroovyAssignabilityCheck
250 jar([name: "resources_en.jar", duplicate: "preserve"]) {
251 // custom resources should go first
252 module("python-community-ide-resources") {
254 include(name: "**/tips/**")
257 module("platform-resources-en") {
259 exclude(name: "tips/images/switcher.png")
260 exclude(name: "tips/images/navigateToFilePath.gif")
265 jar("icons.jar") { module("icons") }
266 jar("boot.jar") { module("boot") }
272 fileset(dir: "$ch/build/kotlinc/lib") {
273 include(name: "kotlin-runtime.jar")
274 include(name: "kotlin-reflect.jar")
278 fileset(dir: "$ch/lib/libpty") {
279 exclude(name: "*.txt")
284 fileset(dir: "$ch/lib") {
285 include(name: "cglib*.jar")
290 fileset(dir: "$ch/lib/src") {
291 include(name: "trove4j_changes.txt")
292 include(name: "trove4j_src.jar")
295 jar("pycharm-pydev-src.zip") {
296 fileset(dir: "$pythonCommunityHome/pydevSrc")
298 jar("pycharm-openapi-src.zip") {
299 fileset(dir: "$pythonCommunityHome/openapi/src")
300 fileset(dir: "$pythonCommunityHome/psi-api/src")
306 fileset(dir: "$home/python/help") {
307 include(name: "*.pdf")
312 fileset(dir: "$pythonCommunityHome/helpers")
316 fileset(dir: "$ch/license")
317 fileset(dir: "$ch") {
318 include(name: "LICENSE.txt")
319 include(name: "NOTICE.txt")
323 layoutPlugins(superLayouts)
326 fileset(dir: "$ch/bin") {
327 exclude(name: "appletviewer.policy")
332 patchPropertiesFile(target, args + [appendices: ["$home/build/conf/ideaJNC.properties"]])
336 private layoutWin(Map args, String target) {
339 fileset(dir: "$ch/bin/win") {
340 exclude(name: "breakgen*")
345 fileset(dir: "$pythonCommunityHome/skeletons") {
346 include(name: "skeletons-win*.zip")
351 winScripts(target, ch, "pycharm.bat", args)
352 winVMOptions(target, null, "pycharm.exe", "pycharm64.exe")
353 ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false)
356 private layoutUnix(Map args, String target) {
359 fileset(dir: "$ch/bin/linux") {
360 exclude(name: "libbreakgen*")
365 ant.copy(file: "$pythonCommunityHome/resources/PyCharmCore128.png", tofile: "$target/bin/pycharm.png")
367 unixScripts(target, ch, "pycharm.sh", args)
368 unixVMOptions(target, "pycharm")
370 ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false)
373 private layoutMac(Map _args, String target) {
376 fileset(dir: "$home/bin") {
377 include(name: "*.jnilib")
382 fileset(dir: "$pythonCommunityHome/skeletons") {
383 include(name: "skeletons-mac*.zip")
388 Map args = new HashMap(_args)
389 args.icns = "$pythonCommunityHome/resources/PyCharmCore.icns"
390 args.bundleIdentifier = "com.jetbrains.pycharm"
391 args.platform_prefix = "PyCharmCore"
393 args."idea.properties.path" = "${paths.distAll}/bin/idea.properties"
394 args."idea.properties" = ["idea.no.jre.check": true, "ide.mac.useNativeClipboard": "false"];
395 args.executable = "pycharm"
396 layoutMacApp(target, ch, args)