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">
|
||||
<attribute name="tasks" />
|
||||
<attribute name="args" default="" />
|
||||
<sequential>
|
||||
<java classname="org.gradle.wrapper.GradleWrapperMain"
|
||||
fork="true"
|
||||
@@ -54,6 +55,7 @@
|
||||
</classpath>
|
||||
<arg line="--no-daemon" />
|
||||
<arg line="@{tasks}" />
|
||||
<arg line="@{args}" />
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
@@ -63,11 +65,11 @@
|
||||
</target>
|
||||
|
||||
<target name="zip-compiler">
|
||||
<run-gradle tasks="zip-compiler" />
|
||||
<run-gradle tasks="zipCompiler" args="-PdeployVersion=${build.number}" />
|
||||
</target>
|
||||
|
||||
<target name="zip-test-data">
|
||||
<run-gradle tasks="zip-test-data" />
|
||||
<run-gradle tasks="zipTestData" />
|
||||
</target>
|
||||
|
||||
<target name="writeCompilerVersionToTemplateFile">
|
||||
@@ -75,17 +77,11 @@
|
||||
</target>
|
||||
|
||||
<target name="writePluginVersionToTemplateFile">
|
||||
<run-gradle tasks="writePluginVersionToTemplateFile" />
|
||||
<run-gradle tasks="writePluginVersion" args="-PpluginVersion=${plugin.xml.version.number}" />
|
||||
</target>
|
||||
|
||||
<target name="revertTemplateFiles">
|
||||
<run-gradle tasks="revertTemplateFiles" />
|
||||
</target>
|
||||
|
||||
<target name="pre_build" depends="writeCompilerVersionToTemplateFile, writePluginVersionToTemplateFile, cleanupArtifacts"/>
|
||||
|
||||
<target name="zipArtifacts">
|
||||
<run-gradle tasks="zipArtifacts" />
|
||||
<run-gradle tasks="zipPlugin" args="-PpluginArtifactDir=${pluginArtifactDir} -PpluginZipPath=${plugin.zip}"/>
|
||||
</target>
|
||||
|
||||
<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"/>
|
||||
</target>
|
||||
|
||||
<target name="post_build" depends="zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
|
||||
|
||||
<target name="none">
|
||||
<fail message="Either specify pre_build or post_build"/>
|
||||
</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>
|
||||
|
||||
+34
-58
@@ -507,83 +507,59 @@ tasks {
|
||||
"check" { dependsOn("test") }
|
||||
}
|
||||
|
||||
// TODO: copied from build.xml (used on TC), reconsider location and dependencies after complete migration
|
||||
val `zip-compiler` by task<Zip> {
|
||||
fun CopySpec.compilerScriptPermissionsSpec() {
|
||||
filesMatching("bin/*") { mode = 0b111101101 }
|
||||
filesMatching("bin/*.bat") { mode = 0b110100100 }
|
||||
}
|
||||
|
||||
val zipCompiler by task<Zip> {
|
||||
destinationDir = file(distDir)
|
||||
archiveName = "kotlin-compiler-$kotlinVersion.zip"
|
||||
from(distKotlinHomeDir) {
|
||||
exclude("bin/**")
|
||||
into("kotlinc")
|
||||
compilerScriptPermissionsSpec()
|
||||
}
|
||||
from("$distKotlinHomeDir/bin") {
|
||||
include("*.bat")
|
||||
into("kotlinc/bin")
|
||||
fileMode = 0b110100100
|
||||
}
|
||||
from("$distKotlinHomeDir/bin") {
|
||||
exclude("*.bat")
|
||||
into("kotlinc/bin")
|
||||
fileMode = 0b111101101
|
||||
doLast {
|
||||
logger.lifecycle("Compiler artifacts packed to $archivePath")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: copied from build.xml (used on TC), reconsider location and dependencies after complete migration
|
||||
val `zip-test-data` by task<Zip> {
|
||||
val zipTestData by task<Zip> {
|
||||
destinationDir = file(distDir)
|
||||
archiveName = "kotlin-test-data.zip"
|
||||
from("compiler/testData") { into("compiler") }
|
||||
from("idea/testData") { into("ide") }
|
||||
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 pluginXmlDir = "$rootDir/idea/src/META-INF"
|
||||
val pluginXmlPath = "$pluginXmlDir/plugin.xml"
|
||||
val pluginXmlBackupDir = "$buildDir/plugin_xml_backup"
|
||||
val pluginXmlBackupPath = "$pluginXmlBackupDir/plugin.xml"
|
||||
|
||||
val backupTemplateFile by task<Copy> {
|
||||
from(pluginXmlPath)
|
||||
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
|
||||
val zipPlugin by task<Zip> {
|
||||
val src = when (project.findProperty("pluginArtifactDir") as String?) {
|
||||
"Kotlin" -> ideaPluginDir
|
||||
"KotlinUltimate" -> ideaUltimatePluginDir
|
||||
null -> if (project.hasProperty("ultimate")) ideaUltimatePluginDir else ideaPluginDir
|
||||
else -> error("Unsupported plugin artifact dir")
|
||||
}
|
||||
val destPath = project.findProperty("pluginZipPath") as String?
|
||||
val dest = File(destPath ?: "$buildDir/kotlin-plugin.zip")
|
||||
destinationDir = dest.parentFile
|
||||
archiveName = dest.name
|
||||
from(src) {
|
||||
exclude("kotlinc/bin/**")
|
||||
into("Kotlin")
|
||||
doFirst {
|
||||
if (destPath == null) throw GradleException("Specify target zip path with 'pluginZipPath' property")
|
||||
}
|
||||
from("$src/kotlinc/bin") {
|
||||
include("*.bat")
|
||||
into("Kotlin/kotlinc/bin")
|
||||
fileMode = 0b110100100
|
||||
into("Kotlin") {
|
||||
from("$src/kotlinc") {
|
||||
into("kotlinc")
|
||||
compilerScriptPermissionsSpec()
|
||||
}
|
||||
from(src) {
|
||||
exclude("kotlinc")
|
||||
}
|
||||
}
|
||||
from("$src/kotlinc/bin") {
|
||||
exclude("*.bat")
|
||||
into("Kotlin/kotlinc/bin")
|
||||
fileMode = 0b111101101
|
||||
doLast {
|
||||
logger.lifecycle("Plugin artifacts packed to $archivePath")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
dependsOn(writeBuildNumber, writeStdlibVersion, writeCompilerVersion)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user