Refactor helper tasks for TeamCity builds
Invoke them properly from TeamCityBuild.xml acting as a temporary adapter. Remove obsolete tasks from TeamCityBuild.xml. Patch plugin version with regex replacement in plugin.xml.
This commit is contained in:
committed by
Vyacheslav Gerasimov
parent
b5db681e06
commit
7710cc455c
+6
-44
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
<macrodef name="run-gradle">
|
<macrodef name="run-gradle">
|
||||||
<attribute name="tasks" />
|
<attribute name="tasks" />
|
||||||
|
<attribute name="args" default="" />
|
||||||
<sequential>
|
<sequential>
|
||||||
<java classname="org.gradle.wrapper.GradleWrapperMain"
|
<java classname="org.gradle.wrapper.GradleWrapperMain"
|
||||||
fork="true"
|
fork="true"
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
</classpath>
|
</classpath>
|
||||||
<arg line="--no-daemon" />
|
<arg line="--no-daemon" />
|
||||||
<arg line="@{tasks}" />
|
<arg line="@{tasks}" />
|
||||||
|
<arg line="@{args}" />
|
||||||
</java>
|
</java>
|
||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</macrodef>
|
||||||
@@ -63,11 +65,11 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="zip-compiler">
|
<target name="zip-compiler">
|
||||||
<run-gradle tasks="zip-compiler" />
|
<run-gradle tasks="zipCompiler" args="-PdeployVersion=${build.number}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="zip-test-data">
|
<target name="zip-test-data">
|
||||||
<run-gradle tasks="zip-test-data" />
|
<run-gradle tasks="zipTestData" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="writeCompilerVersionToTemplateFile">
|
<target name="writeCompilerVersionToTemplateFile">
|
||||||
@@ -75,17 +77,11 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="writePluginVersionToTemplateFile">
|
<target name="writePluginVersionToTemplateFile">
|
||||||
<run-gradle tasks="writePluginVersionToTemplateFile" />
|
<run-gradle tasks="writePluginVersion" args="-PpluginVersion=${plugin.xml.version.number}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="revertTemplateFiles">
|
|
||||||
<run-gradle tasks="revertTemplateFiles" />
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="pre_build" depends="writeCompilerVersionToTemplateFile, writePluginVersionToTemplateFile, cleanupArtifacts"/>
|
|
||||||
|
|
||||||
<target name="zipArtifacts">
|
<target name="zipArtifacts">
|
||||||
<run-gradle tasks="zipArtifacts" />
|
<run-gradle tasks="zipPlugin" args="-PpluginArtifactDir=${pluginArtifactDir} -PpluginZipPath=${plugin.zip}"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<macrodef name="print-statistic">
|
<macrodef name="print-statistic">
|
||||||
@@ -118,42 +114,8 @@
|
|||||||
<print-file-size-statistic path="${basedir}/libraries/stdlib/js/build/classes/main" file-name="kotlin.meta.js"/>
|
<print-file-size-statistic path="${basedir}/libraries/stdlib/js/build/classes/main" file-name="kotlin.meta.js"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="post_build" depends="zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
|
|
||||||
|
|
||||||
<target name="none">
|
<target name="none">
|
||||||
<fail message="Either specify pre_build or post_build"/>
|
<fail message="Either specify pre_build or post_build"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<property name="teamcity.build.branch" value=""/>
|
|
||||||
|
|
||||||
<condition property="need.remove.artifacts" value="true">
|
|
||||||
<and>
|
|
||||||
<matches pattern="rri?/.*" string="${teamcity.build.branch}"/>
|
|
||||||
<not>
|
|
||||||
<matches pattern="rri?/internal/.*" string="${teamcity.build.branch}"/>
|
|
||||||
</not>
|
|
||||||
</and>
|
|
||||||
</condition>
|
|
||||||
|
|
||||||
<target name="remove_internal_artifacts"
|
|
||||||
description="Remove internal artifacts for rri?/* branches, but store them for rri?/internal/*"
|
|
||||||
if="need.remove.artifacts">
|
|
||||||
<echo message="Remove internal artifacts" />
|
|
||||||
|
|
||||||
<delete failonerror="false" verbose="true">
|
|
||||||
<fileset dir="dist">
|
|
||||||
<include name="kotlin-compiler-before-shrink.jar"/>
|
|
||||||
<include name="kotlin-for-upsource.jar"/>
|
|
||||||
<include name="kotlin-for-upsource-sources.jar"/>
|
|
||||||
<include name="kotlin-test-data.zip"/>
|
|
||||||
</fileset>
|
|
||||||
<fileset dir="out/artifacts/internal">
|
|
||||||
<include name="kotlin-ide-common.jar"/>
|
|
||||||
</fileset>
|
|
||||||
</delete>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="dont_remove_internal_artifacts" unless="need.remove.artifacts">
|
|
||||||
<echo message="Internal artifacts left untouched"/>
|
|
||||||
</target>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+34
-58
@@ -507,83 +507,59 @@ tasks {
|
|||||||
"check" { dependsOn("test") }
|
"check" { dependsOn("test") }
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: copied from build.xml (used on TC), reconsider location and dependencies after complete migration
|
fun CopySpec.compilerScriptPermissionsSpec() {
|
||||||
val `zip-compiler` by task<Zip> {
|
filesMatching("bin/*") { mode = 0b111101101 }
|
||||||
|
filesMatching("bin/*.bat") { mode = 0b110100100 }
|
||||||
|
}
|
||||||
|
|
||||||
|
val zipCompiler by task<Zip> {
|
||||||
destinationDir = file(distDir)
|
destinationDir = file(distDir)
|
||||||
archiveName = "kotlin-compiler-$kotlinVersion.zip"
|
archiveName = "kotlin-compiler-$kotlinVersion.zip"
|
||||||
from(distKotlinHomeDir) {
|
from(distKotlinHomeDir) {
|
||||||
exclude("bin/**")
|
|
||||||
into("kotlinc")
|
into("kotlinc")
|
||||||
|
compilerScriptPermissionsSpec()
|
||||||
}
|
}
|
||||||
from("$distKotlinHomeDir/bin") {
|
doLast {
|
||||||
include("*.bat")
|
logger.lifecycle("Compiler artifacts packed to $archivePath")
|
||||||
into("kotlinc/bin")
|
|
||||||
fileMode = 0b110100100
|
|
||||||
}
|
|
||||||
from("$distKotlinHomeDir/bin") {
|
|
||||||
exclude("*.bat")
|
|
||||||
into("kotlinc/bin")
|
|
||||||
fileMode = 0b111101101
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: copied from build.xml (used on TC), reconsider location and dependencies after complete migration
|
val zipTestData by task<Zip> {
|
||||||
val `zip-test-data` by task<Zip> {
|
|
||||||
destinationDir = file(distDir)
|
destinationDir = file(distDir)
|
||||||
archiveName = "kotlin-test-data.zip"
|
archiveName = "kotlin-test-data.zip"
|
||||||
from("compiler/testData") { into("compiler") }
|
from("compiler/testData") { into("compiler") }
|
||||||
from("idea/testData") { into("ide") }
|
from("idea/testData") { into("ide") }
|
||||||
from("idea/idea-completion/testData") { into("ide/completion") }
|
from("idea/idea-completion/testData") { into("ide/completion") }
|
||||||
|
doLast {
|
||||||
|
logger.lifecycle("Test data packed to $archivePath")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: copied from TeamCityBuild.xml (excluding some parts), consider implementing patching in the appropriate projects
|
val zipPlugin by task<Zip> {
|
||||||
|
val src = when (project.findProperty("pluginArtifactDir") as String?) {
|
||||||
val pluginXmlDir = "$rootDir/idea/src/META-INF"
|
"Kotlin" -> ideaPluginDir
|
||||||
val pluginXmlPath = "$pluginXmlDir/plugin.xml"
|
"KotlinUltimate" -> ideaUltimatePluginDir
|
||||||
val pluginXmlBackupDir = "$buildDir/plugin_xml_backup"
|
null -> if (project.hasProperty("ultimate")) ideaUltimatePluginDir else ideaPluginDir
|
||||||
val pluginXmlBackupPath = "$pluginXmlBackupDir/plugin.xml"
|
else -> error("Unsupported plugin artifact dir")
|
||||||
|
}
|
||||||
val backupTemplateFile by task<Copy> {
|
val destPath = project.findProperty("pluginZipPath") as String?
|
||||||
from(pluginXmlPath)
|
val dest = File(destPath ?: "$buildDir/kotlin-plugin.zip")
|
||||||
into(pluginXmlBackupDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
val writePluginVersionToTemplateFile by task<Copy> {
|
|
||||||
dependsOn(backupTemplateFile)
|
|
||||||
from(pluginXmlBackupPath)
|
|
||||||
into(pluginXmlDir)
|
|
||||||
filter { it.replace("@snapshot@", "$buildNumber") }
|
|
||||||
}
|
|
||||||
|
|
||||||
val restoreTemplateFile by task<Copy> {
|
|
||||||
from(pluginXmlBackupPath)
|
|
||||||
into(pluginXmlDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
val revertTemplateFiles by task<Delete> {
|
|
||||||
dependsOn(restoreTemplateFile)
|
|
||||||
delete(pluginXmlBackupDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: copied from build.xml (used on TC), reconsider location, logic and dependencies after complete migration
|
|
||||||
val zipArtifacts by task<Zip> {
|
|
||||||
val dest = File(System.getProperty("plugin.zip") ?: "$distDir/artifacts/kotlin-plugin-$buildNumber.zip")
|
|
||||||
val src = System.getProperty("pluginArtifactDir") ?: ideaPluginDir
|
|
||||||
destinationDir = dest.parentFile
|
destinationDir = dest.parentFile
|
||||||
archiveName = dest.name
|
archiveName = dest.name
|
||||||
from(src) {
|
doFirst {
|
||||||
exclude("kotlinc/bin/**")
|
if (destPath == null) throw GradleException("Specify target zip path with 'pluginZipPath' property")
|
||||||
into("Kotlin")
|
|
||||||
}
|
}
|
||||||
from("$src/kotlinc/bin") {
|
into("Kotlin") {
|
||||||
include("*.bat")
|
from("$src/kotlinc") {
|
||||||
into("Kotlin/kotlinc/bin")
|
into("kotlinc")
|
||||||
fileMode = 0b110100100
|
compilerScriptPermissionsSpec()
|
||||||
|
}
|
||||||
|
from(src) {
|
||||||
|
exclude("kotlinc")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
from("$src/kotlinc/bin") {
|
doLast {
|
||||||
exclude("*.bat")
|
logger.lifecycle("Plugin artifacts packed to $archivePath")
|
||||||
into("Kotlin/kotlinc/bin")
|
|
||||||
fileMode = 0b111101101
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,20 @@ val writeCompilerVersion by tasks.creating {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val writePluginVersion by tasks.creating {
|
||||||
|
val versionFile = project(":idea").projectDir.resolve("src/META-INF/plugin.xml")
|
||||||
|
val pluginVersion = rootProject.findProperty("pluginVersion") as String?
|
||||||
|
inputs.property("version", pluginVersion)
|
||||||
|
outputs.file(versionFile)
|
||||||
|
doLast {
|
||||||
|
requireNotNull(pluginVersion) { "Specify 'pluginVersion' property" }
|
||||||
|
replaceVersion(versionFile, """<version>([^<]+)</version>""") {
|
||||||
|
logger.lifecycle("Writing new plugin version: $pluginVersion")
|
||||||
|
pluginVersion!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val writeVersions by tasks.creating {
|
val writeVersions by tasks.creating {
|
||||||
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
|
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user