diff --git a/.idea/modules.xml b/.idea/modules.xml index 6446ab4d74a1..4d78d45ff1e3 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -307,6 +307,7 @@ + \ No newline at end of file diff --git a/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginBuilder.groovy b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginBuilder.groovy new file mode 100644 index 000000000000..489960f67a05 --- /dev/null +++ b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginBuilder.groovy @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.pycharm + +import org.codehaus.gant.GantBinding +import org.jetbrains.intellij.build.BuildContext +import org.jetbrains.intellij.build.BuildOptions +import org.jetbrains.intellij.build.BuildTasks +import org.jetbrains.intellij.build.ProprietaryBuildTools + +/** + * @author vlan + */ +class PythonCommunityPluginBuilder { + private final GantBinding binding + private final String home + + PythonCommunityPluginBuilder(String home, GantBinding binding) { + this.home = home + this.binding = binding + } + + def build() { + def pluginBuildNumber = System.getProperty("build.number", "SNAPSHOT") + def options = new BuildOptions(targetOS: BuildOptions.OS_NONE, buildNumber: pluginBuildNumber) + def buildContext = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global, + home, home, new PythonCommunityPluginProperties(pluginBuildNumber), + ProprietaryBuildTools.DUMMY, options) + def buildTasks = BuildTasks.create(buildContext) + buildTasks.buildDistributions() + } +} diff --git a/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginProperties.groovy b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginProperties.groovy new file mode 100644 index 000000000000..5f94546fb15c --- /dev/null +++ b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonCommunityPluginProperties.groovy @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.pycharm + +import org.jetbrains.intellij.build.CommunityRepositoryModules + +/** + * @author vlan + */ +class PythonCommunityPluginProperties extends PythonPluginPropertiesBase { + PythonCommunityPluginProperties(String pluginVersion) { + super() + productCode = "PC" + platformPrefix = "PyCharmCore" + applicationInfoModule = "python-community-ide-resources" + productLayout.pluginModulesToPublish = [pythonCommunityPluginModule] + + productLayout.allNonTrivialPlugins = CommunityRepositoryModules.COMMUNITY_REPOSITORY_PLUGINS + [ + pythonCommunityPluginLayout(pluginVersion) + ] + } +} diff --git a/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonPluginPropertiesBase.groovy b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonPluginPropertiesBase.groovy new file mode 100644 index 000000000000..f8dae9592117 --- /dev/null +++ b/python/build/groovy/org/jetbrains/intellij/build/pycharm/PythonPluginPropertiesBase.groovy @@ -0,0 +1,88 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.intellij.build.pycharm + +import org.jetbrains.intellij.build.ApplicationInfoProperties +import org.jetbrains.intellij.build.LinuxDistributionCustomizer +import org.jetbrains.intellij.build.MacDistributionCustomizer +import org.jetbrains.intellij.build.WindowsDistributionCustomizer +import org.jetbrains.intellij.build.impl.PluginLayout + +/** + * @author vlan + */ +abstract class PythonPluginPropertiesBase extends PyCharmPropertiesBase { + List communityModules = [ + "IntelliLang-python", + "ipnb", + "python-openapi", + "python-community-plugin-core", + "python-community-plugin-java", + "python-psi-api", + "python-pydev", + "python-community", + ] + + String pythonCommunityPluginModule = "python-community-plugin-resources" + + PythonPluginPropertiesBase() { + super() + } + + PluginLayout pythonCommunityPluginLayout(String pluginVersion) { + pythonPlugin(pythonCommunityPluginModule, "python-ce", "python-community-plugin-build-patches", + communityModules, pluginVersion) + } + + static PluginLayout pythonPlugin(String mainModuleName, String name, String buildPatchesModule, List modules, + String pluginVersion, @DelegatesTo(PluginLayout.PluginLayoutSpec) Closure body = {}) { + return PluginLayout.plugin(mainModuleName) { + directoryName = name + mainJarName = "${name}.jar" + version = pluginVersion + modules.each { module -> + withModule(module, mainJarName, false) + excludeFromModule(module, "**/plugin.xml") + excludeFromModule(module, "**/python-plugin-dependencies.xml") + } + withModule(buildPatchesModule, mainJarName, false) + withResourceFromModule("python-helpers", "", "helpers") + doNotCreateSeparateJarForLocalizableResources() + body.delegate = delegate + body() + } + } + + @Override + String getBaseArtifactName(ApplicationInfoProperties applicationInfo, String buildNumber) { + return null + } + + @Override + WindowsDistributionCustomizer createWindowsCustomizer(String projectHome) { + return null + } + + @Override + LinuxDistributionCustomizer createLinuxCustomizer(String projectHome) { + return null + } + + @Override + MacDistributionCustomizer createMacCustomizer(String projectHome) { + return null + } +} diff --git a/python/build/python_community_plugin_build.gant b/python/build/python_community_plugin_build.gant new file mode 100644 index 000000000000..e728d702236f --- /dev/null +++ b/python/build/python_community_plugin_build.gant @@ -0,0 +1,12 @@ +import org.jetbrains.intellij.build.impl.BuildUtils +import org.jetbrains.jps.gant.JpsGantTool +import org.jetbrains.jps.idea.IdeaProjectLoader + +includeTool << JpsGantTool + +target("default": "Default") { + String home = new File(IdeaProjectLoader.guessHome(this)).absolutePath + BuildUtils.addToClassPath("$home/build/groovy", ant) + BuildUtils.addToClassPath("$home/python/build/groovy", ant) + Class.forName("org.jetbrains.intellij.build.pycharm.PythonCommunityPluginBuilder").constructors[0].newInstance(home, binding).build() +} diff --git a/python/build/python_plugin_build.gant b/python/build/python_plugin_build.gant deleted file mode 100644 index a7fc79529c8e..000000000000 --- a/python/build/python_plugin_build.gant +++ /dev/null @@ -1,168 +0,0 @@ -import org.jetbrains.intellij.build.impl.BuildUtils -import org.jetbrains.jps.model.library.JpsOrderRootType - -import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome - -setProperty("projectHome", guessHome(this as Script)) - -includeTargets << new File("${projectHome}/build/scripts/utils.gant") - -setProperty("dryRun", false) - -setProperty("communityHome", "${projectHome}/python") - -setProperty("pythonPluginVersion", requireProperty("build.number", snapshot)) - -def buildModules(List modules, List libDirs) { - def forbiddenJars = [ - "/dev/", "/rt/", "/ant/", - "ls-client-api", "/ideaLicenseDecoder", "jcip-annotations", - "/eawtstub.jar", "/y.jar", "/ysvg.jar" - ] - - def normalizedHome = home.replace('\\', '/') - def approvedJars = ["$normalizedHome/lib/", "$normalizedHome/xml/relaxng/lib/"] - libDirs.each { approvedJars.add("$normalizedHome/$it/") } - - buildModulesAndCollectUsedJars(modules, approvedJars, forbiddenJars) -} - - -target('default': "Build Python Plugin") { - def pythonHome = "$home/python" - ant.property(file: "$pythonHome/build/build-plugin.properties") - BuildUtils.addToClassPath("$home/python/build/groovy", ant) - - def communityModules = [ - "IntelliLang-python", - "ipnb", - "python-openapi", - "python-community-configure", - "python-community-plugin-core", - "python-community-plugin-java", - "python-psi-api", - "python-pydev", - "python-community-ide-resources", - "python-community-plugin-resources", - "python-community" - ] - - - def modules = communityModules - - def outDir = "$home/out/python" - def ideaDistDir = "$outDir/idea" - def helpDir = "$outDir/help" - loadProject() - - if (dryRun) { - projectBuilder.targetFolder = "$home/out/classes" - } - else { - projectBuilder.targetFolder = "$outDir/classes" - } - projectBuilder.dryRun = dryRun - - projectBuilder.stage("Cleaning up sandbox folder") - if (!dryRun) { - forceDelete("$outDir/classes") - } - - buildModules(modules, []) - - def ideaBuildTxt = new File(ideaDistDir, "build.txt") - def currentIdeaBranch - def currentIdeaBuild - if (ideaBuildTxt.exists()) { - def matcher = (ideaBuildTxt.text =~ /IU-(\d+)\.(\d+).*/) - currentIdeaBranch = matcher[0][1] - currentIdeaBuild = matcher[0][2] - } - else { - currentIdeaBranch = null - currentIdeaBuild = null - } - - def sinceBuild - def untilBuild - if (currentIdeaBranch != null && currentIdeaBuild != null) { - sinceBuild = "${currentIdeaBranch}.${currentIdeaBuild}" - untilBuildNum = (currentIdeaBranch.toInteger() + 1).toString() - untilBuild = "$untilBuildNum.0" - } else { - sinceBuild = null - untilBuild = null - } - - // def pluginVersion = "$pythonPluginVersion.${new SimpleDateFormat("yyyyMMdd").format(new Date())}" - def pluginVersion = "$pythonPluginVersion" - - // set version to PyCharm current version from ApplicationInfo.xml - ant.loadfile(property: "appInfo", srcFile: "${communityHome}/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml") { - } - - ant.xmlproperty(file: "${communityHome}/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml", collapseAttributes: "true") - - def pythonPluginVersionString = "${versionSelector()}.${pluginVersion}" - - - ant.mkdir(dir: "$outDir/plugins/python-ce") - ant.copy(file: "$communityHome/pluginResources/META-INF/plugin.xml", todir: "$outDir/plugins/python-ce") - ant.replace(file: "$outDir/plugins/python-ce/plugin.xml") { - replacefilter(token: "@@PYCHARM_VERSION@@", value: "$pythonPluginVersionString") - } - - if (sinceBuild != null && untilBuild != null) { - ant.replaceregexp(file: "$outDir/plugins/python-ce/plugin.xml", - match: "since-build=\"[^\"]+\"", - replace: "since-build=\"${sinceBuild}\"") - } - - layout("$outDir/layout-ce") { - dir("python") { - dir("lib") { - jar("python.jar") { - communityModules.each { - module(it) { - exclude(name: "**/plugin.xml") - exclude(name: "**/python-community-configure-ide.xml") - exclude(name: "**/python-plugin-dependencies.xml") - exclude(name: "**/icon-robots.txt") - } - } - dir("META-INF") { - fileset(file: "$outDir/plugins/python-ce/plugin.xml") - fileset(file: "$communityHome/build/python-plugin-dependencies.xml") - } - } - fileset(dir: "${communityHome}/ipnb/lib") { - include(name: "*.jar") - } - } - dir("help") { - fileset(dir: "${helpDir}") { - include(name: "pytonpluginhelp.jar") - include(name: "pytonpluginhelp_mac.jar") - } - } - dir("helpers") { - fileset(dir: "${communityHome}/helpers") { - include(name: "**/*") - } - } - } - } - - def zipFilePathCE = "$outDir/python-community-${pluginVersion}.zip" - ant.delete(file: zipFilePathCE) - ant.zip(destfile: zipFilePathCE) { - fileset(dir: "$outDir/layout-ce") - } - notifyArtifactBuilt(zipFilePathCE) - - def pluginsPaths = [] - pluginsPaths << zipFilePathCE - - - new File(outDir, "plugins-paths.txt").text = pluginsPaths.join("\n") -} \ No newline at end of file