Files
openide/python/build/python_plugin_build.gant
T

167 lines
5.0 KiB
Plaintext

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")
}
}
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")
}