Replace android sdk dependencies with custom project build, cleanup update_dependencies.xml

This commit is contained in:
Ilya Chernikov
2017-11-15 18:50:21 +01:00
committed by Vyacheslav Gerasimov
parent 98204aa2d3
commit 0b63e11ea8
19 changed files with 184 additions and 222 deletions
+19 -1
View File
@@ -2,10 +2,12 @@
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project
import java.io.File
@@ -97,3 +99,19 @@ fun firstFromJavaHomeThatExists(vararg paths: String): File? =
paths.mapNotNull { File(jreHome, it).takeIf { it.exists() } }.firstOrNull()
fun toolsJar(): File? = firstFromJavaHomeThatExists("../lib/tools.jar", "../Classes/tools.jar")
private fun Task.addConfigurationAndProjectDependency(name: String, sourceProject: String, sourceConfiguration: String, sourceTask: String): Configuration {
dependsOn("$sourceProject:$sourceTask")
return project.configurations.findByName(name) // assuming that dependency is already added too
?: project.configurations.create(name).also {
DependencyHandlerScope(project.dependencies).let { dh -> dh.add(name, dh.project(sourceProject, configuration = sourceConfiguration)) }
}
}
fun Task.androidSdkPath(): String =
addConfigurationAndProjectDependency("androidSdk", ":custom-dependencies:android-sdk", "androidSdk", "prepareSdk")
.singleFile.canonicalPath
fun Task.androidJarPath(): String =
addConfigurationAndProjectDependency("androidJar", ":custom-dependencies:android-sdk", "androidJar", "extractAndroidJar")
.singleFile.canonicalPath
+1 -1
View File
@@ -62,7 +62,7 @@ dependencies {
testRuntime(projectDist(":kotlin-reflect"))
testRuntime(projectDist(":kotlin-daemon-client"))
testRuntime(preloadedDeps("dx", subdir = "android-5.0/lib"))
testRuntime(project(":custom-dependencies:android-sdk", configuration = "dxJar"))
testRuntime(files(toolsJar()))
testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6"))
+1 -1
View File
@@ -29,7 +29,7 @@ dependencies {
testCompile(projectTests(":compiler:tests-common-jvm6"))
testCompileOnly(project(":kotlin-reflect-api"))
testCompile(commonDep("junit:junit"))
testCompile(preloadedDeps("dx", subdir = "android-5.0/lib"))
testCompile(project(":custom-dependencies:android-sdk", configuration = "dxJar"))
}
afterEvaluate {
@@ -366,7 +366,27 @@ public class KotlinTestUtils {
}
public static File findAndroidApiJar() {
return new File(getHomeDirectory(), "dependencies/android.jar");
String androidJarProp = System.getProperty("android.jar");
File androidJarFile = androidJarProp == null ? null : new File(androidJarProp);
if (androidJarFile == null || !androidJarFile.isFile()) {
throw new RuntimeException(
"Unable to get a valid path from 'android.jar' property (" +
androidJarProp +
"), please point it to the 'android.jar' file location");
}
return androidJarFile;
}
public static File findAndroidSdk() {
String androidSdkProp = System.getProperty("android.sdk");
File androidSdkDir = androidSdkProp == null ? null : new File(androidSdkProp);
if (androidSdkDir == null || !androidSdkDir.isDirectory()) {
throw new RuntimeException(
"Unable to get a valid path from 'android.sdk' property (" +
androidSdkProp +
"), please point it to the android SDK location");
}
return androidSdkDir;
}
public static File getAnnotationsJar() {
@@ -0,0 +1,99 @@
import java.io.File
// TODO: consider adding dx sources (the only jar used on the compile time so far)
// e.g. from "https://android.googlesource.com/platform/dalvik/+archive/android-5.0.0_r2/dx.tar.gz"
repositories {
ivy {
artifactPattern("https://dl-ssl.google.com/android/repository/[artifact]-[revision].[ext]")
artifactPattern("https://dl-ssl.google.com/android/repository/[artifact]_[revision](-[classifier]).[ext]")
artifactPattern("https://dl.google.com/android/repository/[artifact]_[revision](-[classifier]).[ext]")
}
}
val androidSdk by configurations.creating
val androidJar by configurations.creating
val dxJar by configurations.creating
val androidPlatform by configurations.creating
val buildTools by configurations.creating
val libsDestDir = File(buildDir, "libs")
val sdkDestDir = File(buildDir, "androidSdk")
data class LocMap(val name: String, val ver: String, val dest: String, val suffix: String,
val additionalConfig: Configuration? = null, val dirLevelsToSkit: Int = 0)
val sdkLocMaps = listOf(
LocMap("platform", "26_r02", "platforms/android-26", "", androidPlatform, 1),
LocMap("android_m2repository", "r44", "extras/android", ""),
LocMap("platform-tools", "r25.0.3", "", "linux"),
LocMap("tools", "r24.3.4", "", "linux"),
LocMap("build-tools", "r23.0.1", "build-tools/23.0.1", "linux", buildTools, 1))
val prepareSdk by task<DefaultTask> {
outputs.dir(sdkDestDir)
doLast {}
}
fun LocMap.toDependency(): String =
"google:$name:$ver${suffix?.takeIf{ it.isNotEmpty() }?.let { ":$it" } ?: ""}@zip"
sdkLocMaps.forEach {
val id = "${it.name}_${it.ver}"
val cfg = configurations.create(id)
val dependency = it.toDependency()
dependencies.add(cfg.name, dependency)
val t = task<Copy>("unzip_$id") {
afterEvaluate {
from(zipTree(cfg.singleFile))
}
into(file("$sdkDestDir/${it.dest}"))
}
if (it.dirLevelsToSkit > 0) {
t.apply {
eachFile {
path = path.split("/").drop(it.dirLevelsToSkit).joinToString("/")
}
}
}
prepareSdk.dependsOn(t)
it.additionalConfig?.also {
dependencies.add(it.name, dependency)
}
}
val clean by task<Delete> {
delete(buildDir)
}
val extractAndroidJar by task<Copy> {
configurations.add(androidJar)
afterEvaluate {
from(zipTree(androidPlatform.singleFile).matching { include("**/android.jar") }.files.first())
}
into(libsDestDir)
}
val extractDxJar by task<Copy> {
configurations.add(dxJar)
afterEvaluate {
from(zipTree(buildTools.singleFile).matching { include("**/dx.jar") }.files.first())
}
into(libsDestDir)
}
artifacts.add(androidSdk.name, file("$sdkDestDir")) {
builtBy(prepareSdk)
}
artifacts.add(androidJar.name, file("$libsDestDir/android.jar")) {
builtBy(extractAndroidJar)
}
artifacts.add(dxJar.name, file("$libsDestDir/dx.jar")) {
builtBy(extractDxJar)
}
+7 -1
View File
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
apply { plugin("kotlin") }
@@ -18,7 +19,7 @@ dependencies {
compile(project(":idea:ide-common"))
compile(project(":idea:idea-gradle"))
compile(preloadedDeps("dx", subdir = "android-5.0/lib"))
compile(project(":custom-dependencies:android-sdk", configuration = "dxJar"))
testCompile(projectDist(":kotlin-test:kotlin-test-jvm"))
testCompile(project(":idea:idea-test-framework")) { isTransitive = false }
@@ -56,8 +57,13 @@ sourceSets {
"test" { projectDefault() }
}
tasks.withType<KotlinCompile> {
dependsOn(":custom-dependencies:android-sdk:extractDxJar")
}
projectTest {
workingDir = rootDir
systemProperty("android.sdk", androidSdkPath())
}
testsJar {}
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.android;
import com.android.annotations.NonNull;
import com.intellij.openapi.application.PathManager;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import java.io.File;
@@ -29,7 +30,7 @@ import java.io.File;
public class TestUtils {
@NonNull
public static File getSdk() {
return new File(PathManager.getHomePath() + "/../dependencies/androidSDK");
return KotlinTestUtils.findAndroidSdk();
}
@NonNull
+1
View File
@@ -61,6 +61,7 @@ testsJar()
projectTest {
workingDir = rootDir
systemProperty("android.sdk", androidSdkPath())
}
configureInstrumentation()
@@ -22,6 +22,7 @@ import com.intellij.util.PathUtil
import junit.framework.TestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.GradleImportingTestCase
import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
import java.io.File
@@ -470,7 +471,7 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
}
""")
createProjectSubFile("local.properties", """
sdk.dir=/${StringUtil.escapeBackSlashes(File(homePath).parent + "/dependencies/androidSDK")}
sdk.dir=/${KotlinTestUtils.findAndroidSdk()}
""")
@@ -597,7 +598,7 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
}
""")
createProjectSubFile("local.properties", """
sdk.dir=/${StringUtil.escapeBackSlashes(File(homePath).parent + "/dependencies/androidSDK")}
sdk.dir=/${KotlinTestUtils.findAndroidSdk()}
""")
importProject()
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Assert
import org.junit.Test
import java.io.File
@@ -1108,7 +1109,7 @@ compileTestKotlin {
include ':js-module'
""")
createProjectSubFile("local.properties", """
sdk.dir=/${StringUtil.escapeBackSlashes(File(homePath).parent + "/dependencies/androidSDK")}
sdk.dir=/${KotlinTestUtils.findAndroidSdk()}
""")
importProject()
@@ -1177,7 +1178,7 @@ compileTestKotlin {
}
""")
createProjectSubFile("local.properties", """
sdk.dir=/${StringUtil.escapeBackSlashes(File(homePath).parent + "/dependencies/androidSDK")}
sdk.dir=/${KotlinTestUtils.findAndroidSdk()}
""")
createProjectSubFile("src/main/AndroidManifest.xml", """
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -7,6 +7,10 @@ repositories {
jcenter()
}
configurations {
androidSdk
}
dependencies {
testCompile project(':kotlin-gradle-plugin')
testCompile project(':kotlin-gradle-plugin').sourceSets.test.output
@@ -25,6 +29,8 @@ dependencies {
testCompile gradleApi()
testRuntime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar')
androidSdk project(path: ":custom-dependencies:android-sdk", configuration: "androidSdk")
}
// Include Gradle task properties validation into the testing procedure:
@@ -81,6 +87,7 @@ tasks.withType(Test) {
if (mavenLocalRepo != null) {
systemProperty("maven.repo.local", mavenLocalRepo)
}
systemProperty("android.sdk", project.configurations["androidSdk"].singleFile.getCanonicalPath())
testLogging {
// set options for log level LIFECYCLE
@@ -5,6 +5,7 @@ import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.getFilesByNames
import org.jetbrains.kotlin.gradle.util.isLegacyAndroidGradleVersion
import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
import java.io.File
@@ -41,15 +42,13 @@ class KotlinAndroid30GradleIT : AbstractKotlinAndroidGradleTests(gradleVersion =
}
}
const val ANDROID_HOME_PATH = "../../../dependencies/androidSDK"
abstract class AbstractKotlinAndroidGradleTests(
protected val gradleVersion: String,
private val androidGradlePluginVersion: String
) : BaseGradleIT() {
override fun defaultBuildOptions() =
super.defaultBuildOptions().copy(androidHome = File(ANDROID_HOME_PATH),
super.defaultBuildOptions().copy(androidHome = KotlinTestUtils.findAndroidSdk(),
androidGradlePluginVersion = androidGradlePluginVersion)
@Test
@@ -301,7 +300,7 @@ abstract class AbstractKotlinAndroidWithJackGradleTests(
fun getEnvJDK_18() = System.getenv()["JDK_18"]
override fun defaultBuildOptions() =
super.defaultBuildOptions().copy(androidHome = File(ANDROID_HOME_PATH),
super.defaultBuildOptions().copy(androidHome = KotlinTestUtils.findAndroidSdk(),
androidGradlePluginVersion = androidGradlePluginVersion, javaHome = File(getEnvJDK_18()))
@Test
@@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.util.allKotlinFiles
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.getFilesByNames
import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
import java.io.File
@@ -15,9 +16,9 @@ class IncrementalCompilationMultiProjectIT : BaseGradleIT() {
private fun androidBuildOptions() =
BuildOptions(withDaemon = true,
androidHome = File(ANDROID_HOME_PATH),
androidGradlePluginVersion = ANDROID_GRADLE_PLUGIN_VERSION,
incremental = true)
androidHome = KotlinTestUtils.findAndroidSdk(),
androidGradlePluginVersion = ANDROID_GRADLE_PLUGIN_VERSION,
incremental = true)
override fun defaultBuildOptions(): BuildOptions =
super.defaultBuildOptions().copy(withDaemon = true, incremental = true)
@@ -1,6 +1,7 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.isLegacyAndroidGradleVersion
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.junit.Test
import java.io.File
@@ -19,9 +20,9 @@ open class Kapt3AndroidIT : Kapt3BaseIT() {
private fun androidBuildOptions() =
BuildOptions(withDaemon = true,
androidHome = File(ANDROID_HOME_PATH),
androidGradlePluginVersion = androidGradlePluginVersion,
freeCommandLineArgs = listOf("-Pkapt.verbose=true"))
androidHome = KotlinTestUtils.findAndroidSdk(),
androidGradlePluginVersion = androidGradlePluginVersion,
freeCommandLineArgs = listOf("-Pkapt.verbose=true"))
override fun defaultBuildOptions() = androidBuildOptions()
@@ -58,6 +58,7 @@ testsJar {}
projectTest {
dependsOn(":kotlin-android-extensions-runtime:dist")
workingDir = rootDir
systemProperty("android.sdk", androidSdkPath())
}
runtimeJar()
@@ -18,13 +18,15 @@ package org.jetbrains.kotlin.android
import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTest
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
abstract class AbstractParcelQuickFixTest : AbstractAndroidQuickFixMultiFileTest() {
override fun setUp() {
super.setUp()
val androidJarDir = File("dependencies/androidSDK/platforms").listFiles().first { it.name.startsWith("android-") }
val androidSdk = KotlinTestUtils.findAndroidSdk()
val androidJarDir = File(androidSdk, "platforms").listFiles().first { it.name.startsWith("android-") }
ConfigLibraryUtil.addLibrary(myModule, "androidJar", androidJarDir.absolutePath, arrayOf("android.jar"))
ConfigLibraryUtil.addLibrary(myModule, "androidExtensionsRuntime", "dist/kotlinc/lib", arrayOf("android-extensions-runtime.jar"))
@@ -24,6 +24,7 @@ import org.jetbrains.jps.android.model.JpsAndroidSdkType
import org.jetbrains.jps.model.impl.JpsSimpleElementImpl
import org.jetbrains.jps.model.library.JpsOrderRootType
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File
abstract class AbstractAndroidJpsTestCase : BaseKotlinJpsBuildTestCase() {
@@ -42,7 +43,7 @@ abstract class AbstractAndroidJpsTestCase : BaseKotlinJpsBuildTestCase() {
val jdkName = "java_sdk"
addJdk(jdkName)
val properties = JpsAndroidSdkProperties("android-23", jdkName)
val sdkPath = homePath + "/../dependencies/androidSDK"
val sdkPath = KotlinTestUtils.findAndroidSdk().canonicalPath
val library = myModel.global.addSdk(SDK_NAME, sdkPath, "", JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties))
library.addRoot(File(sdkPath + "/platforms/android-23/android.jar"), JpsOrderRootType.COMPILED)
return library.properties
+1
View File
@@ -57,6 +57,7 @@ include ":kotlin-build-common",
":core:util.runtime",
":custom-dependencies:protobuf-relocated",
":custom-dependencies:protobuf-lite",
":custom-dependencies:android-sdk",
":idea:idea-jvm",
":idea:idea-maven",
":idea:idea-gradle",
+2 -200
View File
@@ -40,208 +40,10 @@
<!--build.locator.request="buildType:bt410,status:SUCCESS,branch:idea/${ideaVersion}-${idea.kotlin.branch}"/>-->
<!--</target>-->
<target name="get-ivy-library">
<mkdir dir="${dependencies}/download"/>
<get-maven-library prefix="org/apache/ivy" lib="ivy" version="2.4.0" target.jar.name.base="ivy"/>
<target name="fetch-third-party" depends="make-dependency-dirs">
</target>
<macrodef name="get-maven-library">
<attribute name="prefix"/>
<attribute name="lib"/>
<attribute name="version"/>
<attribute name="bin" default="true"/>
<attribute name="src" default="true"/>
<attribute name="server" default="https://repo1.maven.org/maven2"/>
<attribute name="jar.name.base" default="@{lib}-@{version}"/>
<attribute name="target.jar.name.base" default="@{jar.name.base}"/>
<attribute name="path" default="@{prefix}/@{lib}/@{version}/@{jar.name.base}"/>
<attribute name="download" default="${dependencies}/download"/>
<attribute name="dependencies" default="${dependencies}"/>
<sequential>
<sequential if:true="@{bin}">
<get src="@{server}/@{path}.jar" dest="@{download}/@{jar.name.base}.jar" usetimestamp="true"/>
<copy file="@{download}/@{jar.name.base}.jar" tofile="@{dependencies}/@{target.jar.name.base}.jar" overwrite="true"/>
</sequential>
<sequential if:true="@{src}">
<get src="@{server}/@{path}-sources.jar" dest="@{download}/@{jar.name.base}-sources.jar" usetimestamp="true"/>
<copy file="@{download}/@{jar.name.base}-sources.jar" tofile="@{dependencies}/@{target.jar.name.base}-sources.jar"
overwrite="true"/>
</sequential>
</sequential>
</macrodef>
<!--
This doesn't download sources, see https://issues.apache.org/jira/browse/IVY-1003.
Please download sources manually if you need them.
-->
<macrodef name="get-maven-library-with-dependencies">
<attribute name="group"/>
<attribute name="artifact"/>
<attribute name="version"/>
<attribute name="target.dir" default="maven"/>
<sequential>
<mkdir dir="${dependencies}/@{target.dir}"/>
<java classname="org.apache.ivy.Main" fork="true">
<arg value="-dependency"/>
<arg value="@{group}"/>
<arg value="@{artifact}"/>
<arg value="@{version}"/>
<arg value="-retrieve"/>
<arg value="${dependencies}/@{target.dir}/[artifact]-[revision](-[classifier]).[ext]"/>
<classpath>
<pathelement location="${dependencies}/ivy.jar"/>
</classpath>
</java>
</sequential>
</macrodef>
<macrodef name="get-ant-library">
<attribute name="version"/>
<attribute name="folderName"/>
<sequential>
<get src="http://archive.apache.org/dist/ant/binaries/apache-ant-@{version}-bin.tar.gz"
dest="${dependencies}/download/apache-ant-@{version}-bin.tar.gz" usetimestamp="true"/>
<get src="http://archive.apache.org/dist/ant/source/apache-ant-@{version}-src.zip"
dest="${dependencies}/apache-ant-@{version}-src.zip" usetimestamp="true"/>
<delete dir="${dependencies}/@{folderName}" failonerror="false"/>
<untar src="${dependencies}/download/apache-ant-@{version}-bin.tar.gz" dest="${dependencies}" compression="gzip"/>
<move file="${dependencies}/apache-ant-@{version}" tofile="${dependencies}/@{folderName}"/>
</sequential>
</macrodef>
<target name="fetch-third-party" depends="get-ivy-library, make-dependency-dirs">
<!-- dx.jar -->
<property name="android-build-tools.zip" value="build-tools_r21.1.1-linux.zip"/>
<get
src="https://dl-ssl.google.com/android/repository/${android-build-tools.zip}"
dest="${dependencies}/download/${android-build-tools.zip}"
usetimestamp="true"/>
<unzip src="${dependencies}/download/${android-build-tools.zip}" dest="${dependencies}"/>
<property name="android-sources.tgz" value="dx.tar.gz"/>
<get
src="https://android.googlesource.com/platform/dalvik/+archive/android-5.0.0_r2/${android-sources.tgz}"
dest="${dependencies}/download/${android-sources.tgz}"
usetimestamp="true"/>
<delete dir="${dependencies}/dx-src" failonerror="false"/>
<untar src="${dependencies}/download/${android-sources.tgz}" dest="${dependencies}/dx-src" compression="gzip"/>
<!-- jline -->
<get-maven-library prefix="org/jline" lib="jline" version="3.3.1" target.jar.name.base="jline3"/>
<!-- jansi -->
<get-maven-library prefix="org/fusesource/jansi" lib="jansi" version="1.16" target.jar.name.base="jansi"/>
<!-- Guava 21 sources-->
<get-maven-library prefix="com/google/guava" lib="guava" version="21.0" bin="false"/>
<!-- ASM -->
<get src="https://raw.github.com/JetBrains/intellij-community/172/lib/src/asm-src.zip"
dest="${dependencies}/asm-src.zip"/>
<!-- Junit Sources -->
<get-maven-library prefix="junit" lib="junit" version="4.12" bin="false"/>
<get-maven-library prefix="org/hamcrest" lib="hamcrest-core" version="1.3" bin="false"/>
<!-- Android SDK platform -->
<ant antfile="download_android_sdk.xml" target="download_android_sdk"/>
<!-- Javaslang -->
<get-maven-library prefix="io/javaslang" lib="javaslang" version="2.0.6"/>
<delete file="${dependencies}/android.jar" failonerror="false"/>
<get src="http://dl-ssl.google.com/android/repository/android-19_r02.zip"
dest="${dependencies}/download/android-sdk.zip" usetimestamp="true"/>
<unzip src="${dependencies}/download/android-sdk.zip" dest="${dependencies}">
<patternset>
<include name="**/android.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
</target>
<macrodef name="download_teamcity_artifact">
<attribute name="teamcity.server.url"/>
<attribute name="build.locator.request"/>
<attribute name="artifact.path"/>
<attribute name="dest"/>
<attribute name="usetimestamp"/>
<attribute name="build.number.pattern" default="[\w-+\.]+"/>
<sequential>
<local name="artifact.build.id"/>
<local name="build.request.url"/>
<property name="build.request.url"
value="@{teamcity.server.url}/guestAuth/app/rest/builds/?locator=@{build.locator.request},count:1"/>
<echo message="Requested URL ${build.request.url}"/>
<loadresource property="artifact.build.id">
<url url="${build.request.url}"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="^(.*)\sid=&quot;(\d+)&quot;(.*)$" replace="\2" flags="s"/>
</tokenfilter>
</filterchain>
</loadresource>
<local name="processed.artifact.path"/>
<local name="artifact.build.number"/>
<loadresource property="artifact.build.number">
<url url="${build.request.url}"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="^(.*)\snumber=&quot;(@{build.number.pattern})&quot;(.*)$" replace="\2" flags="s"/>
</tokenfilter>
</filterchain>
</loadresource>
<loadresource property="processed.artifact.path">
<string value="@{artifact.path}"/>
<filterchain>
<replacestring from="{build.number}" to="${artifact.build.number}"/>
</filterchain>
</loadresource>
<echo message="Build Number: ${artifact.build.number} Build Id: ${artifact.build.id}"/>
<get
src="@{teamcity.server.url}/guestAuth/app/rest/builds/id:${artifact.build.id}/artifacts/content/${processed.artifact.path}"
dest="@{dest}" usetimestamp="@{usetimestamp}"/>
</sequential>
</macrodef>
<macrodef name="download_and_unzip">
<attribute name="url"/>
<attribute name="dir"/>
<attribute name="usetimestamp"/>
<sequential>
<get src="@{url}" dest="@{dir}.zip" usetimestamp="@{usetimestamp}"/>
<local name="need.unpack"/>
<condition property="need.unpack">
<not>
<available file="@{dir}" type="dir"/>
</not>
</condition>
<unzip src="@{dir}.zip" dest="@{dir}" if:set="need.unpack"/>
<echo message="Folder exist - so not unpacked @{dir}" unless:set="need.unpack"/>
</sequential>
</macrodef>
<!--
Currently we use empty annotations.
Future options are: