| import org.jetbrains.jps.LayoutInfo | |
| import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome | |
| setProperty("home", guessHome(this as Script)) | |
| includeTargets << new File("${guessHome(this as Script)}/build/scripts/utils.gant") | |
| includeTargets << new File("${guessHome(this)}/build/scripts/libLicenses.gant") | |
| requireProperty("buildNumber", requireProperty("build.number", snapshot)) | |
| setProperty("ch", home) | |
| setProperty("pythonCommunityHome", "$home/python") | |
| // load ApplicationInfo.xml properties | |
| ant.xmlproperty(file: "$pythonCommunityHome/resources/idea/PyCharmCoreApplicationInfo.xml", collapseAttributes: "true") | |
| setProperty("system_selector", "PyCharm${p("component.version.major")}0") | |
| setProperty("dryRun", false) | |
| setProperty("jdk16", guessJdk()) | |
| //modules to compile | |
| setProperty("pluginFilter", new File("$pythonCommunityHome/build/plugin-list.txt").readLines()) | |
| private List<String> pycharmPlatformApiModules() { | |
| return [platformApiModules, "dom-openapi"].flatten() | |
| } | |
| private List pycharmImplementationModules() { //modules to put into pycharm.jar | |
| return [platformImplementationModules, "dom-impl", "python-community", "python-ide-community", "python-openapi", "python-psi-api", | |
| "platform-main"].flatten() | |
| } | |
| private List modules() { | |
| return [ | |
| "python-pydev", "colorSchemes", pycharmPlatformApiModules(), pycharmImplementationModules(), pluginFilter | |
| ].flatten() | |
| } | |
| private List approvedJars() { | |
| def normalizedHome = ch.replace('\\', '/') | |
| def normalizedPythonHome = pythonCommunityHome.replace('\\', '/') | |
| return ["$normalizedHome/lib/", "$normalizedPythonHome/lib/", "$normalizedHome/xml/relaxng/lib/"] | |
| } | |
| class Paths { | |
| final sandbox | |
| final distAll | |
| final distWin | |
| final distMac | |
| final distUnix | |
| final artifacts | |
| final ideaSystem | |
| final ideaConfig | |
| def Paths(String home) { | |
| sandbox = "$home/out/pycharmCE" | |
| distAll = "$sandbox/layout" | |
| distWin = "$sandbox/win" | |
| distMac = "$sandbox/mac" | |
| distUnix = "$sandbox/unix" | |
| artifacts = "$sandbox/artifacts" | |
| ideaSystem = "$sandbox/system" | |
| ideaConfig = "$sandbox/config" | |
| } | |
| } | |
| setProperty("paths", new Paths(home)) | |
| setProperty("buildName", "PC-$buildNumber") | |
| target('default': "Build artifacts") { | |
| loadProject() | |
| projectBuilder.stage("Cleaning up sandbox folder") | |
| projectBuilder.targetFolder = "${paths.sandbox}/classes" | |
| projectBuilder.dryRun = dryRun | |
| if (!dryRun) { | |
| forceDelete(paths.sandbox) | |
| ant.mkdir(dir: paths.sandbox) | |
| } | |
| ant.tstamp() { | |
| format(property: "todayYear", pattern: "yyyy") | |
| } | |
| ant.patternset(id: "resources.included") { | |
| include(name: "**/*.properties") | |
| include(name: "fileTemplates/**/*") | |
| include(name: "inspectionDescriptions/**/*") | |
| include(name: "intentionDescriptions/**/*") | |
| include(name: "tips/**/*") | |
| include(name: "search/**/*") | |
| } | |
| ant.patternset(id: "resources.excluded") { | |
| exclude(name: "**/*.properties") | |
| exclude(name: "fileTemplates/**/*") | |
| exclude(name: "fileTemplates") | |
| exclude(name: "inspectionDescriptions/**/*") | |
| exclude(name: "inspectionDescriptions") | |
| exclude(name: "intentionDescriptions/**/*") | |
| exclude(name: "intentionDescriptions") | |
| exclude(name: "tips/**/*") | |
| exclude(name: "tips") | |
| } | |
| zipSources(home, paths.artifacts) | |
| def usedJars = buildModulesAndCollectUsedJars(modules(), approvedJars(), ["/ant/"]) | |
| layoutCommunity("${paths.sandbox}/classes/production", usedJars) | |
| /* | |
| buildNSIS([paths.distAll, paths.distWin], | |
| "$home/python/build/strings.nsi", "$home/python/build/paths.nsi", | |
| "pycharm", false, true, system_selector) | |
| */ | |
| /* | |
| signMacZip("pycharm") | |
| buildDmg("pycharm", "${home}/python/build/DMG_background.png") | |
| */ | |
| } | |
| public layoutCommunity(String classesPath, Set usedJars) { | |
| setProperty("pluginFilter", new File("$pythonCommunityHome/build/plugin-list.txt").readLines()) | |
| if (usedJars == null) { | |
| usedJars = collectUsedJars(modules(), approvedJars(), ["/ant/"], null) | |
| } | |
| def appInfo = appInfoFile(classesPath) | |
| def paths = new Paths(home) | |
| buildSearchableOptions("${projectBuilder.moduleOutput(findModule("platform-resources"))}/search", [], { | |
| projectBuilder.moduleRuntimeClasspath(findModule("main_pycharm_ce"), false).each { | |
| ant.pathelement(location: it) | |
| } | |
| }, "-Didea.platform.prefix=PyCharmCore -Didea.no.jre.check=true") | |
| if (!dryRun) { | |
| wireBuildDate("PC-${buildNumber}", appInfo) | |
| } | |
| Map args = [ | |
| buildNumber: "PC-${buildNumber}", | |
| system_selector: system_selector, | |
| ide_jvm_args: "-Didea.platform.prefix=PyCharmCore -Didea.no.jre.check=true"] | |
| LayoutInfo layoutInfo = layoutFull(args, paths.distAll, usedJars) | |
| generateLicensesTable("$paths.artifacts/third-party-libraries.txt", layoutInfo.usedModules); | |
| layoutWin(args, paths.distWin) | |
| layoutUnix(args, paths.distUnix) | |
| layoutMac(args, paths.distMac) | |
| ant.echo(message: "PC-${buildNumber}", file: "${paths.distAll}/build.txt") | |
| def launcher = "${paths.distWin}/bin/pycharm.exe" | |
| def launcher64 = "${paths.distWin}/bin/pycharm64.exe" | |
| List resourcePaths = ["$ch/community-resources/src", | |
| "$ch/platform/icons/src", | |
| "$pythonCommunityHome/resources"] | |
| buildWinLauncher("$ch", "$ch/bin/WinLauncher/WinLauncher.exe", launcher, | |
| appInfo, "$pythonCommunityHome/build/pycharm_community_launcher.properties", system_selector, resourcePaths) | |
| buildWinLauncher("$ch", "$ch/bin/WinLauncher/WinLauncher64.exe", launcher64, | |
| appInfo, "$pythonCommunityHome/build/pycharm64_community_launcher.properties", system_selector, resourcePaths) | |
| buildWinZip("${paths.artifacts}/pycharmPC-${buildNumber}.zip", [paths.distAll, paths.distWin]) | |
| String tarRoot = isEap() ? "pycharm-community-$buildNumber" : "pycharm-community-${p("component.version.major")}.${p("component.version.minor")}" | |
| buildTarGz(tarRoot, "$paths.artifacts/pycharmPC-${buildNumber}.tar", [paths.distAll, paths.distUnix]) | |
| String macAppRoot = isEap() ? "PyCharm CE ${p("component.version.major")}.${p("component.version.minor")} EAP.app/Contents" : "PyCharm CE.app/Contents" | |
| buildMacZip(macAppRoot, "${paths.artifacts}/pycharmPC-${buildNumber}.sit", [paths.distAll], paths.distMac) | |
| } | |
| private layoutPlugins(layouts) { | |
| dir("plugins") { | |
| layouts.layoutPlugin("rest") | |
| layouts.layoutPlugin("python-rest") | |
| } | |
| layouts.layoutCommunityPlugins(ch) | |
| } | |
| private String appInfoFile(String classesPath) { | |
| return "$classesPath/python-community/idea/PyCharmCoreApplicationInfo.xml" | |
| } | |
| private layoutFull(Map args, String target, Set usedJars) { | |
| def openapiModules = pycharmPlatformApiModules() | |
| def superLayouts = includeFile("$ch/build/scripts/layouts.gant") | |
| reassignAltClickToMultipleCarets("$ch") | |
| def result = layout(target) { | |
| dir("lib") { | |
| jar("util.jar") { | |
| module("util") | |
| module("util-rt") | |
| } | |
| jar("openapi.jar") { | |
| openapiModules.each { module it } | |
| } | |
| jar("annotations.jar") { module("annotations") } | |
| jar("extensions.jar") { module("extensions") } | |
| jar("pycharm.jar") { | |
| pycharmImplementationModules().each { | |
| module(it) { | |
| exclude(name: "**/tips/**") | |
| } | |
| } | |
| } | |
| jar("pycharm-pydev.jar") { | |
| module("python-pydev") | |
| } | |
| jar("bootstrap.jar") { module("bootstrap") } | |
| jar("resources.jar") { | |
| module("platform-resources") | |
| module("colorSchemes") | |
| } | |
| jar("forms_rt.jar") { | |
| module("forms_rt") | |
| } | |
| //noinspection GroovyAssignabilityCheck | |
| jar([name: "resources_en.jar", duplicate: "preserve"]) { | |
| // custom resources should go first | |
| fileset(dir: "$pythonCommunityHome/resources") { | |
| include(name: "**/tips/**") | |
| } | |
| module("platform-resources-en") { | |
| ant.patternset { | |
| exclude(name: "tips/images/switcher.png") | |
| exclude(name: "tips/images/navigateToFilePath.gif") | |
| } | |
| } | |
| } | |
| jar("icons.jar") { module("icons") } | |
| jar("boot.jar") { module("boot") } | |
| usedJars.each { | |
| fileset(file: it) | |
| } | |
| dir("libpty") { | |
| fileset(dir: "$ch/lib/libpty") { | |
| exclude(name: "*.txt") | |
| } | |
| } | |
| dir("ext") { | |
| fileset(dir: "$ch/lib") { | |
| include(name: "cglib*.jar") | |
| } | |
| } | |
| dir("src") { | |
| fileset(dir: "$ch/lib/src") { | |
| include(name: "trove4j_changes.txt") | |
| include(name: "trove4j_src.jar") | |
| } | |
| jar("pycharm-pydev-src.zip") { | |
| fileset(dir: "$pythonCommunityHome/pydevSrc") | |
| } | |
| jar("pycharm-openapi-src.zip") { | |
| fileset(dir: "$pythonCommunityHome/openapi/src") | |
| fileset(dir: "$pythonCommunityHome/psi-api/src") | |
| } | |
| } | |
| } | |
| dir("help") { | |
| fileset(dir: "$home/python/help") { | |
| include(name: "*.pdf") | |
| } | |
| } | |
| dir("helpers") { | |
| fileset(dir: "$pythonCommunityHome/helpers") | |
| } | |
| dir("license") { | |
| fileset(dir: "$ch/license") | |
| fileset(dir: "$ch") { | |
| include(name: "LICENSE.txt") | |
| include(name: "NOTICE.txt") | |
| } | |
| } | |
| layoutPlugins(superLayouts) | |
| dir("bin") { | |
| fileset(dir: "$ch/bin") { | |
| exclude(name: "appletviewer.policy") | |
| include(name: "*.*") | |
| } | |
| } | |
| } | |
| patchPropertiesFile(target, args + [appendices: ["$home/build/conf/ideaJNC.properties"]]) | |
| return result | |
| } | |
| private layoutWin(Map args, String target) { | |
| layout(target) { | |
| dir("bin") { | |
| fileset(dir: "$ch/bin/win") { | |
| exclude(name: "breakgen*") | |
| } | |
| } | |
| dir("skeletons") { | |
| fileset(dir: "$pythonCommunityHome/skeletons") { | |
| include(name: "skeletons-win*.zip") | |
| } | |
| } | |
| } | |
| winScripts(target, ch, "pycharm.bat", args) | |
| winVMOptions(target, null, "pycharm.exe", "pycharm64.exe") | |
| ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false) | |
| } | |
| private layoutUnix(Map args, String target) { | |
| layout(target) { | |
| dir("bin") { | |
| fileset(dir: "$ch/bin/linux") { | |
| exclude(name: "libbreakgen*") | |
| } | |
| } | |
| } | |
| ant.copy(file: "$pythonCommunityHome/resources/PyCharmCore128.png", tofile: "$target/bin/pycharm.png") | |
| unixScripts(target, ch, "pycharm.sh", args) | |
| unixVMOptions(target, "pycharm") | |
| ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false) | |
| } | |
| private layoutMac(Map _args, String target) { | |
| layout(target) { | |
| dir("bin") { | |
| fileset(dir: "$home/bin") { | |
| include(name: "*.jnilib") | |
| } | |
| } | |
| dir("skeletons") { | |
| fileset(dir: "$pythonCommunityHome/skeletons") { | |
| include(name: "skeletons-mac*.zip") | |
| } | |
| } | |
| } | |
| Map args = new HashMap(_args) | |
| args.icns = "$pythonCommunityHome/resources/PyCharmCore.icns" | |
| args.bundleIdentifier = "com.jetbrains.pycharm" | |
| args.platform_prefix = "PyCharmCore" | |
| args.help_id = "PY" | |
| args."idea.properties.path" = "${paths.distAll}/bin/idea.properties" | |
| args."idea.properties" = ["idea.no.jre.check": true, "ide.mac.useNativeClipboard": "false"]; | |
| layoutMacApp(target, ch, args) | |
| } |