Use newer build API for Python Community plugin

This commit is contained in:
Andrey Vlasovskikh
2017-02-15 15:13:37 +03:00
parent 5aa5b9229f
commit 773da219ee
6 changed files with 181 additions and 168 deletions
+1
View File
@@ -307,6 +307,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" filepath="$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/yaml/yaml.iml" filepath="$PROJECT_DIR$/plugins/yaml/yaml.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/python/build/patches/python-community-plugin-build-patches.iml" filepath="$PROJECT_DIR$/python/build/patches/python-community-plugin-build-patches.iml" group="python" />
</modules>
</component>
</project>
@@ -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()
}
}
@@ -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)
]
}
}
@@ -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<String> 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<String> 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
}
}
@@ -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()
}
-168
View File
@@ -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")
}