mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Delete outdated scripts
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
trunk=481
|
||||
eap=481
|
||||
release=408
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
target('default': 'Downloads custom JRE build from Teamcity server') {
|
||||
def platform = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "win" : SystemInfo.isLinux ? "linux" : ""
|
||||
if (platform == "") {
|
||||
echo "Unsupported platform, JRE download skipped"
|
||||
return
|
||||
}
|
||||
if (jreArchitecture == "disable") {
|
||||
echo "JRE update disabled"
|
||||
return
|
||||
}
|
||||
if (!(jreArchitecture == "64" || jreArchitecture == "32" && platform == "win")) {
|
||||
echo "Acceptable architecture (32 or 64 bit) is not defined, JRE download skipped"
|
||||
return
|
||||
}
|
||||
|
||||
def majorBuildNumber = ideBuildNumber.split(/\./)[0]
|
||||
def buildConfiguration = jreBuildTypeId.replaceAll(/#build#/, majorBuildNumber)
|
||||
|
||||
String buildId, buildNumber
|
||||
try {
|
||||
buildId = new URL("$jreTeamcityUrl/buildTypes/id:$buildConfiguration/builds/tags:$jreBuildTag/id").text
|
||||
buildNumber = new URL("$jreTeamcityUrl/builds/id:$buildId/number").text
|
||||
}
|
||||
catch (IOException e) {
|
||||
echo "Build server connection failed: ${e.message}, JRE download skipped"
|
||||
return
|
||||
}
|
||||
|
||||
java(jvm: SystemInfo.isMac ? "$workIdeaHome/jdk/Contents/Home/jre/bin/java" : "$workIdeaHome/jre/jre/bin/java",
|
||||
fork: "true", classname: "dummy", outputproperty: "jvmVersionOutput") {
|
||||
jvmarg(value: "-version")
|
||||
}
|
||||
try {
|
||||
if (jvmVersionOutput =~ /\(build .*release-${Pattern.quote(buildNumber.replace(".", "-b"))}\)/ &&
|
||||
jvmVersionOutput =~ (jreArchitecture == "64" ? /OpenJDK 64-Bit Server VM/ : /OpenJDK Server VM/)) {
|
||||
echo "Latest version of custom JRE is installed, no update is required"
|
||||
return
|
||||
}
|
||||
}
|
||||
catch (MissingPropertyException ignored) {
|
||||
echo "Could'nt determine existing JRE version"
|
||||
}
|
||||
def files = new XmlSlurper().parse("$jreTeamcityUrl/builds/id:$buildId/artifacts/children/$platform")
|
||||
def artifact = files.children().collect { it.@name.text() }.find {
|
||||
it.startsWith(jreArtifactPrefix) && it.endsWith(jreArchitecture == "64" ? "_x64.tar.gz" : "_x86.tar.gz") && !it.contains("debug")
|
||||
}
|
||||
get src: "$jreTeamcityUrl/builds/id:$buildId/artifacts/content/$platform/$artifact", dest: deployDir
|
||||
if (SystemInfo.isWindows) {
|
||||
mkdir dir: "$deployDir/jre"
|
||||
untar src: "$deployDir/$artifact", dest: "$deployDir/jre", compression: "gzip"
|
||||
}
|
||||
else if (SystemInfo.isMac) {
|
||||
// untar task doesn't support symlinks, so we need to use native tar executable
|
||||
exec(executable: "tar", dir: "$deployDir") {
|
||||
arg(value: "-xf")
|
||||
arg(value: "$artifact")
|
||||
}
|
||||
}
|
||||
else if (SystemInfo.isLinux) {
|
||||
mkdir dir: "$deployDir/jre"
|
||||
// untar task doesn't support symlinks, so we need to use native tar executable
|
||||
exec(executable: "tar", dir: "$deployDir") {
|
||||
arg(value: "-xf")
|
||||
arg(value: "$artifact")
|
||||
arg(value: "--directory")
|
||||
arg(value: "jre")
|
||||
}
|
||||
}
|
||||
delete file: "$deployDir/$artifact"
|
||||
}
|
||||
@@ -1,328 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.text.VersionComparatorUtil
|
||||
import groovyjarjarasm.asm.AnnotationVisitor
|
||||
import groovyjarjarasm.asm.ClassReader
|
||||
import groovyjarjarasm.asm.ClassVisitor
|
||||
import groovyjarjarasm.asm.Opcodes
|
||||
|
||||
import java.util.jar.JarFile
|
||||
|
||||
import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
|
||||
|
||||
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
|
||||
|
||||
String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_110_CompilerAndPlugin_NoTests"
|
||||
|
||||
target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') {
|
||||
def communityHome = guessHome(this)
|
||||
def classVersionOfCompiledClasses = readKotlinClassVersionOfCompiledClasses()
|
||||
def reasonToUpdate = getReasonToUpdate(communityHome, new File(communityHome, "build/kotlinc/plugin/Kotlin"), classVersionOfCompiledClasses)
|
||||
if (reasonToUpdate == null) {
|
||||
if (isDefined("workIdeaHome")) {
|
||||
def workKotlinVersionFile = new File(workIdeaHome, "plugins/Kotlin/kotlinc/build.txt")
|
||||
if (workKotlinVersionFile.exists()) {
|
||||
try {
|
||||
def currentKotlinVersionFile = new File(communityHome, "build/kotlinc/build.txt")
|
||||
if (VersionComparatorUtil.compare(currentKotlinVersionFile.text, workKotlinVersionFile.text) < 0) {
|
||||
reasonToUpdate = "a newer version is installed in $workIdeaHome"
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
reasonToUpdate = "cannot read Kotlin version: $e"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reasonToUpdate == null) {
|
||||
projectBuilder.info("Compatible Kotlin plugin already installed, no update is required")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
projectBuilder.info("Kotlin plugin will be updated: $reasonToUpdate")
|
||||
|
||||
if (isDefined("workIdeaHome")) {
|
||||
if (updatePluginFromWorkIdeaInstallation(communityHome, workIdeaHome, classVersionOfCompiledClasses)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (isDefined("kotlin.teamcity.host")) {
|
||||
if (downloadAndExtract(new TeamCityBuildLocator(p("kotlin.teamcity.host"), p("kotlin.build.type.id"), p("kotlin.build.selector")),
|
||||
communityHome, classVersionOfCompiledClasses)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (!downloadAndExtract(new TeamCityBuildLocator("https://teamcity.jetbrains.com", kotlinBuildConfigurationOnPublicTeamCity, "status:SUCCESS"),
|
||||
communityHome, classVersionOfCompiledClasses)) {
|
||||
projectBuilder.error("Failed to install Kotlin plugin")
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updatePluginFromWorkIdeaInstallation(String communityHome, String workIdeaHome, String classVersionOfCompiledClasses) {
|
||||
def kotlinPluginFromWorkIdea = new File(workIdeaHome, "plugins/Kotlin")
|
||||
if (!kotlinPluginFromWorkIdea.exists()) {
|
||||
projectBuilder.info("Cannot use Kotlin from $workIdeaHome: the plugin directory doesn't exist")
|
||||
return false
|
||||
}
|
||||
|
||||
def reasonToUpdate = getReasonToUpdate(communityHome, kotlinPluginFromWorkIdea, classVersionOfCompiledClasses)
|
||||
if (reasonToUpdate != null) {
|
||||
projectBuilder.info("Cannot use Kotlin from $workIdeaHome: $reasonToUpdate")
|
||||
return false
|
||||
}
|
||||
|
||||
ant.delete(dir: "$communityHome/build/kotlinc")
|
||||
ant.copy(todir: "$communityHome/build/kotlinc/plugin/Kotlin") {
|
||||
ant.fileset(dir: kotlinPluginFromWorkIdea)
|
||||
}
|
||||
ant.copy(todir: "$communityHome/build/kotlinc") {
|
||||
ant.fileset(dir: "$kotlinPluginFromWorkIdea/kotlinc")
|
||||
}
|
||||
ant.copy(todir: "$communityHome/build/kotlinc/jps") {
|
||||
ant.fileset(dir: "$kotlinPluginFromWorkIdea/lib/jps")
|
||||
}
|
||||
projectBuilder.info("Kotlin plugin updated from $workIdeaHome installation")
|
||||
return true
|
||||
}
|
||||
|
||||
private String getReasonToUpdate(String communityHome, File kotlinPluginHome, String classVersionOfCompiledClasses) {
|
||||
def kotlincHome = new File(kotlinPluginHome, "kotlinc")
|
||||
def buildTxt = new File(kotlincHome, "build.txt")
|
||||
if (!buildTxt.exists()) {
|
||||
return "Kotlin binaries aren't found at $kotlincHome"
|
||||
}
|
||||
|
||||
if (classVersionOfCompiledClasses != null) {
|
||||
def currentKotlinClassVersion = detectKotlinClassVersionForKotlinDist(kotlincHome)
|
||||
if (currentKotlinClassVersion == null) {
|
||||
projectBuilder.info("Cannot detect Kotlin class file version for $kotlincHome, class file versions compatibility won't be checked")
|
||||
}
|
||||
else if (VersionComparatorUtil.compare(currentKotlinClassVersion, classVersionOfCompiledClasses) < 0) {
|
||||
return "Kotlin compiler produces class-files of version $currentKotlinClassVersion, but IDEA classes have version $classVersionOfCompiledClasses"
|
||||
}
|
||||
}
|
||||
|
||||
String currentKotlinVersion
|
||||
try {
|
||||
currentKotlinVersion = buildTxt.text
|
||||
}
|
||||
catch (IOException e) {
|
||||
return "cannot read Kotlin version from $buildTxt.absolutePath: $e"
|
||||
}
|
||||
|
||||
def externalDependenciesXml = new File(communityHome, ".idea/externalDependencies.xml")
|
||||
if (!externalDependenciesXml.exists()) {
|
||||
return "cannot read required Kotlin version from $externalDependenciesXml.absolutePath: the file doesn't exist"
|
||||
}
|
||||
|
||||
def root = new XmlParser().parse(externalDependenciesXml)
|
||||
def pluginTag = root.component?.find { it.@name == "ExternalDependencies" }?.plugin?.find { it.@id == "org.jetbrains.kotlin" }
|
||||
if (pluginTag == null) return "cannot find Kotlin plugin in $externalDependenciesXml.absolutePath"
|
||||
|
||||
String minVersion = pluginTag['@min-version']
|
||||
if (minVersion == null) return "minimum required version for Kotlin plugin isn't specified in $externalDependenciesXml.absolutePath"
|
||||
String maxVersion = pluginTag['@max-version']
|
||||
if (maxVersion == null) return "maximum required version for Kotlin plugin isn't specified in $externalDependenciesXml.absolutePath"
|
||||
|
||||
if (VersionComparatorUtil.compare(currentKotlinVersion, minVersion) < 0) {
|
||||
return "Kotlin version is $currentKotlinVersion, but at least $minVersion is required";
|
||||
}
|
||||
if (VersionComparatorUtil.compare(currentKotlinVersion, maxVersion) > 0) {
|
||||
return "Kotlin version is $currentKotlinVersion, but at most $maxVersion is required";
|
||||
}
|
||||
|
||||
String ideVersion
|
||||
def ideVersionFile = new File(communityHome, "build.txt")
|
||||
try {
|
||||
ideVersion = ideVersionFile.text
|
||||
}
|
||||
catch (IOException e) {
|
||||
return "cannot read IDE version from $ideVersionFile: $e"
|
||||
}
|
||||
def pluginJar = new File(kotlinPluginHome, "lib/kotlin-plugin.jar")
|
||||
String pluginUntilBuild
|
||||
try {
|
||||
def jarFile = new JarFile(pluginJar)
|
||||
try {
|
||||
def pluginXmlEntry = jarFile.getEntry("META-INF/plugin.xml")
|
||||
if (pluginXmlEntry == null) {
|
||||
return "cannot check Kotlin plugin compatibility (META-INF/plugin.xml not found in $pluginJar)"
|
||||
}
|
||||
def pluginXml = new XmlParser().parse(jarFile.getInputStream(pluginXmlEntry))
|
||||
pluginUntilBuild = pluginXml."idea-version"?.first()?."@until-build"
|
||||
if (pluginUntilBuild != null) {
|
||||
String ideVersionBaseLine = StringUtil.substringBefore(ideVersion, ".")
|
||||
String pluginUntilBuildBaseLine = StringUtil.substringBefore(pluginUntilBuild, ".")
|
||||
if (ideVersionBaseLine > pluginUntilBuildBaseLine) {
|
||||
return "Kotlin plugin isn't compatible with $ideVersion (its 'until-build' is $pluginUntilBuild)"
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
jarFile.close()
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
return "cannot check Kotlin plugin compatibility: $e"
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private String detectKotlinClassVersionForKotlinDist(File kotlincHome) {
|
||||
def kotlinRuntimeFile = new File(kotlincHome, "lib/kotlin-runtime.jar")
|
||||
def kotlinRuntimeJar = new JarFile(kotlinRuntimeFile)
|
||||
try {
|
||||
try {
|
||||
def unitClassPath = "kotlin/Unit.class"
|
||||
def entry = kotlinRuntimeJar.getJarEntry(unitClassPath)
|
||||
if (entry == null) {
|
||||
projectBuilder.warning("Cannot find $unitClassPath in $kotlinRuntimeJar")
|
||||
return null
|
||||
}
|
||||
return readKotlinClassFileVersion(kotlinRuntimeJar.getInputStream(entry))
|
||||
}
|
||||
finally {
|
||||
kotlinRuntimeJar.close()
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
projectBuilder.warning("Cannot detect Kotlin class file version for Kotlin distribution: $e")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String readKotlinClassVersionOfCompiledClasses() {
|
||||
if (!isDefined("modulesOutput")) return null
|
||||
|
||||
def kotlinClassFile = new File("$modulesOutput/production/execution-impl/com/intellij/execution/ui/DefaultJreSelector.class")
|
||||
if (!kotlinClassFile.exists()) {
|
||||
projectBuilder.warning("Cannot detect Kotlin class file version of IDEA classes: $kotlinClassFile doesn't exist")
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
return kotlinClassFile.withInputStream { readKotlinClassFileVersion(it) }
|
||||
}
|
||||
catch (IOException e) {
|
||||
projectBuilder.warning("Cannot detect Kotlin class file version of IDEA classes: $e")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private static String readKotlinClassFileVersion(InputStream classFileStream) {
|
||||
def reader = new ClassReader(classFileStream)
|
||||
String kotlinBytecodeVersion = null
|
||||
String kotlinMetaDataVersion = null
|
||||
reader.accept(new ClassVisitor(Opcodes.ASM5) {
|
||||
AnnotationVisitor visitAnnotation(String annotationName, boolean b) {
|
||||
if (annotationName == "Lkotlin/jvm/internal/KotlinClass;") {
|
||||
return new AnnotationVisitor(Opcodes.ASM5) {
|
||||
void visit(String name, Object value) {
|
||||
if (name == "version") {
|
||||
kotlinBytecodeVersion = (value as Integer[]).join(".")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (annotationName == "Lkotlin/Metadata;") {
|
||||
return new AnnotationVisitor(Opcodes.ASM5) {
|
||||
void visit(String name, Object value) {
|
||||
if (name == "mv") {
|
||||
//strip patch number of metadata version because changes in patch updates are forward and backward compatible
|
||||
kotlinMetaDataVersion = (value as Integer[]).toList().dropRight(1).join(".")
|
||||
}
|
||||
else if (name == "bv") {
|
||||
kotlinBytecodeVersion = (value as Integer[]).join(".")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}, 0)
|
||||
if (kotlinBytecodeVersion != null && kotlinMetaDataVersion != null) {
|
||||
kotlinBytecodeVersion = kotlinBytecodeVersion + "." + kotlinMetaDataVersion
|
||||
}
|
||||
return kotlinBytecodeVersion
|
||||
}
|
||||
|
||||
private boolean downloadAndExtract(TeamCityBuildLocator buildLocator, String communityHome, String classVersionOfCompiledClasses) {
|
||||
String buildNumber;
|
||||
try {
|
||||
buildNumber = new URL(buildLocator.buildNumberUrl).text
|
||||
}
|
||||
catch (Exception e) {
|
||||
projectBuilder.info("Cannot get Kotlin build number from $buildLocator.buildNumberUrl: $e")
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
def pluginZip = new File(communityHome, "build/kotlin-plugin-${buildNumber}.zip")
|
||||
def pluginZipPath = pluginZip.absolutePath
|
||||
if (!pluginZip.exists()) {
|
||||
ant.delete(dir: "$communityHome/build", includes: "kotlin-plugin-*.zip")
|
||||
projectBuilder.info("Downloading Kotlin build $buildNumber")
|
||||
ant.get(src: buildLocator.getDownloadUrl(buildNumber), dest: pluginZipPath)
|
||||
}
|
||||
else {
|
||||
projectBuilder.info("Extracting Kotlin build $buildNumber")
|
||||
}
|
||||
|
||||
def kotlincDir = "$communityHome/build/kotlinc"
|
||||
ant.delete(dir: kotlincDir)
|
||||
ant.unzip(src: pluginZipPath, dest: "$kotlincDir/plugin")
|
||||
ant.unzip(src: pluginZipPath, dest: "$kotlincDir") {
|
||||
ant.patternset(includes: "Kotlin/kotlinc/**")
|
||||
ant.globmapper(from: "Kotlin/kotlinc/*", to: "*")
|
||||
}
|
||||
ant.unzip(src: pluginZipPath, dest: "$kotlincDir/jps") {
|
||||
ant.patternset(includes: "Kotlin/lib/jps/**")
|
||||
ant.globmapper(from: "Kotlin/lib/jps/*", to: "*")
|
||||
}
|
||||
def reasonToUpdate = getReasonToUpdate(communityHome, new File(kotlincDir, "plugin/Kotlin"), classVersionOfCompiledClasses)
|
||||
if (reasonToUpdate != null) {
|
||||
projectBuilder.warning("Cannot use the downloaded Kotlin plugin: $reasonToUpdate")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
class TeamCityBuildLocator {
|
||||
String host;
|
||||
String buildTypeId;
|
||||
String buildSelector;
|
||||
|
||||
TeamCityBuildLocator(String host, String buildTypeId, String buildSelector) {
|
||||
this.host = host
|
||||
this.buildTypeId = buildTypeId
|
||||
this.buildSelector = buildSelector
|
||||
}
|
||||
|
||||
String getBuildNumberUrl() {
|
||||
return "$host/guestAuth/app/rest/buildTypes/id:$buildTypeId/builds/$buildSelector,count:1/number"
|
||||
}
|
||||
|
||||
String getDownloadUrl(String buildNumber) {
|
||||
String encodedBuildNumber = URLEncoder.encode(buildNumber, "UTF-8")
|
||||
int index = encodedBuildNumber.lastIndexOf('-')
|
||||
String releaseBuildNumber = encodedBuildNumber.substring(0, index)
|
||||
return "$host/guestAuth/repository/download/$buildTypeId/$encodedBuildNumber/kotlin-plugin-$releaseBuildNumber-IJ2017.1-1.zip"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user